2
0

pdf.worker.js 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499
  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.440';
  27. var pdfjsBuild = 'e5cea05';
  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. }
  6499. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  6500. return NaN;
  6501. }
  6502. function parseFloatOperand() {
  6503. var str = '';
  6504. var eof = 15;
  6505. var lookup = [
  6506. '0',
  6507. '1',
  6508. '2',
  6509. '3',
  6510. '4',
  6511. '5',
  6512. '6',
  6513. '7',
  6514. '8',
  6515. '9',
  6516. '.',
  6517. 'E',
  6518. 'E-',
  6519. null,
  6520. '-'
  6521. ];
  6522. var length = dict.length;
  6523. while (pos < length) {
  6524. var b = dict[pos++];
  6525. var b1 = b >> 4;
  6526. var b2 = b & 15;
  6527. if (b1 === eof) {
  6528. break;
  6529. }
  6530. str += lookup[b1];
  6531. if (b2 === eof) {
  6532. break;
  6533. }
  6534. str += lookup[b2];
  6535. }
  6536. return parseFloat(str);
  6537. }
  6538. var operands = [];
  6539. var entries = [];
  6540. pos = 0;
  6541. var end = dict.length;
  6542. while (pos < end) {
  6543. var b = dict[pos];
  6544. if (b <= 21) {
  6545. if (b === 12) {
  6546. b = b << 8 | dict[++pos];
  6547. }
  6548. entries.push([
  6549. b,
  6550. operands
  6551. ]);
  6552. operands = [];
  6553. ++pos;
  6554. } else {
  6555. operands.push(parseOperand());
  6556. }
  6557. }
  6558. return entries;
  6559. },
  6560. parseIndex: function CFFParser_parseIndex(pos) {
  6561. var cffIndex = new CFFIndex();
  6562. var bytes = this.bytes;
  6563. var count = bytes[pos++] << 8 | bytes[pos++];
  6564. var offsets = [];
  6565. var end = pos;
  6566. var i, ii;
  6567. if (count !== 0) {
  6568. var offsetSize = bytes[pos++];
  6569. var startPos = pos + (count + 1) * offsetSize - 1;
  6570. for (i = 0, ii = count + 1; i < ii; ++i) {
  6571. var offset = 0;
  6572. for (var j = 0; j < offsetSize; ++j) {
  6573. offset <<= 8;
  6574. offset += bytes[pos++];
  6575. }
  6576. offsets.push(startPos + offset);
  6577. }
  6578. end = offsets[count];
  6579. }
  6580. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  6581. var offsetStart = offsets[i];
  6582. var offsetEnd = offsets[i + 1];
  6583. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  6584. }
  6585. return {
  6586. obj: cffIndex,
  6587. endPos: end
  6588. };
  6589. },
  6590. parseNameIndex: function CFFParser_parseNameIndex(index) {
  6591. var names = [];
  6592. for (var i = 0, ii = index.count; i < ii; ++i) {
  6593. var name = index.get(i);
  6594. var length = Math.min(name.length, 127);
  6595. var data = [];
  6596. for (var j = 0; j < length; ++j) {
  6597. var c = name[j];
  6598. if (j === 0 && c === 0) {
  6599. data[j] = c;
  6600. continue;
  6601. }
  6602. if (c < 33 || c > 126 || c === 91 || c === 93 || c === 40 || c === 41 || c === 123 || c === 125 || c === 60 || c === 62 || c === 47 || c === 37 || c === 35)
  6603. {
  6604. data[j] = 95;
  6605. continue;
  6606. }
  6607. data[j] = c;
  6608. }
  6609. names.push(bytesToString(data));
  6610. }
  6611. return names;
  6612. },
  6613. parseStringIndex: function CFFParser_parseStringIndex(index) {
  6614. var strings = new CFFStrings();
  6615. for (var i = 0, ii = index.count; i < ii; ++i) {
  6616. var data = index.get(i);
  6617. strings.add(bytesToString(data));
  6618. }
  6619. return strings;
  6620. },
  6621. createDict: function CFFParser_createDict(Type, dict, strings) {
  6622. var cffDict = new Type(strings);
  6623. for (var i = 0, ii = dict.length; i < ii; ++i) {
  6624. var pair = dict[i];
  6625. var key = pair[0];
  6626. var value = pair[1];
  6627. cffDict.setByKey(key, value);
  6628. }
  6629. return cffDict;
  6630. },
  6631. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  6632. if (state.callDepth > MAX_SUBR_NESTING) {
  6633. return false;
  6634. }
  6635. var stackSize = state.stackSize;
  6636. var stack = state.stack;
  6637. var length = data.length;
  6638. for (var j = 0; j < length;) {
  6639. var value = data[j++];
  6640. var validationCommand = null;
  6641. if (value === 12) {
  6642. var q = data[j++];
  6643. if (q === 0) {
  6644. data[j - 2] = 139;
  6645. data[j - 1] = 22;
  6646. stackSize = 0;
  6647. } else {
  6648. validationCommand = CharstringValidationData12[q];
  6649. }
  6650. } else if (value === 28) {
  6651. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  6652. j += 2;
  6653. stackSize++;
  6654. } else if (value === 14) {
  6655. if (stackSize >= 4) {
  6656. stackSize -= 4;
  6657. if (this.seacAnalysisEnabled) {
  6658. state.seac = stack.slice(stackSize, stackSize + 4);
  6659. return false;
  6660. }
  6661. }
  6662. validationCommand = CharstringValidationData[value];
  6663. } else if (value >= 32 && value <= 246) {
  6664. stack[stackSize] = value - 139;
  6665. stackSize++;
  6666. } else if (value >= 247 && value <= 254) {
  6667. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  6668. j++;
  6669. stackSize++;
  6670. } else if (value === 255) {
  6671. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  6672. j += 4;
  6673. stackSize++;
  6674. } else if (value === 19 || value === 20) {
  6675. state.hints += stackSize >> 1;
  6676. j += state.hints + 7 >> 3;
  6677. stackSize %= 2;
  6678. validationCommand = CharstringValidationData[value];
  6679. } else if (value === 10 || value === 29) {
  6680. var subrsIndex;
  6681. if (value === 10) {
  6682. subrsIndex = localSubrIndex;
  6683. } else {
  6684. subrsIndex = globalSubrIndex;
  6685. }
  6686. if (!subrsIndex) {
  6687. validationCommand = CharstringValidationData[value];
  6688. warn('Missing subrsIndex for ' + validationCommand.id);
  6689. return false;
  6690. }
  6691. var bias = 32768;
  6692. if (subrsIndex.count < 1240) {
  6693. bias = 107;
  6694. } else if (subrsIndex.count < 33900) {
  6695. bias = 1131;
  6696. }
  6697. var subrNumber = stack[--stackSize] + bias;
  6698. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  6699. validationCommand = CharstringValidationData[value];
  6700. warn('Out of bounds subrIndex for ' + validationCommand.id);
  6701. return false;
  6702. }
  6703. state.stackSize = stackSize;
  6704. state.callDepth++;
  6705. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  6706. if (!valid) {
  6707. return false;
  6708. }
  6709. state.callDepth--;
  6710. stackSize = state.stackSize;
  6711. continue;
  6712. } else if (value === 11) {
  6713. state.stackSize = stackSize;
  6714. return true;
  6715. } else {
  6716. validationCommand = CharstringValidationData[value];
  6717. }
  6718. if (validationCommand) {
  6719. if (validationCommand.stem) {
  6720. state.hints += stackSize >> 1;
  6721. }
  6722. if ('min' in validationCommand) {
  6723. if (!state.undefStack && stackSize < validationCommand.min) {
  6724. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  6725. return false;
  6726. }
  6727. }
  6728. if (state.firstStackClearing && validationCommand.stackClearing) {
  6729. state.firstStackClearing = false;
  6730. stackSize -= validationCommand.min;
  6731. if (stackSize >= 2 && validationCommand.stem) {
  6732. stackSize %= 2;
  6733. } else if (stackSize > 1) {
  6734. warn('Found too many parameters for stack-clearing command');
  6735. }
  6736. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  6737. state.width = stack[stackSize - 1];
  6738. }
  6739. }
  6740. if ('stackDelta' in validationCommand) {
  6741. if ('stackFn' in validationCommand) {
  6742. validationCommand.stackFn(stack, stackSize);
  6743. }
  6744. stackSize += validationCommand.stackDelta;
  6745. } else if (validationCommand.stackClearing) {
  6746. stackSize = 0;
  6747. } else if (validationCommand.resetStack) {
  6748. stackSize = 0;
  6749. state.undefStack = false;
  6750. } else if (validationCommand.undefStack) {
  6751. stackSize = 0;
  6752. state.undefStack = true;
  6753. state.firstStackClearing = false;
  6754. }
  6755. }
  6756. }
  6757. state.stackSize = stackSize;
  6758. return true;
  6759. },
  6760. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  6761. var seacs = [];
  6762. var widths = [];
  6763. var count = charStrings.count;
  6764. for (var i = 0; i < count; i++) {
  6765. var charstring = charStrings.get(i);
  6766. var state = {
  6767. callDepth: 0,
  6768. stackSize: 0,
  6769. stack: [],
  6770. undefStack: true,
  6771. hints: 0,
  6772. firstStackClearing: true,
  6773. seac: null,
  6774. width: null
  6775. };
  6776. var valid = true;
  6777. var localSubrToUse = null;
  6778. if (fdSelect && fdArray.length) {
  6779. var fdIndex = fdSelect.getFDIndex(i);
  6780. if (fdIndex === -1) {
  6781. warn('Glyph index is not in fd select.');
  6782. valid = false;
  6783. }
  6784. if (fdIndex >= fdArray.length) {
  6785. warn('Invalid fd index for glyph index.');
  6786. valid = false;
  6787. }
  6788. if (valid) {
  6789. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  6790. }
  6791. } else if (localSubrIndex) {
  6792. localSubrToUse = localSubrIndex;
  6793. }
  6794. if (valid) {
  6795. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  6796. }
  6797. if (state.width !== null) {
  6798. widths[i] = state.width;
  6799. }
  6800. if (state.seac !== null) {
  6801. seacs[i] = state.seac;
  6802. }
  6803. if (!valid) {
  6804. charStrings.set(i, new Uint8Array([14]));
  6805. }
  6806. }
  6807. return {
  6808. charStrings: charStrings,
  6809. seacs: seacs,
  6810. widths: widths
  6811. };
  6812. },
  6813. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  6814. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  6815. parentDict.setByKey(18, [
  6816. 0,
  6817. 0
  6818. ]);
  6819. parentDict.privateDict = privateDict;
  6820. },
  6821. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  6822. if (!parentDict.hasName('Private')) {
  6823. this.emptyPrivateDictionary(parentDict);
  6824. return;
  6825. }
  6826. var privateOffset = parentDict.getByName('Private');
  6827. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  6828. parentDict.removeByName('Private');
  6829. return;
  6830. }
  6831. var size = privateOffset[0];
  6832. var offset = privateOffset[1];
  6833. if (size === 0 || offset >= this.bytes.length) {
  6834. this.emptyPrivateDictionary(parentDict);
  6835. return;
  6836. }
  6837. var privateDictEnd = offset + size;
  6838. var dictData = this.bytes.subarray(offset, privateDictEnd);
  6839. var dict = this.parseDict(dictData);
  6840. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  6841. parentDict.privateDict = privateDict;
  6842. if (!privateDict.getByName('Subrs')) {
  6843. return;
  6844. }
  6845. var subrsOffset = privateDict.getByName('Subrs');
  6846. var relativeOffset = offset + subrsOffset;
  6847. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  6848. this.emptyPrivateDictionary(parentDict);
  6849. return;
  6850. }
  6851. var subrsIndex = this.parseIndex(relativeOffset);
  6852. privateDict.subrsIndex = subrsIndex.obj;
  6853. },
  6854. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  6855. if (pos === 0) {
  6856. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  6857. } else if (pos === 1) {
  6858. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  6859. } else if (pos === 2) {
  6860. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  6861. }
  6862. var bytes = this.bytes;
  6863. var start = pos;
  6864. var format = bytes[pos++];
  6865. var charset = ['.notdef'];
  6866. var id, count, i;
  6867. length -= 1;
  6868. switch (format) {
  6869. case 0:
  6870. for (i = 0; i < length; i++) {
  6871. id = bytes[pos++] << 8 | bytes[pos++];
  6872. charset.push(cid ? id : strings.get(id));
  6873. }
  6874. break;
  6875. case 1:
  6876. while (charset.length <= length) {
  6877. id = bytes[pos++] << 8 | bytes[pos++];
  6878. count = bytes[pos++];
  6879. for (i = 0; i <= count; i++) {
  6880. charset.push(cid ? id++ : strings.get(id++));
  6881. }
  6882. }
  6883. break;
  6884. case 2:
  6885. while (charset.length <= length) {
  6886. id = bytes[pos++] << 8 | bytes[pos++];
  6887. count = bytes[pos++] << 8 | bytes[pos++];
  6888. for (i = 0; i <= count; i++) {
  6889. charset.push(cid ? id++ : strings.get(id++));
  6890. }
  6891. }
  6892. break;
  6893. default:
  6894. error('Unknown charset format');
  6895. }
  6896. var end = pos;
  6897. var raw = bytes.subarray(start, end);
  6898. return new CFFCharset(false, format, charset, raw);
  6899. },
  6900. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  6901. var encoding = Object.create(null);
  6902. var bytes = this.bytes;
  6903. var predefined = false;
  6904. var hasSupplement = false;
  6905. var format, i, ii;
  6906. var raw = null;
  6907. function readSupplement() {
  6908. var supplementsCount = bytes[pos++];
  6909. for (i = 0; i < supplementsCount; i++) {
  6910. var code = bytes[pos++];
  6911. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  6912. encoding[code] = charset.indexOf(strings.get(sid));
  6913. }
  6914. }
  6915. if (pos === 0 || pos === 1) {
  6916. predefined = true;
  6917. format = pos;
  6918. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  6919. for (i = 0, ii = charset.length; i < ii; i++) {
  6920. var index = baseEncoding.indexOf(charset[i]);
  6921. if (index !== -1) {
  6922. encoding[index] = i;
  6923. }
  6924. }
  6925. } else {
  6926. var dataStart = pos;
  6927. format = bytes[pos++];
  6928. switch (format & 0x7f) {
  6929. case 0:
  6930. var glyphsCount = bytes[pos++];
  6931. for (i = 1; i <= glyphsCount; i++) {
  6932. encoding[bytes[pos++]] = i;
  6933. }
  6934. break;
  6935. case 1:
  6936. var rangesCount = bytes[pos++];
  6937. var gid = 1;
  6938. for (i = 0; i < rangesCount; i++) {
  6939. var start = bytes[pos++];
  6940. var left = bytes[pos++];
  6941. for (var j = start; j <= start + left; j++) {
  6942. encoding[j] = gid++;
  6943. }
  6944. }
  6945. break;
  6946. default:
  6947. error('Unknown encoding format: ' + format + ' in CFF');
  6948. break;
  6949. }
  6950. var dataEnd = pos;
  6951. if (format & 0x80) {
  6952. bytes[dataStart] &= 0x7f;
  6953. readSupplement();
  6954. hasSupplement = true;
  6955. }
  6956. raw = bytes.subarray(dataStart, dataEnd);
  6957. }
  6958. format = format & 0x7f;
  6959. return new CFFEncoding(predefined, format, encoding, raw);
  6960. },
  6961. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  6962. var start = pos;
  6963. var bytes = this.bytes;
  6964. var format = bytes[pos++];
  6965. var fdSelect = [], rawBytes;
  6966. var i, invalidFirstGID = false;
  6967. switch (format) {
  6968. case 0:
  6969. for (i = 0; i < length; ++i) {
  6970. var id = bytes[pos++];
  6971. fdSelect.push(id);
  6972. }
  6973. rawBytes = bytes.subarray(start, pos);
  6974. break;
  6975. case 3:
  6976. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  6977. for (i = 0; i < rangesCount; ++i) {
  6978. var first = bytes[pos++] << 8 | bytes[pos++];
  6979. if (i === 0 && first !== 0) {
  6980. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  6981. invalidFirstGID = true;
  6982. first = 0;
  6983. }
  6984. var fdIndex = bytes[pos++];
  6985. var next = bytes[pos] << 8 | bytes[pos + 1];
  6986. for (var j = first; j < next; ++j) {
  6987. fdSelect.push(fdIndex);
  6988. }
  6989. }
  6990. pos += 2;
  6991. rawBytes = bytes.subarray(start, pos);
  6992. if (invalidFirstGID) {
  6993. rawBytes[3] = rawBytes[4] = 0;
  6994. }
  6995. break;
  6996. default:
  6997. error('parseFDSelect: Unknown format "' + format + '".');
  6998. break;
  6999. }
  7000. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  7001. return new CFFFDSelect(fdSelect, rawBytes);
  7002. }
  7003. };
  7004. return CFFParser;
  7005. }();
  7006. var CFF = function CFFClosure() {
  7007. function CFF() {
  7008. this.header = null;
  7009. this.names = [];
  7010. this.topDict = null;
  7011. this.strings = new CFFStrings();
  7012. this.globalSubrIndex = null;
  7013. this.encoding = null;
  7014. this.charset = null;
  7015. this.charStrings = null;
  7016. this.fdArray = [];
  7017. this.fdSelect = null;
  7018. this.isCIDFont = false;
  7019. }
  7020. return CFF;
  7021. }();
  7022. var CFFHeader = function CFFHeaderClosure() {
  7023. function CFFHeader(major, minor, hdrSize, offSize) {
  7024. this.major = major;
  7025. this.minor = minor;
  7026. this.hdrSize = hdrSize;
  7027. this.offSize = offSize;
  7028. }
  7029. return CFFHeader;
  7030. }();
  7031. var CFFStrings = function CFFStringsClosure() {
  7032. function CFFStrings() {
  7033. this.strings = [];
  7034. }
  7035. CFFStrings.prototype = {
  7036. get: function CFFStrings_get(index) {
  7037. if (index >= 0 && index <= 390) {
  7038. return CFFStandardStrings[index];
  7039. }
  7040. if (index - 391 <= this.strings.length) {
  7041. return this.strings[index - 391];
  7042. }
  7043. return CFFStandardStrings[0];
  7044. },
  7045. add: function CFFStrings_add(value) {
  7046. this.strings.push(value);
  7047. },
  7048. get count() {
  7049. return this.strings.length;
  7050. }
  7051. };
  7052. return CFFStrings;
  7053. }();
  7054. var CFFIndex = function CFFIndexClosure() {
  7055. function CFFIndex() {
  7056. this.objects = [];
  7057. this.length = 0;
  7058. }
  7059. CFFIndex.prototype = {
  7060. add: function CFFIndex_add(data) {
  7061. this.length += data.length;
  7062. this.objects.push(data);
  7063. },
  7064. set: function CFFIndex_set(index, data) {
  7065. this.length += data.length - this.objects[index].length;
  7066. this.objects[index] = data;
  7067. },
  7068. get: function CFFIndex_get(index) {
  7069. return this.objects[index];
  7070. },
  7071. get count() {
  7072. return this.objects.length;
  7073. }
  7074. };
  7075. return CFFIndex;
  7076. }();
  7077. var CFFDict = function CFFDictClosure() {
  7078. function CFFDict(tables, strings) {
  7079. this.keyToNameMap = tables.keyToNameMap;
  7080. this.nameToKeyMap = tables.nameToKeyMap;
  7081. this.defaults = tables.defaults;
  7082. this.types = tables.types;
  7083. this.opcodes = tables.opcodes;
  7084. this.order = tables.order;
  7085. this.strings = strings;
  7086. this.values = Object.create(null);
  7087. }
  7088. CFFDict.prototype = {
  7089. setByKey: function CFFDict_setByKey(key, value) {
  7090. if (!(key in this.keyToNameMap)) {
  7091. return false;
  7092. }
  7093. var valueLength = value.length;
  7094. if (valueLength === 0) {
  7095. return true;
  7096. }
  7097. for (var i = 0; i < valueLength; i++) {
  7098. if (isNaN(value[i])) {
  7099. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  7100. return true;
  7101. }
  7102. }
  7103. var type = this.types[key];
  7104. if (type === 'num' || type === 'sid' || type === 'offset') {
  7105. value = value[0];
  7106. }
  7107. this.values[key] = value;
  7108. return true;
  7109. },
  7110. setByName: function CFFDict_setByName(name, value) {
  7111. if (!(name in this.nameToKeyMap)) {
  7112. error('Invalid dictionary name "' + name + '"');
  7113. }
  7114. this.values[this.nameToKeyMap[name]] = value;
  7115. },
  7116. hasName: function CFFDict_hasName(name) {
  7117. return this.nameToKeyMap[name] in this.values;
  7118. },
  7119. getByName: function CFFDict_getByName(name) {
  7120. if (!(name in this.nameToKeyMap)) {
  7121. error('Invalid dictionary name "' + name + '"');
  7122. }
  7123. var key = this.nameToKeyMap[name];
  7124. if (!(key in this.values)) {
  7125. return this.defaults[key];
  7126. }
  7127. return this.values[key];
  7128. },
  7129. removeByName: function CFFDict_removeByName(name) {
  7130. delete this.values[this.nameToKeyMap[name]];
  7131. }
  7132. };
  7133. CFFDict.createTables = function CFFDict_createTables(layout) {
  7134. var tables = {
  7135. keyToNameMap: {},
  7136. nameToKeyMap: {},
  7137. defaults: {},
  7138. types: {},
  7139. opcodes: {},
  7140. order: []
  7141. };
  7142. for (var i = 0, ii = layout.length; i < ii; ++i) {
  7143. var entry = layout[i];
  7144. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  7145. tables.keyToNameMap[key] = entry[1];
  7146. tables.nameToKeyMap[entry[1]] = key;
  7147. tables.types[key] = entry[2];
  7148. tables.defaults[key] = entry[3];
  7149. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  7150. tables.order.push(key);
  7151. }
  7152. return tables;
  7153. };
  7154. return CFFDict;
  7155. }();
  7156. var CFFTopDict = function CFFTopDictClosure() {
  7157. var layout = [
  7158. [
  7159. [
  7160. 12,
  7161. 30
  7162. ],
  7163. 'ROS',
  7164. [
  7165. 'sid',
  7166. 'sid',
  7167. 'num'
  7168. ],
  7169. null
  7170. ],
  7171. [
  7172. [
  7173. 12,
  7174. 20
  7175. ],
  7176. 'SyntheticBase',
  7177. 'num',
  7178. null
  7179. ],
  7180. [
  7181. 0,
  7182. 'version',
  7183. 'sid',
  7184. null
  7185. ],
  7186. [
  7187. 1,
  7188. 'Notice',
  7189. 'sid',
  7190. null
  7191. ],
  7192. [
  7193. [
  7194. 12,
  7195. 0
  7196. ],
  7197. 'Copyright',
  7198. 'sid',
  7199. null
  7200. ],
  7201. [
  7202. 2,
  7203. 'FullName',
  7204. 'sid',
  7205. null
  7206. ],
  7207. [
  7208. 3,
  7209. 'FamilyName',
  7210. 'sid',
  7211. null
  7212. ],
  7213. [
  7214. 4,
  7215. 'Weight',
  7216. 'sid',
  7217. null
  7218. ],
  7219. [
  7220. [
  7221. 12,
  7222. 1
  7223. ],
  7224. 'isFixedPitch',
  7225. 'num',
  7226. 0
  7227. ],
  7228. [
  7229. [
  7230. 12,
  7231. 2
  7232. ],
  7233. 'ItalicAngle',
  7234. 'num',
  7235. 0
  7236. ],
  7237. [
  7238. [
  7239. 12,
  7240. 3
  7241. ],
  7242. 'UnderlinePosition',
  7243. 'num',
  7244. -100
  7245. ],
  7246. [
  7247. [
  7248. 12,
  7249. 4
  7250. ],
  7251. 'UnderlineThickness',
  7252. 'num',
  7253. 50
  7254. ],
  7255. [
  7256. [
  7257. 12,
  7258. 5
  7259. ],
  7260. 'PaintType',
  7261. 'num',
  7262. 0
  7263. ],
  7264. [
  7265. [
  7266. 12,
  7267. 6
  7268. ],
  7269. 'CharstringType',
  7270. 'num',
  7271. 2
  7272. ],
  7273. [
  7274. [
  7275. 12,
  7276. 7
  7277. ],
  7278. 'FontMatrix',
  7279. [
  7280. 'num',
  7281. 'num',
  7282. 'num',
  7283. 'num',
  7284. 'num',
  7285. 'num'
  7286. ],
  7287. [
  7288. 0.001,
  7289. 0,
  7290. 0,
  7291. 0.001,
  7292. 0,
  7293. 0
  7294. ]
  7295. ],
  7296. [
  7297. 13,
  7298. 'UniqueID',
  7299. 'num',
  7300. null
  7301. ],
  7302. [
  7303. 5,
  7304. 'FontBBox',
  7305. [
  7306. 'num',
  7307. 'num',
  7308. 'num',
  7309. 'num'
  7310. ],
  7311. [
  7312. 0,
  7313. 0,
  7314. 0,
  7315. 0
  7316. ]
  7317. ],
  7318. [
  7319. [
  7320. 12,
  7321. 8
  7322. ],
  7323. 'StrokeWidth',
  7324. 'num',
  7325. 0
  7326. ],
  7327. [
  7328. 14,
  7329. 'XUID',
  7330. 'array',
  7331. null
  7332. ],
  7333. [
  7334. 15,
  7335. 'charset',
  7336. 'offset',
  7337. 0
  7338. ],
  7339. [
  7340. 16,
  7341. 'Encoding',
  7342. 'offset',
  7343. 0
  7344. ],
  7345. [
  7346. 17,
  7347. 'CharStrings',
  7348. 'offset',
  7349. 0
  7350. ],
  7351. [
  7352. 18,
  7353. 'Private',
  7354. [
  7355. 'offset',
  7356. 'offset'
  7357. ],
  7358. null
  7359. ],
  7360. [
  7361. [
  7362. 12,
  7363. 21
  7364. ],
  7365. 'PostScript',
  7366. 'sid',
  7367. null
  7368. ],
  7369. [
  7370. [
  7371. 12,
  7372. 22
  7373. ],
  7374. 'BaseFontName',
  7375. 'sid',
  7376. null
  7377. ],
  7378. [
  7379. [
  7380. 12,
  7381. 23
  7382. ],
  7383. 'BaseFontBlend',
  7384. 'delta',
  7385. null
  7386. ],
  7387. [
  7388. [
  7389. 12,
  7390. 31
  7391. ],
  7392. 'CIDFontVersion',
  7393. 'num',
  7394. 0
  7395. ],
  7396. [
  7397. [
  7398. 12,
  7399. 32
  7400. ],
  7401. 'CIDFontRevision',
  7402. 'num',
  7403. 0
  7404. ],
  7405. [
  7406. [
  7407. 12,
  7408. 33
  7409. ],
  7410. 'CIDFontType',
  7411. 'num',
  7412. 0
  7413. ],
  7414. [
  7415. [
  7416. 12,
  7417. 34
  7418. ],
  7419. 'CIDCount',
  7420. 'num',
  7421. 8720
  7422. ],
  7423. [
  7424. [
  7425. 12,
  7426. 35
  7427. ],
  7428. 'UIDBase',
  7429. 'num',
  7430. null
  7431. ],
  7432. [
  7433. [
  7434. 12,
  7435. 37
  7436. ],
  7437. 'FDSelect',
  7438. 'offset',
  7439. null
  7440. ],
  7441. [
  7442. [
  7443. 12,
  7444. 36
  7445. ],
  7446. 'FDArray',
  7447. 'offset',
  7448. null
  7449. ],
  7450. [
  7451. [
  7452. 12,
  7453. 38
  7454. ],
  7455. 'FontName',
  7456. 'sid',
  7457. null
  7458. ]
  7459. ];
  7460. var tables = null;
  7461. function CFFTopDict(strings) {
  7462. if (tables === null) {
  7463. tables = CFFDict.createTables(layout);
  7464. }
  7465. CFFDict.call(this, tables, strings);
  7466. this.privateDict = null;
  7467. }
  7468. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  7469. return CFFTopDict;
  7470. }();
  7471. var CFFPrivateDict = function CFFPrivateDictClosure() {
  7472. var layout = [
  7473. [
  7474. 6,
  7475. 'BlueValues',
  7476. 'delta',
  7477. null
  7478. ],
  7479. [
  7480. 7,
  7481. 'OtherBlues',
  7482. 'delta',
  7483. null
  7484. ],
  7485. [
  7486. 8,
  7487. 'FamilyBlues',
  7488. 'delta',
  7489. null
  7490. ],
  7491. [
  7492. 9,
  7493. 'FamilyOtherBlues',
  7494. 'delta',
  7495. null
  7496. ],
  7497. [
  7498. [
  7499. 12,
  7500. 9
  7501. ],
  7502. 'BlueScale',
  7503. 'num',
  7504. 0.039625
  7505. ],
  7506. [
  7507. [
  7508. 12,
  7509. 10
  7510. ],
  7511. 'BlueShift',
  7512. 'num',
  7513. 7
  7514. ],
  7515. [
  7516. [
  7517. 12,
  7518. 11
  7519. ],
  7520. 'BlueFuzz',
  7521. 'num',
  7522. 1
  7523. ],
  7524. [
  7525. 10,
  7526. 'StdHW',
  7527. 'num',
  7528. null
  7529. ],
  7530. [
  7531. 11,
  7532. 'StdVW',
  7533. 'num',
  7534. null
  7535. ],
  7536. [
  7537. [
  7538. 12,
  7539. 12
  7540. ],
  7541. 'StemSnapH',
  7542. 'delta',
  7543. null
  7544. ],
  7545. [
  7546. [
  7547. 12,
  7548. 13
  7549. ],
  7550. 'StemSnapV',
  7551. 'delta',
  7552. null
  7553. ],
  7554. [
  7555. [
  7556. 12,
  7557. 14
  7558. ],
  7559. 'ForceBold',
  7560. 'num',
  7561. 0
  7562. ],
  7563. [
  7564. [
  7565. 12,
  7566. 17
  7567. ],
  7568. 'LanguageGroup',
  7569. 'num',
  7570. 0
  7571. ],
  7572. [
  7573. [
  7574. 12,
  7575. 18
  7576. ],
  7577. 'ExpansionFactor',
  7578. 'num',
  7579. 0.06
  7580. ],
  7581. [
  7582. [
  7583. 12,
  7584. 19
  7585. ],
  7586. 'initialRandomSeed',
  7587. 'num',
  7588. 0
  7589. ],
  7590. [
  7591. 20,
  7592. 'defaultWidthX',
  7593. 'num',
  7594. 0
  7595. ],
  7596. [
  7597. 21,
  7598. 'nominalWidthX',
  7599. 'num',
  7600. 0
  7601. ],
  7602. [
  7603. 19,
  7604. 'Subrs',
  7605. 'offset',
  7606. null
  7607. ]
  7608. ];
  7609. var tables = null;
  7610. function CFFPrivateDict(strings) {
  7611. if (tables === null) {
  7612. tables = CFFDict.createTables(layout);
  7613. }
  7614. CFFDict.call(this, tables, strings);
  7615. this.subrsIndex = null;
  7616. }
  7617. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  7618. return CFFPrivateDict;
  7619. }();
  7620. var CFFCharsetPredefinedTypes = {
  7621. ISO_ADOBE: 0,
  7622. EXPERT: 1,
  7623. EXPERT_SUBSET: 2
  7624. };
  7625. var CFFCharset = function CFFCharsetClosure() {
  7626. function CFFCharset(predefined, format, charset, raw) {
  7627. this.predefined = predefined;
  7628. this.format = format;
  7629. this.charset = charset;
  7630. this.raw = raw;
  7631. }
  7632. return CFFCharset;
  7633. }();
  7634. var CFFEncoding = function CFFEncodingClosure() {
  7635. function CFFEncoding(predefined, format, encoding, raw) {
  7636. this.predefined = predefined;
  7637. this.format = format;
  7638. this.encoding = encoding;
  7639. this.raw = raw;
  7640. }
  7641. return CFFEncoding;
  7642. }();
  7643. var CFFFDSelect = function CFFFDSelectClosure() {
  7644. function CFFFDSelect(fdSelect, raw) {
  7645. this.fdSelect = fdSelect;
  7646. this.raw = raw;
  7647. }
  7648. CFFFDSelect.prototype = {
  7649. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  7650. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  7651. return -1;
  7652. }
  7653. return this.fdSelect[glyphIndex];
  7654. }
  7655. };
  7656. return CFFFDSelect;
  7657. }();
  7658. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  7659. function CFFOffsetTracker() {
  7660. this.offsets = Object.create(null);
  7661. }
  7662. CFFOffsetTracker.prototype = {
  7663. isTracking: function CFFOffsetTracker_isTracking(key) {
  7664. return key in this.offsets;
  7665. },
  7666. track: function CFFOffsetTracker_track(key, location) {
  7667. if (key in this.offsets) {
  7668. error('Already tracking location of ' + key);
  7669. }
  7670. this.offsets[key] = location;
  7671. },
  7672. offset: function CFFOffsetTracker_offset(value) {
  7673. for (var key in this.offsets) {
  7674. this.offsets[key] += value;
  7675. }
  7676. },
  7677. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  7678. if (!(key in this.offsets)) {
  7679. error('Not tracking location of ' + key);
  7680. }
  7681. var data = output.data;
  7682. var dataOffset = this.offsets[key];
  7683. var size = 5;
  7684. for (var i = 0, ii = values.length; i < ii; ++i) {
  7685. var offset0 = i * size + dataOffset;
  7686. var offset1 = offset0 + 1;
  7687. var offset2 = offset0 + 2;
  7688. var offset3 = offset0 + 3;
  7689. var offset4 = offset0 + 4;
  7690. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  7691. error('writing to an offset that is not empty');
  7692. }
  7693. var value = values[i];
  7694. data[offset0] = 0x1d;
  7695. data[offset1] = value >> 24 & 0xFF;
  7696. data[offset2] = value >> 16 & 0xFF;
  7697. data[offset3] = value >> 8 & 0xFF;
  7698. data[offset4] = value & 0xFF;
  7699. }
  7700. }
  7701. };
  7702. return CFFOffsetTracker;
  7703. }();
  7704. var CFFCompiler = function CFFCompilerClosure() {
  7705. function CFFCompiler(cff) {
  7706. this.cff = cff;
  7707. }
  7708. CFFCompiler.prototype = {
  7709. compile: function CFFCompiler_compile() {
  7710. var cff = this.cff;
  7711. var output = {
  7712. data: [],
  7713. length: 0,
  7714. add: function CFFCompiler_add(data) {
  7715. this.data = this.data.concat(data);
  7716. this.length = this.data.length;
  7717. }
  7718. };
  7719. var header = this.compileHeader(cff.header);
  7720. output.add(header);
  7721. var nameIndex = this.compileNameIndex(cff.names);
  7722. output.add(nameIndex);
  7723. if (cff.isCIDFont) {
  7724. if (cff.topDict.hasName('FontMatrix')) {
  7725. var base = cff.topDict.getByName('FontMatrix');
  7726. cff.topDict.removeByName('FontMatrix');
  7727. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  7728. var subDict = cff.fdArray[i];
  7729. var matrix = base.slice(0);
  7730. if (subDict.hasName('FontMatrix')) {
  7731. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  7732. }
  7733. subDict.setByName('FontMatrix', matrix);
  7734. }
  7735. }
  7736. }
  7737. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  7738. output.add(compiled.output);
  7739. var topDictTracker = compiled.trackers[0];
  7740. var stringIndex = this.compileStringIndex(cff.strings.strings);
  7741. output.add(stringIndex);
  7742. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  7743. output.add(globalSubrIndex);
  7744. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  7745. if (cff.encoding.predefined) {
  7746. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  7747. } else {
  7748. var encoding = this.compileEncoding(cff.encoding);
  7749. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  7750. output.add(encoding);
  7751. }
  7752. }
  7753. if (cff.charset && cff.topDict.hasName('charset')) {
  7754. if (cff.charset.predefined) {
  7755. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  7756. } else {
  7757. var charset = this.compileCharset(cff.charset);
  7758. topDictTracker.setEntryLocation('charset', [output.length], output);
  7759. output.add(charset);
  7760. }
  7761. }
  7762. var charStrings = this.compileCharStrings(cff.charStrings);
  7763. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  7764. output.add(charStrings);
  7765. if (cff.isCIDFont) {
  7766. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  7767. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  7768. output.add(fdSelect);
  7769. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  7770. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  7771. output.add(compiled.output);
  7772. var fontDictTrackers = compiled.trackers;
  7773. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  7774. }
  7775. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  7776. output.add([0]);
  7777. return output.data;
  7778. },
  7779. encodeNumber: function CFFCompiler_encodeNumber(value) {
  7780. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  7781. return this.encodeInteger(value);
  7782. }
  7783. return this.encodeFloat(value);
  7784. },
  7785. encodeFloat: function CFFCompiler_encodeFloat(num) {
  7786. var value = num.toString();
  7787. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  7788. if (m) {
  7789. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  7790. value = (Math.round(num * epsilon) / epsilon).toString();
  7791. }
  7792. var nibbles = '';
  7793. var i, ii;
  7794. for (i = 0, ii = value.length; i < ii; ++i) {
  7795. var a = value[i];
  7796. if (a === 'e') {
  7797. nibbles += value[++i] === '-' ? 'c' : 'b';
  7798. } else if (a === '.') {
  7799. nibbles += 'a';
  7800. } else if (a === '-') {
  7801. nibbles += 'e';
  7802. } else {
  7803. nibbles += a;
  7804. }
  7805. }
  7806. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  7807. var out = [30];
  7808. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  7809. out.push(parseInt(nibbles.substr(i, 2), 16));
  7810. }
  7811. return out;
  7812. },
  7813. encodeInteger: function CFFCompiler_encodeInteger(value) {
  7814. var code;
  7815. if (value >= -107 && value <= 107) {
  7816. code = [value + 139];
  7817. } else if (value >= 108 && value <= 1131) {
  7818. value = value - 108;
  7819. code = [
  7820. (value >> 8) + 247,
  7821. value & 0xFF
  7822. ];
  7823. } else if (value >= -1131 && value <= -108) {
  7824. value = -value - 108;
  7825. code = [
  7826. (value >> 8) + 251,
  7827. value & 0xFF
  7828. ];
  7829. } else if (value >= -32768 && value <= 32767) {
  7830. code = [
  7831. 0x1c,
  7832. value >> 8 & 0xFF,
  7833. value & 0xFF
  7834. ];
  7835. } else {
  7836. code = [
  7837. 0x1d,
  7838. value >> 24 & 0xFF,
  7839. value >> 16 & 0xFF,
  7840. value >> 8 & 0xFF,
  7841. value & 0xFF
  7842. ];
  7843. }
  7844. return code;
  7845. },
  7846. compileHeader: function CFFCompiler_compileHeader(header) {
  7847. return [
  7848. header.major,
  7849. header.minor,
  7850. header.hdrSize,
  7851. header.offSize
  7852. ];
  7853. },
  7854. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  7855. var nameIndex = new CFFIndex();
  7856. for (var i = 0, ii = names.length; i < ii; ++i) {
  7857. nameIndex.add(stringToBytes(names[i]));
  7858. }
  7859. return this.compileIndex(nameIndex);
  7860. },
  7861. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  7862. var fontDictTrackers = [];
  7863. var fdArrayIndex = new CFFIndex();
  7864. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7865. var fontDict = dicts[i];
  7866. if (removeCidKeys) {
  7867. fontDict.removeByName('CIDFontVersion');
  7868. fontDict.removeByName('CIDFontRevision');
  7869. fontDict.removeByName('CIDFontType');
  7870. fontDict.removeByName('CIDCount');
  7871. fontDict.removeByName('UIDBase');
  7872. }
  7873. var fontDictTracker = new CFFOffsetTracker();
  7874. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  7875. fontDictTrackers.push(fontDictTracker);
  7876. fdArrayIndex.add(fontDictData);
  7877. fontDictTracker.offset(length);
  7878. }
  7879. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  7880. return {
  7881. trackers: fontDictTrackers,
  7882. output: fdArrayIndex
  7883. };
  7884. },
  7885. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  7886. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7887. var fontDict = dicts[i];
  7888. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  7889. var privateDict = fontDict.privateDict;
  7890. var privateDictTracker = new CFFOffsetTracker();
  7891. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  7892. var outputLength = output.length;
  7893. privateDictTracker.offset(outputLength);
  7894. if (!privateDictData.length) {
  7895. outputLength = 0;
  7896. }
  7897. trackers[i].setEntryLocation('Private', [
  7898. privateDictData.length,
  7899. outputLength
  7900. ], output);
  7901. output.add(privateDictData);
  7902. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  7903. var subrs = this.compileIndex(privateDict.subrsIndex);
  7904. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  7905. output.add(subrs);
  7906. }
  7907. }
  7908. },
  7909. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  7910. var out = [];
  7911. var order = dict.order;
  7912. for (var i = 0; i < order.length; ++i) {
  7913. var key = order[i];
  7914. if (!(key in dict.values)) {
  7915. continue;
  7916. }
  7917. var values = dict.values[key];
  7918. var types = dict.types[key];
  7919. if (!isArray(types)) {
  7920. types = [types];
  7921. }
  7922. if (!isArray(values)) {
  7923. values = [values];
  7924. }
  7925. if (values.length === 0) {
  7926. continue;
  7927. }
  7928. for (var j = 0, jj = types.length; j < jj; ++j) {
  7929. var type = types[j];
  7930. var value = values[j];
  7931. switch (type) {
  7932. case 'num':
  7933. case 'sid':
  7934. out = out.concat(this.encodeNumber(value));
  7935. break;
  7936. case 'offset':
  7937. var name = dict.keyToNameMap[key];
  7938. if (!offsetTracker.isTracking(name)) {
  7939. offsetTracker.track(name, out.length);
  7940. }
  7941. out = out.concat([
  7942. 0x1d,
  7943. 0,
  7944. 0,
  7945. 0,
  7946. 0
  7947. ]);
  7948. break;
  7949. case 'array':
  7950. case 'delta':
  7951. out = out.concat(this.encodeNumber(value));
  7952. for (var k = 1, kk = values.length; k < kk; ++k) {
  7953. out = out.concat(this.encodeNumber(values[k]));
  7954. }
  7955. break;
  7956. default:
  7957. error('Unknown data type of ' + type);
  7958. break;
  7959. }
  7960. }
  7961. out = out.concat(dict.opcodes[key]);
  7962. }
  7963. return out;
  7964. },
  7965. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  7966. var stringIndex = new CFFIndex();
  7967. for (var i = 0, ii = strings.length; i < ii; ++i) {
  7968. stringIndex.add(stringToBytes(strings[i]));
  7969. }
  7970. return this.compileIndex(stringIndex);
  7971. },
  7972. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  7973. var globalSubrIndex = this.cff.globalSubrIndex;
  7974. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  7975. },
  7976. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  7977. return this.compileIndex(charStrings);
  7978. },
  7979. compileCharset: function CFFCompiler_compileCharset(charset) {
  7980. return this.compileTypedArray(charset.raw);
  7981. },
  7982. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  7983. return this.compileTypedArray(encoding.raw);
  7984. },
  7985. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  7986. return this.compileTypedArray(fdSelect);
  7987. },
  7988. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  7989. var out = [];
  7990. for (var i = 0, ii = data.length; i < ii; ++i) {
  7991. out[i] = data[i];
  7992. }
  7993. return out;
  7994. },
  7995. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  7996. trackers = trackers || [];
  7997. var objects = index.objects;
  7998. var count = objects.length;
  7999. if (count === 0) {
  8000. return [
  8001. 0,
  8002. 0,
  8003. 0
  8004. ];
  8005. }
  8006. var data = [
  8007. count >> 8 & 0xFF,
  8008. count & 0xff
  8009. ];
  8010. var lastOffset = 1, i;
  8011. for (i = 0; i < count; ++i) {
  8012. lastOffset += objects[i].length;
  8013. }
  8014. var offsetSize;
  8015. if (lastOffset < 0x100) {
  8016. offsetSize = 1;
  8017. } else if (lastOffset < 0x10000) {
  8018. offsetSize = 2;
  8019. } else if (lastOffset < 0x1000000) {
  8020. offsetSize = 3;
  8021. } else {
  8022. offsetSize = 4;
  8023. }
  8024. data.push(offsetSize);
  8025. var relativeOffset = 1;
  8026. for (i = 0; i < count + 1; i++) {
  8027. if (offsetSize === 1) {
  8028. data.push(relativeOffset & 0xFF);
  8029. } else if (offsetSize === 2) {
  8030. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8031. } else if (offsetSize === 3) {
  8032. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8033. } else {
  8034. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8035. }
  8036. if (objects[i]) {
  8037. relativeOffset += objects[i].length;
  8038. }
  8039. }
  8040. for (i = 0; i < count; i++) {
  8041. if (trackers[i]) {
  8042. trackers[i].offset(data.length);
  8043. }
  8044. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  8045. data.push(objects[i][j]);
  8046. }
  8047. }
  8048. return data;
  8049. }
  8050. };
  8051. return CFFCompiler;
  8052. }();
  8053. exports.CFFStandardStrings = CFFStandardStrings;
  8054. exports.CFFParser = CFFParser;
  8055. exports.CFF = CFF;
  8056. exports.CFFHeader = CFFHeader;
  8057. exports.CFFStrings = CFFStrings;
  8058. exports.CFFIndex = CFFIndex;
  8059. exports.CFFCharset = CFFCharset;
  8060. exports.CFFTopDict = CFFTopDict;
  8061. exports.CFFPrivateDict = CFFPrivateDict;
  8062. exports.CFFCompiler = CFFCompiler;
  8063. }));
  8064. (function (root, factory) {
  8065. factory(root.pdfjsCoreChunkedStream = {}, root.pdfjsSharedUtil);
  8066. }(this, function (exports, sharedUtil) {
  8067. var MissingDataException = sharedUtil.MissingDataException;
  8068. var arrayByteLength = sharedUtil.arrayByteLength;
  8069. var arraysToBytes = sharedUtil.arraysToBytes;
  8070. var assert = sharedUtil.assert;
  8071. var createPromiseCapability = sharedUtil.createPromiseCapability;
  8072. var isInt = sharedUtil.isInt;
  8073. var isEmptyObj = sharedUtil.isEmptyObj;
  8074. var ChunkedStream = function ChunkedStreamClosure() {
  8075. function ChunkedStream(length, chunkSize, manager) {
  8076. this.bytes = new Uint8Array(length);
  8077. this.start = 0;
  8078. this.pos = 0;
  8079. this.end = length;
  8080. this.chunkSize = chunkSize;
  8081. this.loadedChunks = [];
  8082. this.numChunksLoaded = 0;
  8083. this.numChunks = Math.ceil(length / chunkSize);
  8084. this.manager = manager;
  8085. this.progressiveDataLength = 0;
  8086. this.lastSuccessfulEnsureByteChunk = -1;
  8087. }
  8088. ChunkedStream.prototype = {
  8089. getMissingChunks: function ChunkedStream_getMissingChunks() {
  8090. var chunks = [];
  8091. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  8092. if (!this.loadedChunks[chunk]) {
  8093. chunks.push(chunk);
  8094. }
  8095. }
  8096. return chunks;
  8097. },
  8098. getBaseStreams: function ChunkedStream_getBaseStreams() {
  8099. return [this];
  8100. },
  8101. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  8102. return this.numChunksLoaded === this.numChunks;
  8103. },
  8104. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  8105. var end = begin + chunk.byteLength;
  8106. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  8107. var length = this.bytes.length;
  8108. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  8109. this.bytes.set(new Uint8Array(chunk), begin);
  8110. var chunkSize = this.chunkSize;
  8111. var beginChunk = Math.floor(begin / chunkSize);
  8112. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8113. var curChunk;
  8114. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8115. if (!this.loadedChunks[curChunk]) {
  8116. this.loadedChunks[curChunk] = true;
  8117. ++this.numChunksLoaded;
  8118. }
  8119. }
  8120. },
  8121. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  8122. var position = this.progressiveDataLength;
  8123. var beginChunk = Math.floor(position / this.chunkSize);
  8124. this.bytes.set(new Uint8Array(data), position);
  8125. position += data.byteLength;
  8126. this.progressiveDataLength = position;
  8127. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  8128. var curChunk;
  8129. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8130. if (!this.loadedChunks[curChunk]) {
  8131. this.loadedChunks[curChunk] = true;
  8132. ++this.numChunksLoaded;
  8133. }
  8134. }
  8135. },
  8136. ensureByte: function ChunkedStream_ensureByte(pos) {
  8137. var chunk = Math.floor(pos / this.chunkSize);
  8138. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  8139. return;
  8140. }
  8141. if (!this.loadedChunks[chunk]) {
  8142. throw new MissingDataException(pos, pos + 1);
  8143. }
  8144. this.lastSuccessfulEnsureByteChunk = chunk;
  8145. },
  8146. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  8147. if (begin >= end) {
  8148. return;
  8149. }
  8150. if (end <= this.progressiveDataLength) {
  8151. return;
  8152. }
  8153. var chunkSize = this.chunkSize;
  8154. var beginChunk = Math.floor(begin / chunkSize);
  8155. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8156. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8157. if (!this.loadedChunks[chunk]) {
  8158. throw new MissingDataException(begin, end);
  8159. }
  8160. }
  8161. },
  8162. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  8163. var chunk, numChunks = this.numChunks;
  8164. for (var i = 0; i < numChunks; ++i) {
  8165. chunk = (beginChunk + i) % numChunks;
  8166. if (!this.loadedChunks[chunk]) {
  8167. return chunk;
  8168. }
  8169. }
  8170. return null;
  8171. },
  8172. hasChunk: function ChunkedStream_hasChunk(chunk) {
  8173. return !!this.loadedChunks[chunk];
  8174. },
  8175. get length() {
  8176. return this.end - this.start;
  8177. },
  8178. get isEmpty() {
  8179. return this.length === 0;
  8180. },
  8181. getByte: function ChunkedStream_getByte() {
  8182. var pos = this.pos;
  8183. if (pos >= this.end) {
  8184. return -1;
  8185. }
  8186. this.ensureByte(pos);
  8187. return this.bytes[this.pos++];
  8188. },
  8189. getUint16: function ChunkedStream_getUint16() {
  8190. var b0 = this.getByte();
  8191. var b1 = this.getByte();
  8192. if (b0 === -1 || b1 === -1) {
  8193. return -1;
  8194. }
  8195. return (b0 << 8) + b1;
  8196. },
  8197. getInt32: function ChunkedStream_getInt32() {
  8198. var b0 = this.getByte();
  8199. var b1 = this.getByte();
  8200. var b2 = this.getByte();
  8201. var b3 = this.getByte();
  8202. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  8203. },
  8204. getBytes: function ChunkedStream_getBytes(length) {
  8205. var bytes = this.bytes;
  8206. var pos = this.pos;
  8207. var strEnd = this.end;
  8208. if (!length) {
  8209. this.ensureRange(pos, strEnd);
  8210. return bytes.subarray(pos, strEnd);
  8211. }
  8212. var end = pos + length;
  8213. if (end > strEnd) {
  8214. end = strEnd;
  8215. }
  8216. this.ensureRange(pos, end);
  8217. this.pos = end;
  8218. return bytes.subarray(pos, end);
  8219. },
  8220. peekByte: function ChunkedStream_peekByte() {
  8221. var peekedByte = this.getByte();
  8222. this.pos--;
  8223. return peekedByte;
  8224. },
  8225. peekBytes: function ChunkedStream_peekBytes(length) {
  8226. var bytes = this.getBytes(length);
  8227. this.pos -= bytes.length;
  8228. return bytes;
  8229. },
  8230. getByteRange: function ChunkedStream_getBytes(begin, end) {
  8231. this.ensureRange(begin, end);
  8232. return this.bytes.subarray(begin, end);
  8233. },
  8234. skip: function ChunkedStream_skip(n) {
  8235. if (!n) {
  8236. n = 1;
  8237. }
  8238. this.pos += n;
  8239. },
  8240. reset: function ChunkedStream_reset() {
  8241. this.pos = this.start;
  8242. },
  8243. moveStart: function ChunkedStream_moveStart() {
  8244. this.start = this.pos;
  8245. },
  8246. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  8247. this.ensureRange(start, start + length);
  8248. function ChunkedStreamSubstream() {
  8249. }
  8250. ChunkedStreamSubstream.prototype = Object.create(this);
  8251. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  8252. var chunkSize = this.chunkSize;
  8253. var beginChunk = Math.floor(this.start / chunkSize);
  8254. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  8255. var missingChunks = [];
  8256. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8257. if (!this.loadedChunks[chunk]) {
  8258. missingChunks.push(chunk);
  8259. }
  8260. }
  8261. return missingChunks;
  8262. };
  8263. var subStream = new ChunkedStreamSubstream();
  8264. subStream.pos = subStream.start = start;
  8265. subStream.end = start + length || this.end;
  8266. subStream.dict = dict;
  8267. return subStream;
  8268. },
  8269. isStream: true
  8270. };
  8271. return ChunkedStream;
  8272. }();
  8273. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  8274. function ChunkedStreamManager(pdfNetworkStream, args) {
  8275. var chunkSize = args.rangeChunkSize;
  8276. var length = args.length;
  8277. this.stream = new ChunkedStream(length, chunkSize, this);
  8278. this.length = length;
  8279. this.chunkSize = chunkSize;
  8280. this.pdfNetworkStream = pdfNetworkStream;
  8281. this.url = args.url;
  8282. this.disableAutoFetch = args.disableAutoFetch;
  8283. this.msgHandler = args.msgHandler;
  8284. this.currRequestId = 0;
  8285. this.chunksNeededByRequest = Object.create(null);
  8286. this.requestsByChunk = Object.create(null);
  8287. this.promisesByRequest = Object.create(null);
  8288. this.progressiveDataLength = 0;
  8289. this.aborted = false;
  8290. this._loadedStreamCapability = createPromiseCapability();
  8291. }
  8292. ChunkedStreamManager.prototype = {
  8293. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  8294. return this._loadedStreamCapability.promise;
  8295. },
  8296. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  8297. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  8298. if (!rangeReader.isStreamingSupported) {
  8299. rangeReader.onProgress = this.onProgress.bind(this);
  8300. }
  8301. var chunks = [], loaded = 0;
  8302. var manager = this;
  8303. var promise = new Promise(function (resolve, reject) {
  8304. var readChunk = function (chunk) {
  8305. try {
  8306. if (!chunk.done) {
  8307. var data = chunk.value;
  8308. chunks.push(data);
  8309. loaded += arrayByteLength(data);
  8310. if (rangeReader.isStreamingSupported) {
  8311. manager.onProgress({ loaded: loaded });
  8312. }
  8313. rangeReader.read().then(readChunk, reject);
  8314. return;
  8315. }
  8316. var chunkData = arraysToBytes(chunks);
  8317. chunks = null;
  8318. resolve(chunkData);
  8319. } catch (e) {
  8320. reject(e);
  8321. }
  8322. };
  8323. rangeReader.read().then(readChunk, reject);
  8324. });
  8325. promise.then(function (data) {
  8326. if (this.aborted) {
  8327. return;
  8328. }
  8329. this.onReceiveData({
  8330. chunk: data,
  8331. begin: begin
  8332. });
  8333. }.bind(this));
  8334. },
  8335. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  8336. var missingChunks = this.stream.getMissingChunks();
  8337. this._requestChunks(missingChunks);
  8338. return this._loadedStreamCapability.promise;
  8339. },
  8340. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  8341. var requestId = this.currRequestId++;
  8342. var i, ii;
  8343. var chunksNeeded = Object.create(null);
  8344. this.chunksNeededByRequest[requestId] = chunksNeeded;
  8345. for (i = 0, ii = chunks.length; i < ii; i++) {
  8346. if (!this.stream.hasChunk(chunks[i])) {
  8347. chunksNeeded[chunks[i]] = true;
  8348. }
  8349. }
  8350. if (isEmptyObj(chunksNeeded)) {
  8351. return Promise.resolve();
  8352. }
  8353. var capability = createPromiseCapability();
  8354. this.promisesByRequest[requestId] = capability;
  8355. var chunksToRequest = [];
  8356. for (var chunk in chunksNeeded) {
  8357. chunk = chunk | 0;
  8358. if (!(chunk in this.requestsByChunk)) {
  8359. this.requestsByChunk[chunk] = [];
  8360. chunksToRequest.push(chunk);
  8361. }
  8362. this.requestsByChunk[chunk].push(requestId);
  8363. }
  8364. if (!chunksToRequest.length) {
  8365. return capability.promise;
  8366. }
  8367. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  8368. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  8369. var groupedChunk = groupedChunksToRequest[i];
  8370. var begin = groupedChunk.beginChunk * this.chunkSize;
  8371. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  8372. this.sendRequest(begin, end);
  8373. }
  8374. return capability.promise;
  8375. },
  8376. getStream: function ChunkedStreamManager_getStream() {
  8377. return this.stream;
  8378. },
  8379. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  8380. end = Math.min(end, this.length);
  8381. var beginChunk = this.getBeginChunk(begin);
  8382. var endChunk = this.getEndChunk(end);
  8383. var chunks = [];
  8384. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8385. chunks.push(chunk);
  8386. }
  8387. return this._requestChunks(chunks);
  8388. },
  8389. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  8390. ranges = ranges || [];
  8391. var chunksToRequest = [];
  8392. for (var i = 0; i < ranges.length; i++) {
  8393. var beginChunk = this.getBeginChunk(ranges[i].begin);
  8394. var endChunk = this.getEndChunk(ranges[i].end);
  8395. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8396. if (chunksToRequest.indexOf(chunk) < 0) {
  8397. chunksToRequest.push(chunk);
  8398. }
  8399. }
  8400. }
  8401. chunksToRequest.sort(function (a, b) {
  8402. return a - b;
  8403. });
  8404. return this._requestChunks(chunksToRequest);
  8405. },
  8406. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  8407. var groupedChunks = [];
  8408. var beginChunk = -1;
  8409. var prevChunk = -1;
  8410. for (var i = 0; i < chunks.length; ++i) {
  8411. var chunk = chunks[i];
  8412. if (beginChunk < 0) {
  8413. beginChunk = chunk;
  8414. }
  8415. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  8416. groupedChunks.push({
  8417. beginChunk: beginChunk,
  8418. endChunk: prevChunk + 1
  8419. });
  8420. beginChunk = chunk;
  8421. }
  8422. if (i + 1 === chunks.length) {
  8423. groupedChunks.push({
  8424. beginChunk: beginChunk,
  8425. endChunk: chunk + 1
  8426. });
  8427. }
  8428. prevChunk = chunk;
  8429. }
  8430. return groupedChunks;
  8431. },
  8432. onProgress: function ChunkedStreamManager_onProgress(args) {
  8433. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  8434. this.msgHandler.send('DocProgress', {
  8435. loaded: bytesLoaded,
  8436. total: this.length
  8437. });
  8438. },
  8439. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  8440. var chunk = args.chunk;
  8441. var isProgressive = args.begin === undefined;
  8442. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  8443. var end = begin + chunk.byteLength;
  8444. var beginChunk = Math.floor(begin / this.chunkSize);
  8445. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  8446. if (isProgressive) {
  8447. this.stream.onReceiveProgressiveData(chunk);
  8448. this.progressiveDataLength = end;
  8449. } else {
  8450. this.stream.onReceiveData(begin, chunk);
  8451. }
  8452. if (this.stream.allChunksLoaded()) {
  8453. this._loadedStreamCapability.resolve(this.stream);
  8454. }
  8455. var loadedRequests = [];
  8456. var i, requestId;
  8457. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  8458. var requestIds = this.requestsByChunk[chunk] || [];
  8459. delete this.requestsByChunk[chunk];
  8460. for (i = 0; i < requestIds.length; ++i) {
  8461. requestId = requestIds[i];
  8462. var chunksNeeded = this.chunksNeededByRequest[requestId];
  8463. if (chunk in chunksNeeded) {
  8464. delete chunksNeeded[chunk];
  8465. }
  8466. if (!isEmptyObj(chunksNeeded)) {
  8467. continue;
  8468. }
  8469. loadedRequests.push(requestId);
  8470. }
  8471. }
  8472. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  8473. var nextEmptyChunk;
  8474. if (this.stream.numChunksLoaded === 1) {
  8475. var lastChunk = this.stream.numChunks - 1;
  8476. if (!this.stream.hasChunk(lastChunk)) {
  8477. nextEmptyChunk = lastChunk;
  8478. }
  8479. } else {
  8480. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  8481. }
  8482. if (isInt(nextEmptyChunk)) {
  8483. this._requestChunks([nextEmptyChunk]);
  8484. }
  8485. }
  8486. for (i = 0; i < loadedRequests.length; ++i) {
  8487. requestId = loadedRequests[i];
  8488. var capability = this.promisesByRequest[requestId];
  8489. delete this.promisesByRequest[requestId];
  8490. capability.resolve();
  8491. }
  8492. this.msgHandler.send('DocProgress', {
  8493. loaded: this.stream.numChunksLoaded * this.chunkSize,
  8494. total: this.length
  8495. });
  8496. },
  8497. onError: function ChunkedStreamManager_onError(err) {
  8498. this._loadedStreamCapability.reject(err);
  8499. },
  8500. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  8501. var chunk = Math.floor(begin / this.chunkSize);
  8502. return chunk;
  8503. },
  8504. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  8505. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  8506. return chunk;
  8507. },
  8508. abort: function ChunkedStreamManager_abort() {
  8509. this.aborted = true;
  8510. if (this.pdfNetworkStream) {
  8511. this.pdfNetworkStream.cancelAllRequests('abort');
  8512. }
  8513. for (var requestId in this.promisesByRequest) {
  8514. var capability = this.promisesByRequest[requestId];
  8515. capability.reject(new Error('Request was aborted'));
  8516. }
  8517. }
  8518. };
  8519. return ChunkedStreamManager;
  8520. }();
  8521. exports.ChunkedStream = ChunkedStream;
  8522. exports.ChunkedStreamManager = ChunkedStreamManager;
  8523. }));
  8524. (function (root, factory) {
  8525. factory(root.pdfjsCoreGlyphList = {}, root.pdfjsSharedUtil);
  8526. }(this, function (exports, sharedUtil) {
  8527. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  8528. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  8529. t['A'] = 0x0041;
  8530. t['AE'] = 0x00C6;
  8531. t['AEacute'] = 0x01FC;
  8532. t['AEmacron'] = 0x01E2;
  8533. t['AEsmall'] = 0xF7E6;
  8534. t['Aacute'] = 0x00C1;
  8535. t['Aacutesmall'] = 0xF7E1;
  8536. t['Abreve'] = 0x0102;
  8537. t['Abreveacute'] = 0x1EAE;
  8538. t['Abrevecyrillic'] = 0x04D0;
  8539. t['Abrevedotbelow'] = 0x1EB6;
  8540. t['Abrevegrave'] = 0x1EB0;
  8541. t['Abrevehookabove'] = 0x1EB2;
  8542. t['Abrevetilde'] = 0x1EB4;
  8543. t['Acaron'] = 0x01CD;
  8544. t['Acircle'] = 0x24B6;
  8545. t['Acircumflex'] = 0x00C2;
  8546. t['Acircumflexacute'] = 0x1EA4;
  8547. t['Acircumflexdotbelow'] = 0x1EAC;
  8548. t['Acircumflexgrave'] = 0x1EA6;
  8549. t['Acircumflexhookabove'] = 0x1EA8;
  8550. t['Acircumflexsmall'] = 0xF7E2;
  8551. t['Acircumflextilde'] = 0x1EAA;
  8552. t['Acute'] = 0xF6C9;
  8553. t['Acutesmall'] = 0xF7B4;
  8554. t['Acyrillic'] = 0x0410;
  8555. t['Adblgrave'] = 0x0200;
  8556. t['Adieresis'] = 0x00C4;
  8557. t['Adieresiscyrillic'] = 0x04D2;
  8558. t['Adieresismacron'] = 0x01DE;
  8559. t['Adieresissmall'] = 0xF7E4;
  8560. t['Adotbelow'] = 0x1EA0;
  8561. t['Adotmacron'] = 0x01E0;
  8562. t['Agrave'] = 0x00C0;
  8563. t['Agravesmall'] = 0xF7E0;
  8564. t['Ahookabove'] = 0x1EA2;
  8565. t['Aiecyrillic'] = 0x04D4;
  8566. t['Ainvertedbreve'] = 0x0202;
  8567. t['Alpha'] = 0x0391;
  8568. t['Alphatonos'] = 0x0386;
  8569. t['Amacron'] = 0x0100;
  8570. t['Amonospace'] = 0xFF21;
  8571. t['Aogonek'] = 0x0104;
  8572. t['Aring'] = 0x00C5;
  8573. t['Aringacute'] = 0x01FA;
  8574. t['Aringbelow'] = 0x1E00;
  8575. t['Aringsmall'] = 0xF7E5;
  8576. t['Asmall'] = 0xF761;
  8577. t['Atilde'] = 0x00C3;
  8578. t['Atildesmall'] = 0xF7E3;
  8579. t['Aybarmenian'] = 0x0531;
  8580. t['B'] = 0x0042;
  8581. t['Bcircle'] = 0x24B7;
  8582. t['Bdotaccent'] = 0x1E02;
  8583. t['Bdotbelow'] = 0x1E04;
  8584. t['Becyrillic'] = 0x0411;
  8585. t['Benarmenian'] = 0x0532;
  8586. t['Beta'] = 0x0392;
  8587. t['Bhook'] = 0x0181;
  8588. t['Blinebelow'] = 0x1E06;
  8589. t['Bmonospace'] = 0xFF22;
  8590. t['Brevesmall'] = 0xF6F4;
  8591. t['Bsmall'] = 0xF762;
  8592. t['Btopbar'] = 0x0182;
  8593. t['C'] = 0x0043;
  8594. t['Caarmenian'] = 0x053E;
  8595. t['Cacute'] = 0x0106;
  8596. t['Caron'] = 0xF6CA;
  8597. t['Caronsmall'] = 0xF6F5;
  8598. t['Ccaron'] = 0x010C;
  8599. t['Ccedilla'] = 0x00C7;
  8600. t['Ccedillaacute'] = 0x1E08;
  8601. t['Ccedillasmall'] = 0xF7E7;
  8602. t['Ccircle'] = 0x24B8;
  8603. t['Ccircumflex'] = 0x0108;
  8604. t['Cdot'] = 0x010A;
  8605. t['Cdotaccent'] = 0x010A;
  8606. t['Cedillasmall'] = 0xF7B8;
  8607. t['Chaarmenian'] = 0x0549;
  8608. t['Cheabkhasiancyrillic'] = 0x04BC;
  8609. t['Checyrillic'] = 0x0427;
  8610. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  8611. t['Chedescendercyrillic'] = 0x04B6;
  8612. t['Chedieresiscyrillic'] = 0x04F4;
  8613. t['Cheharmenian'] = 0x0543;
  8614. t['Chekhakassiancyrillic'] = 0x04CB;
  8615. t['Cheverticalstrokecyrillic'] = 0x04B8;
  8616. t['Chi'] = 0x03A7;
  8617. t['Chook'] = 0x0187;
  8618. t['Circumflexsmall'] = 0xF6F6;
  8619. t['Cmonospace'] = 0xFF23;
  8620. t['Coarmenian'] = 0x0551;
  8621. t['Csmall'] = 0xF763;
  8622. t['D'] = 0x0044;
  8623. t['DZ'] = 0x01F1;
  8624. t['DZcaron'] = 0x01C4;
  8625. t['Daarmenian'] = 0x0534;
  8626. t['Dafrican'] = 0x0189;
  8627. t['Dcaron'] = 0x010E;
  8628. t['Dcedilla'] = 0x1E10;
  8629. t['Dcircle'] = 0x24B9;
  8630. t['Dcircumflexbelow'] = 0x1E12;
  8631. t['Dcroat'] = 0x0110;
  8632. t['Ddotaccent'] = 0x1E0A;
  8633. t['Ddotbelow'] = 0x1E0C;
  8634. t['Decyrillic'] = 0x0414;
  8635. t['Deicoptic'] = 0x03EE;
  8636. t['Delta'] = 0x2206;
  8637. t['Deltagreek'] = 0x0394;
  8638. t['Dhook'] = 0x018A;
  8639. t['Dieresis'] = 0xF6CB;
  8640. t['DieresisAcute'] = 0xF6CC;
  8641. t['DieresisGrave'] = 0xF6CD;
  8642. t['Dieresissmall'] = 0xF7A8;
  8643. t['Digammagreek'] = 0x03DC;
  8644. t['Djecyrillic'] = 0x0402;
  8645. t['Dlinebelow'] = 0x1E0E;
  8646. t['Dmonospace'] = 0xFF24;
  8647. t['Dotaccentsmall'] = 0xF6F7;
  8648. t['Dslash'] = 0x0110;
  8649. t['Dsmall'] = 0xF764;
  8650. t['Dtopbar'] = 0x018B;
  8651. t['Dz'] = 0x01F2;
  8652. t['Dzcaron'] = 0x01C5;
  8653. t['Dzeabkhasiancyrillic'] = 0x04E0;
  8654. t['Dzecyrillic'] = 0x0405;
  8655. t['Dzhecyrillic'] = 0x040F;
  8656. t['E'] = 0x0045;
  8657. t['Eacute'] = 0x00C9;
  8658. t['Eacutesmall'] = 0xF7E9;
  8659. t['Ebreve'] = 0x0114;
  8660. t['Ecaron'] = 0x011A;
  8661. t['Ecedillabreve'] = 0x1E1C;
  8662. t['Echarmenian'] = 0x0535;
  8663. t['Ecircle'] = 0x24BA;
  8664. t['Ecircumflex'] = 0x00CA;
  8665. t['Ecircumflexacute'] = 0x1EBE;
  8666. t['Ecircumflexbelow'] = 0x1E18;
  8667. t['Ecircumflexdotbelow'] = 0x1EC6;
  8668. t['Ecircumflexgrave'] = 0x1EC0;
  8669. t['Ecircumflexhookabove'] = 0x1EC2;
  8670. t['Ecircumflexsmall'] = 0xF7EA;
  8671. t['Ecircumflextilde'] = 0x1EC4;
  8672. t['Ecyrillic'] = 0x0404;
  8673. t['Edblgrave'] = 0x0204;
  8674. t['Edieresis'] = 0x00CB;
  8675. t['Edieresissmall'] = 0xF7EB;
  8676. t['Edot'] = 0x0116;
  8677. t['Edotaccent'] = 0x0116;
  8678. t['Edotbelow'] = 0x1EB8;
  8679. t['Efcyrillic'] = 0x0424;
  8680. t['Egrave'] = 0x00C8;
  8681. t['Egravesmall'] = 0xF7E8;
  8682. t['Eharmenian'] = 0x0537;
  8683. t['Ehookabove'] = 0x1EBA;
  8684. t['Eightroman'] = 0x2167;
  8685. t['Einvertedbreve'] = 0x0206;
  8686. t['Eiotifiedcyrillic'] = 0x0464;
  8687. t['Elcyrillic'] = 0x041B;
  8688. t['Elevenroman'] = 0x216A;
  8689. t['Emacron'] = 0x0112;
  8690. t['Emacronacute'] = 0x1E16;
  8691. t['Emacrongrave'] = 0x1E14;
  8692. t['Emcyrillic'] = 0x041C;
  8693. t['Emonospace'] = 0xFF25;
  8694. t['Encyrillic'] = 0x041D;
  8695. t['Endescendercyrillic'] = 0x04A2;
  8696. t['Eng'] = 0x014A;
  8697. t['Enghecyrillic'] = 0x04A4;
  8698. t['Enhookcyrillic'] = 0x04C7;
  8699. t['Eogonek'] = 0x0118;
  8700. t['Eopen'] = 0x0190;
  8701. t['Epsilon'] = 0x0395;
  8702. t['Epsilontonos'] = 0x0388;
  8703. t['Ercyrillic'] = 0x0420;
  8704. t['Ereversed'] = 0x018E;
  8705. t['Ereversedcyrillic'] = 0x042D;
  8706. t['Escyrillic'] = 0x0421;
  8707. t['Esdescendercyrillic'] = 0x04AA;
  8708. t['Esh'] = 0x01A9;
  8709. t['Esmall'] = 0xF765;
  8710. t['Eta'] = 0x0397;
  8711. t['Etarmenian'] = 0x0538;
  8712. t['Etatonos'] = 0x0389;
  8713. t['Eth'] = 0x00D0;
  8714. t['Ethsmall'] = 0xF7F0;
  8715. t['Etilde'] = 0x1EBC;
  8716. t['Etildebelow'] = 0x1E1A;
  8717. t['Euro'] = 0x20AC;
  8718. t['Ezh'] = 0x01B7;
  8719. t['Ezhcaron'] = 0x01EE;
  8720. t['Ezhreversed'] = 0x01B8;
  8721. t['F'] = 0x0046;
  8722. t['Fcircle'] = 0x24BB;
  8723. t['Fdotaccent'] = 0x1E1E;
  8724. t['Feharmenian'] = 0x0556;
  8725. t['Feicoptic'] = 0x03E4;
  8726. t['Fhook'] = 0x0191;
  8727. t['Fitacyrillic'] = 0x0472;
  8728. t['Fiveroman'] = 0x2164;
  8729. t['Fmonospace'] = 0xFF26;
  8730. t['Fourroman'] = 0x2163;
  8731. t['Fsmall'] = 0xF766;
  8732. t['G'] = 0x0047;
  8733. t['GBsquare'] = 0x3387;
  8734. t['Gacute'] = 0x01F4;
  8735. t['Gamma'] = 0x0393;
  8736. t['Gammaafrican'] = 0x0194;
  8737. t['Gangiacoptic'] = 0x03EA;
  8738. t['Gbreve'] = 0x011E;
  8739. t['Gcaron'] = 0x01E6;
  8740. t['Gcedilla'] = 0x0122;
  8741. t['Gcircle'] = 0x24BC;
  8742. t['Gcircumflex'] = 0x011C;
  8743. t['Gcommaaccent'] = 0x0122;
  8744. t['Gdot'] = 0x0120;
  8745. t['Gdotaccent'] = 0x0120;
  8746. t['Gecyrillic'] = 0x0413;
  8747. t['Ghadarmenian'] = 0x0542;
  8748. t['Ghemiddlehookcyrillic'] = 0x0494;
  8749. t['Ghestrokecyrillic'] = 0x0492;
  8750. t['Gheupturncyrillic'] = 0x0490;
  8751. t['Ghook'] = 0x0193;
  8752. t['Gimarmenian'] = 0x0533;
  8753. t['Gjecyrillic'] = 0x0403;
  8754. t['Gmacron'] = 0x1E20;
  8755. t['Gmonospace'] = 0xFF27;
  8756. t['Grave'] = 0xF6CE;
  8757. t['Gravesmall'] = 0xF760;
  8758. t['Gsmall'] = 0xF767;
  8759. t['Gsmallhook'] = 0x029B;
  8760. t['Gstroke'] = 0x01E4;
  8761. t['H'] = 0x0048;
  8762. t['H18533'] = 0x25CF;
  8763. t['H18543'] = 0x25AA;
  8764. t['H18551'] = 0x25AB;
  8765. t['H22073'] = 0x25A1;
  8766. t['HPsquare'] = 0x33CB;
  8767. t['Haabkhasiancyrillic'] = 0x04A8;
  8768. t['Hadescendercyrillic'] = 0x04B2;
  8769. t['Hardsigncyrillic'] = 0x042A;
  8770. t['Hbar'] = 0x0126;
  8771. t['Hbrevebelow'] = 0x1E2A;
  8772. t['Hcedilla'] = 0x1E28;
  8773. t['Hcircle'] = 0x24BD;
  8774. t['Hcircumflex'] = 0x0124;
  8775. t['Hdieresis'] = 0x1E26;
  8776. t['Hdotaccent'] = 0x1E22;
  8777. t['Hdotbelow'] = 0x1E24;
  8778. t['Hmonospace'] = 0xFF28;
  8779. t['Hoarmenian'] = 0x0540;
  8780. t['Horicoptic'] = 0x03E8;
  8781. t['Hsmall'] = 0xF768;
  8782. t['Hungarumlaut'] = 0xF6CF;
  8783. t['Hungarumlautsmall'] = 0xF6F8;
  8784. t['Hzsquare'] = 0x3390;
  8785. t['I'] = 0x0049;
  8786. t['IAcyrillic'] = 0x042F;
  8787. t['IJ'] = 0x0132;
  8788. t['IUcyrillic'] = 0x042E;
  8789. t['Iacute'] = 0x00CD;
  8790. t['Iacutesmall'] = 0xF7ED;
  8791. t['Ibreve'] = 0x012C;
  8792. t['Icaron'] = 0x01CF;
  8793. t['Icircle'] = 0x24BE;
  8794. t['Icircumflex'] = 0x00CE;
  8795. t['Icircumflexsmall'] = 0xF7EE;
  8796. t['Icyrillic'] = 0x0406;
  8797. t['Idblgrave'] = 0x0208;
  8798. t['Idieresis'] = 0x00CF;
  8799. t['Idieresisacute'] = 0x1E2E;
  8800. t['Idieresiscyrillic'] = 0x04E4;
  8801. t['Idieresissmall'] = 0xF7EF;
  8802. t['Idot'] = 0x0130;
  8803. t['Idotaccent'] = 0x0130;
  8804. t['Idotbelow'] = 0x1ECA;
  8805. t['Iebrevecyrillic'] = 0x04D6;
  8806. t['Iecyrillic'] = 0x0415;
  8807. t['Ifraktur'] = 0x2111;
  8808. t['Igrave'] = 0x00CC;
  8809. t['Igravesmall'] = 0xF7EC;
  8810. t['Ihookabove'] = 0x1EC8;
  8811. t['Iicyrillic'] = 0x0418;
  8812. t['Iinvertedbreve'] = 0x020A;
  8813. t['Iishortcyrillic'] = 0x0419;
  8814. t['Imacron'] = 0x012A;
  8815. t['Imacroncyrillic'] = 0x04E2;
  8816. t['Imonospace'] = 0xFF29;
  8817. t['Iniarmenian'] = 0x053B;
  8818. t['Iocyrillic'] = 0x0401;
  8819. t['Iogonek'] = 0x012E;
  8820. t['Iota'] = 0x0399;
  8821. t['Iotaafrican'] = 0x0196;
  8822. t['Iotadieresis'] = 0x03AA;
  8823. t['Iotatonos'] = 0x038A;
  8824. t['Ismall'] = 0xF769;
  8825. t['Istroke'] = 0x0197;
  8826. t['Itilde'] = 0x0128;
  8827. t['Itildebelow'] = 0x1E2C;
  8828. t['Izhitsacyrillic'] = 0x0474;
  8829. t['Izhitsadblgravecyrillic'] = 0x0476;
  8830. t['J'] = 0x004A;
  8831. t['Jaarmenian'] = 0x0541;
  8832. t['Jcircle'] = 0x24BF;
  8833. t['Jcircumflex'] = 0x0134;
  8834. t['Jecyrillic'] = 0x0408;
  8835. t['Jheharmenian'] = 0x054B;
  8836. t['Jmonospace'] = 0xFF2A;
  8837. t['Jsmall'] = 0xF76A;
  8838. t['K'] = 0x004B;
  8839. t['KBsquare'] = 0x3385;
  8840. t['KKsquare'] = 0x33CD;
  8841. t['Kabashkircyrillic'] = 0x04A0;
  8842. t['Kacute'] = 0x1E30;
  8843. t['Kacyrillic'] = 0x041A;
  8844. t['Kadescendercyrillic'] = 0x049A;
  8845. t['Kahookcyrillic'] = 0x04C3;
  8846. t['Kappa'] = 0x039A;
  8847. t['Kastrokecyrillic'] = 0x049E;
  8848. t['Kaverticalstrokecyrillic'] = 0x049C;
  8849. t['Kcaron'] = 0x01E8;
  8850. t['Kcedilla'] = 0x0136;
  8851. t['Kcircle'] = 0x24C0;
  8852. t['Kcommaaccent'] = 0x0136;
  8853. t['Kdotbelow'] = 0x1E32;
  8854. t['Keharmenian'] = 0x0554;
  8855. t['Kenarmenian'] = 0x053F;
  8856. t['Khacyrillic'] = 0x0425;
  8857. t['Kheicoptic'] = 0x03E6;
  8858. t['Khook'] = 0x0198;
  8859. t['Kjecyrillic'] = 0x040C;
  8860. t['Klinebelow'] = 0x1E34;
  8861. t['Kmonospace'] = 0xFF2B;
  8862. t['Koppacyrillic'] = 0x0480;
  8863. t['Koppagreek'] = 0x03DE;
  8864. t['Ksicyrillic'] = 0x046E;
  8865. t['Ksmall'] = 0xF76B;
  8866. t['L'] = 0x004C;
  8867. t['LJ'] = 0x01C7;
  8868. t['LL'] = 0xF6BF;
  8869. t['Lacute'] = 0x0139;
  8870. t['Lambda'] = 0x039B;
  8871. t['Lcaron'] = 0x013D;
  8872. t['Lcedilla'] = 0x013B;
  8873. t['Lcircle'] = 0x24C1;
  8874. t['Lcircumflexbelow'] = 0x1E3C;
  8875. t['Lcommaaccent'] = 0x013B;
  8876. t['Ldot'] = 0x013F;
  8877. t['Ldotaccent'] = 0x013F;
  8878. t['Ldotbelow'] = 0x1E36;
  8879. t['Ldotbelowmacron'] = 0x1E38;
  8880. t['Liwnarmenian'] = 0x053C;
  8881. t['Lj'] = 0x01C8;
  8882. t['Ljecyrillic'] = 0x0409;
  8883. t['Llinebelow'] = 0x1E3A;
  8884. t['Lmonospace'] = 0xFF2C;
  8885. t['Lslash'] = 0x0141;
  8886. t['Lslashsmall'] = 0xF6F9;
  8887. t['Lsmall'] = 0xF76C;
  8888. t['M'] = 0x004D;
  8889. t['MBsquare'] = 0x3386;
  8890. t['Macron'] = 0xF6D0;
  8891. t['Macronsmall'] = 0xF7AF;
  8892. t['Macute'] = 0x1E3E;
  8893. t['Mcircle'] = 0x24C2;
  8894. t['Mdotaccent'] = 0x1E40;
  8895. t['Mdotbelow'] = 0x1E42;
  8896. t['Menarmenian'] = 0x0544;
  8897. t['Mmonospace'] = 0xFF2D;
  8898. t['Msmall'] = 0xF76D;
  8899. t['Mturned'] = 0x019C;
  8900. t['Mu'] = 0x039C;
  8901. t['N'] = 0x004E;
  8902. t['NJ'] = 0x01CA;
  8903. t['Nacute'] = 0x0143;
  8904. t['Ncaron'] = 0x0147;
  8905. t['Ncedilla'] = 0x0145;
  8906. t['Ncircle'] = 0x24C3;
  8907. t['Ncircumflexbelow'] = 0x1E4A;
  8908. t['Ncommaaccent'] = 0x0145;
  8909. t['Ndotaccent'] = 0x1E44;
  8910. t['Ndotbelow'] = 0x1E46;
  8911. t['Nhookleft'] = 0x019D;
  8912. t['Nineroman'] = 0x2168;
  8913. t['Nj'] = 0x01CB;
  8914. t['Njecyrillic'] = 0x040A;
  8915. t['Nlinebelow'] = 0x1E48;
  8916. t['Nmonospace'] = 0xFF2E;
  8917. t['Nowarmenian'] = 0x0546;
  8918. t['Nsmall'] = 0xF76E;
  8919. t['Ntilde'] = 0x00D1;
  8920. t['Ntildesmall'] = 0xF7F1;
  8921. t['Nu'] = 0x039D;
  8922. t['O'] = 0x004F;
  8923. t['OE'] = 0x0152;
  8924. t['OEsmall'] = 0xF6FA;
  8925. t['Oacute'] = 0x00D3;
  8926. t['Oacutesmall'] = 0xF7F3;
  8927. t['Obarredcyrillic'] = 0x04E8;
  8928. t['Obarreddieresiscyrillic'] = 0x04EA;
  8929. t['Obreve'] = 0x014E;
  8930. t['Ocaron'] = 0x01D1;
  8931. t['Ocenteredtilde'] = 0x019F;
  8932. t['Ocircle'] = 0x24C4;
  8933. t['Ocircumflex'] = 0x00D4;
  8934. t['Ocircumflexacute'] = 0x1ED0;
  8935. t['Ocircumflexdotbelow'] = 0x1ED8;
  8936. t['Ocircumflexgrave'] = 0x1ED2;
  8937. t['Ocircumflexhookabove'] = 0x1ED4;
  8938. t['Ocircumflexsmall'] = 0xF7F4;
  8939. t['Ocircumflextilde'] = 0x1ED6;
  8940. t['Ocyrillic'] = 0x041E;
  8941. t['Odblacute'] = 0x0150;
  8942. t['Odblgrave'] = 0x020C;
  8943. t['Odieresis'] = 0x00D6;
  8944. t['Odieresiscyrillic'] = 0x04E6;
  8945. t['Odieresissmall'] = 0xF7F6;
  8946. t['Odotbelow'] = 0x1ECC;
  8947. t['Ogoneksmall'] = 0xF6FB;
  8948. t['Ograve'] = 0x00D2;
  8949. t['Ogravesmall'] = 0xF7F2;
  8950. t['Oharmenian'] = 0x0555;
  8951. t['Ohm'] = 0x2126;
  8952. t['Ohookabove'] = 0x1ECE;
  8953. t['Ohorn'] = 0x01A0;
  8954. t['Ohornacute'] = 0x1EDA;
  8955. t['Ohorndotbelow'] = 0x1EE2;
  8956. t['Ohorngrave'] = 0x1EDC;
  8957. t['Ohornhookabove'] = 0x1EDE;
  8958. t['Ohorntilde'] = 0x1EE0;
  8959. t['Ohungarumlaut'] = 0x0150;
  8960. t['Oi'] = 0x01A2;
  8961. t['Oinvertedbreve'] = 0x020E;
  8962. t['Omacron'] = 0x014C;
  8963. t['Omacronacute'] = 0x1E52;
  8964. t['Omacrongrave'] = 0x1E50;
  8965. t['Omega'] = 0x2126;
  8966. t['Omegacyrillic'] = 0x0460;
  8967. t['Omegagreek'] = 0x03A9;
  8968. t['Omegaroundcyrillic'] = 0x047A;
  8969. t['Omegatitlocyrillic'] = 0x047C;
  8970. t['Omegatonos'] = 0x038F;
  8971. t['Omicron'] = 0x039F;
  8972. t['Omicrontonos'] = 0x038C;
  8973. t['Omonospace'] = 0xFF2F;
  8974. t['Oneroman'] = 0x2160;
  8975. t['Oogonek'] = 0x01EA;
  8976. t['Oogonekmacron'] = 0x01EC;
  8977. t['Oopen'] = 0x0186;
  8978. t['Oslash'] = 0x00D8;
  8979. t['Oslashacute'] = 0x01FE;
  8980. t['Oslashsmall'] = 0xF7F8;
  8981. t['Osmall'] = 0xF76F;
  8982. t['Ostrokeacute'] = 0x01FE;
  8983. t['Otcyrillic'] = 0x047E;
  8984. t['Otilde'] = 0x00D5;
  8985. t['Otildeacute'] = 0x1E4C;
  8986. t['Otildedieresis'] = 0x1E4E;
  8987. t['Otildesmall'] = 0xF7F5;
  8988. t['P'] = 0x0050;
  8989. t['Pacute'] = 0x1E54;
  8990. t['Pcircle'] = 0x24C5;
  8991. t['Pdotaccent'] = 0x1E56;
  8992. t['Pecyrillic'] = 0x041F;
  8993. t['Peharmenian'] = 0x054A;
  8994. t['Pemiddlehookcyrillic'] = 0x04A6;
  8995. t['Phi'] = 0x03A6;
  8996. t['Phook'] = 0x01A4;
  8997. t['Pi'] = 0x03A0;
  8998. t['Piwrarmenian'] = 0x0553;
  8999. t['Pmonospace'] = 0xFF30;
  9000. t['Psi'] = 0x03A8;
  9001. t['Psicyrillic'] = 0x0470;
  9002. t['Psmall'] = 0xF770;
  9003. t['Q'] = 0x0051;
  9004. t['Qcircle'] = 0x24C6;
  9005. t['Qmonospace'] = 0xFF31;
  9006. t['Qsmall'] = 0xF771;
  9007. t['R'] = 0x0052;
  9008. t['Raarmenian'] = 0x054C;
  9009. t['Racute'] = 0x0154;
  9010. t['Rcaron'] = 0x0158;
  9011. t['Rcedilla'] = 0x0156;
  9012. t['Rcircle'] = 0x24C7;
  9013. t['Rcommaaccent'] = 0x0156;
  9014. t['Rdblgrave'] = 0x0210;
  9015. t['Rdotaccent'] = 0x1E58;
  9016. t['Rdotbelow'] = 0x1E5A;
  9017. t['Rdotbelowmacron'] = 0x1E5C;
  9018. t['Reharmenian'] = 0x0550;
  9019. t['Rfraktur'] = 0x211C;
  9020. t['Rho'] = 0x03A1;
  9021. t['Ringsmall'] = 0xF6FC;
  9022. t['Rinvertedbreve'] = 0x0212;
  9023. t['Rlinebelow'] = 0x1E5E;
  9024. t['Rmonospace'] = 0xFF32;
  9025. t['Rsmall'] = 0xF772;
  9026. t['Rsmallinverted'] = 0x0281;
  9027. t['Rsmallinvertedsuperior'] = 0x02B6;
  9028. t['S'] = 0x0053;
  9029. t['SF010000'] = 0x250C;
  9030. t['SF020000'] = 0x2514;
  9031. t['SF030000'] = 0x2510;
  9032. t['SF040000'] = 0x2518;
  9033. t['SF050000'] = 0x253C;
  9034. t['SF060000'] = 0x252C;
  9035. t['SF070000'] = 0x2534;
  9036. t['SF080000'] = 0x251C;
  9037. t['SF090000'] = 0x2524;
  9038. t['SF100000'] = 0x2500;
  9039. t['SF110000'] = 0x2502;
  9040. t['SF190000'] = 0x2561;
  9041. t['SF200000'] = 0x2562;
  9042. t['SF210000'] = 0x2556;
  9043. t['SF220000'] = 0x2555;
  9044. t['SF230000'] = 0x2563;
  9045. t['SF240000'] = 0x2551;
  9046. t['SF250000'] = 0x2557;
  9047. t['SF260000'] = 0x255D;
  9048. t['SF270000'] = 0x255C;
  9049. t['SF280000'] = 0x255B;
  9050. t['SF360000'] = 0x255E;
  9051. t['SF370000'] = 0x255F;
  9052. t['SF380000'] = 0x255A;
  9053. t['SF390000'] = 0x2554;
  9054. t['SF400000'] = 0x2569;
  9055. t['SF410000'] = 0x2566;
  9056. t['SF420000'] = 0x2560;
  9057. t['SF430000'] = 0x2550;
  9058. t['SF440000'] = 0x256C;
  9059. t['SF450000'] = 0x2567;
  9060. t['SF460000'] = 0x2568;
  9061. t['SF470000'] = 0x2564;
  9062. t['SF480000'] = 0x2565;
  9063. t['SF490000'] = 0x2559;
  9064. t['SF500000'] = 0x2558;
  9065. t['SF510000'] = 0x2552;
  9066. t['SF520000'] = 0x2553;
  9067. t['SF530000'] = 0x256B;
  9068. t['SF540000'] = 0x256A;
  9069. t['Sacute'] = 0x015A;
  9070. t['Sacutedotaccent'] = 0x1E64;
  9071. t['Sampigreek'] = 0x03E0;
  9072. t['Scaron'] = 0x0160;
  9073. t['Scarondotaccent'] = 0x1E66;
  9074. t['Scaronsmall'] = 0xF6FD;
  9075. t['Scedilla'] = 0x015E;
  9076. t['Schwa'] = 0x018F;
  9077. t['Schwacyrillic'] = 0x04D8;
  9078. t['Schwadieresiscyrillic'] = 0x04DA;
  9079. t['Scircle'] = 0x24C8;
  9080. t['Scircumflex'] = 0x015C;
  9081. t['Scommaaccent'] = 0x0218;
  9082. t['Sdotaccent'] = 0x1E60;
  9083. t['Sdotbelow'] = 0x1E62;
  9084. t['Sdotbelowdotaccent'] = 0x1E68;
  9085. t['Seharmenian'] = 0x054D;
  9086. t['Sevenroman'] = 0x2166;
  9087. t['Shaarmenian'] = 0x0547;
  9088. t['Shacyrillic'] = 0x0428;
  9089. t['Shchacyrillic'] = 0x0429;
  9090. t['Sheicoptic'] = 0x03E2;
  9091. t['Shhacyrillic'] = 0x04BA;
  9092. t['Shimacoptic'] = 0x03EC;
  9093. t['Sigma'] = 0x03A3;
  9094. t['Sixroman'] = 0x2165;
  9095. t['Smonospace'] = 0xFF33;
  9096. t['Softsigncyrillic'] = 0x042C;
  9097. t['Ssmall'] = 0xF773;
  9098. t['Stigmagreek'] = 0x03DA;
  9099. t['T'] = 0x0054;
  9100. t['Tau'] = 0x03A4;
  9101. t['Tbar'] = 0x0166;
  9102. t['Tcaron'] = 0x0164;
  9103. t['Tcedilla'] = 0x0162;
  9104. t['Tcircle'] = 0x24C9;
  9105. t['Tcircumflexbelow'] = 0x1E70;
  9106. t['Tcommaaccent'] = 0x0162;
  9107. t['Tdotaccent'] = 0x1E6A;
  9108. t['Tdotbelow'] = 0x1E6C;
  9109. t['Tecyrillic'] = 0x0422;
  9110. t['Tedescendercyrillic'] = 0x04AC;
  9111. t['Tenroman'] = 0x2169;
  9112. t['Tetsecyrillic'] = 0x04B4;
  9113. t['Theta'] = 0x0398;
  9114. t['Thook'] = 0x01AC;
  9115. t['Thorn'] = 0x00DE;
  9116. t['Thornsmall'] = 0xF7FE;
  9117. t['Threeroman'] = 0x2162;
  9118. t['Tildesmall'] = 0xF6FE;
  9119. t['Tiwnarmenian'] = 0x054F;
  9120. t['Tlinebelow'] = 0x1E6E;
  9121. t['Tmonospace'] = 0xFF34;
  9122. t['Toarmenian'] = 0x0539;
  9123. t['Tonefive'] = 0x01BC;
  9124. t['Tonesix'] = 0x0184;
  9125. t['Tonetwo'] = 0x01A7;
  9126. t['Tretroflexhook'] = 0x01AE;
  9127. t['Tsecyrillic'] = 0x0426;
  9128. t['Tshecyrillic'] = 0x040B;
  9129. t['Tsmall'] = 0xF774;
  9130. t['Twelveroman'] = 0x216B;
  9131. t['Tworoman'] = 0x2161;
  9132. t['U'] = 0x0055;
  9133. t['Uacute'] = 0x00DA;
  9134. t['Uacutesmall'] = 0xF7FA;
  9135. t['Ubreve'] = 0x016C;
  9136. t['Ucaron'] = 0x01D3;
  9137. t['Ucircle'] = 0x24CA;
  9138. t['Ucircumflex'] = 0x00DB;
  9139. t['Ucircumflexbelow'] = 0x1E76;
  9140. t['Ucircumflexsmall'] = 0xF7FB;
  9141. t['Ucyrillic'] = 0x0423;
  9142. t['Udblacute'] = 0x0170;
  9143. t['Udblgrave'] = 0x0214;
  9144. t['Udieresis'] = 0x00DC;
  9145. t['Udieresisacute'] = 0x01D7;
  9146. t['Udieresisbelow'] = 0x1E72;
  9147. t['Udieresiscaron'] = 0x01D9;
  9148. t['Udieresiscyrillic'] = 0x04F0;
  9149. t['Udieresisgrave'] = 0x01DB;
  9150. t['Udieresismacron'] = 0x01D5;
  9151. t['Udieresissmall'] = 0xF7FC;
  9152. t['Udotbelow'] = 0x1EE4;
  9153. t['Ugrave'] = 0x00D9;
  9154. t['Ugravesmall'] = 0xF7F9;
  9155. t['Uhookabove'] = 0x1EE6;
  9156. t['Uhorn'] = 0x01AF;
  9157. t['Uhornacute'] = 0x1EE8;
  9158. t['Uhorndotbelow'] = 0x1EF0;
  9159. t['Uhorngrave'] = 0x1EEA;
  9160. t['Uhornhookabove'] = 0x1EEC;
  9161. t['Uhorntilde'] = 0x1EEE;
  9162. t['Uhungarumlaut'] = 0x0170;
  9163. t['Uhungarumlautcyrillic'] = 0x04F2;
  9164. t['Uinvertedbreve'] = 0x0216;
  9165. t['Ukcyrillic'] = 0x0478;
  9166. t['Umacron'] = 0x016A;
  9167. t['Umacroncyrillic'] = 0x04EE;
  9168. t['Umacrondieresis'] = 0x1E7A;
  9169. t['Umonospace'] = 0xFF35;
  9170. t['Uogonek'] = 0x0172;
  9171. t['Upsilon'] = 0x03A5;
  9172. t['Upsilon1'] = 0x03D2;
  9173. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  9174. t['Upsilonafrican'] = 0x01B1;
  9175. t['Upsilondieresis'] = 0x03AB;
  9176. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  9177. t['Upsilonhooksymbol'] = 0x03D2;
  9178. t['Upsilontonos'] = 0x038E;
  9179. t['Uring'] = 0x016E;
  9180. t['Ushortcyrillic'] = 0x040E;
  9181. t['Usmall'] = 0xF775;
  9182. t['Ustraightcyrillic'] = 0x04AE;
  9183. t['Ustraightstrokecyrillic'] = 0x04B0;
  9184. t['Utilde'] = 0x0168;
  9185. t['Utildeacute'] = 0x1E78;
  9186. t['Utildebelow'] = 0x1E74;
  9187. t['V'] = 0x0056;
  9188. t['Vcircle'] = 0x24CB;
  9189. t['Vdotbelow'] = 0x1E7E;
  9190. t['Vecyrillic'] = 0x0412;
  9191. t['Vewarmenian'] = 0x054E;
  9192. t['Vhook'] = 0x01B2;
  9193. t['Vmonospace'] = 0xFF36;
  9194. t['Voarmenian'] = 0x0548;
  9195. t['Vsmall'] = 0xF776;
  9196. t['Vtilde'] = 0x1E7C;
  9197. t['W'] = 0x0057;
  9198. t['Wacute'] = 0x1E82;
  9199. t['Wcircle'] = 0x24CC;
  9200. t['Wcircumflex'] = 0x0174;
  9201. t['Wdieresis'] = 0x1E84;
  9202. t['Wdotaccent'] = 0x1E86;
  9203. t['Wdotbelow'] = 0x1E88;
  9204. t['Wgrave'] = 0x1E80;
  9205. t['Wmonospace'] = 0xFF37;
  9206. t['Wsmall'] = 0xF777;
  9207. t['X'] = 0x0058;
  9208. t['Xcircle'] = 0x24CD;
  9209. t['Xdieresis'] = 0x1E8C;
  9210. t['Xdotaccent'] = 0x1E8A;
  9211. t['Xeharmenian'] = 0x053D;
  9212. t['Xi'] = 0x039E;
  9213. t['Xmonospace'] = 0xFF38;
  9214. t['Xsmall'] = 0xF778;
  9215. t['Y'] = 0x0059;
  9216. t['Yacute'] = 0x00DD;
  9217. t['Yacutesmall'] = 0xF7FD;
  9218. t['Yatcyrillic'] = 0x0462;
  9219. t['Ycircle'] = 0x24CE;
  9220. t['Ycircumflex'] = 0x0176;
  9221. t['Ydieresis'] = 0x0178;
  9222. t['Ydieresissmall'] = 0xF7FF;
  9223. t['Ydotaccent'] = 0x1E8E;
  9224. t['Ydotbelow'] = 0x1EF4;
  9225. t['Yericyrillic'] = 0x042B;
  9226. t['Yerudieresiscyrillic'] = 0x04F8;
  9227. t['Ygrave'] = 0x1EF2;
  9228. t['Yhook'] = 0x01B3;
  9229. t['Yhookabove'] = 0x1EF6;
  9230. t['Yiarmenian'] = 0x0545;
  9231. t['Yicyrillic'] = 0x0407;
  9232. t['Yiwnarmenian'] = 0x0552;
  9233. t['Ymonospace'] = 0xFF39;
  9234. t['Ysmall'] = 0xF779;
  9235. t['Ytilde'] = 0x1EF8;
  9236. t['Yusbigcyrillic'] = 0x046A;
  9237. t['Yusbigiotifiedcyrillic'] = 0x046C;
  9238. t['Yuslittlecyrillic'] = 0x0466;
  9239. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  9240. t['Z'] = 0x005A;
  9241. t['Zaarmenian'] = 0x0536;
  9242. t['Zacute'] = 0x0179;
  9243. t['Zcaron'] = 0x017D;
  9244. t['Zcaronsmall'] = 0xF6FF;
  9245. t['Zcircle'] = 0x24CF;
  9246. t['Zcircumflex'] = 0x1E90;
  9247. t['Zdot'] = 0x017B;
  9248. t['Zdotaccent'] = 0x017B;
  9249. t['Zdotbelow'] = 0x1E92;
  9250. t['Zecyrillic'] = 0x0417;
  9251. t['Zedescendercyrillic'] = 0x0498;
  9252. t['Zedieresiscyrillic'] = 0x04DE;
  9253. t['Zeta'] = 0x0396;
  9254. t['Zhearmenian'] = 0x053A;
  9255. t['Zhebrevecyrillic'] = 0x04C1;
  9256. t['Zhecyrillic'] = 0x0416;
  9257. t['Zhedescendercyrillic'] = 0x0496;
  9258. t['Zhedieresiscyrillic'] = 0x04DC;
  9259. t['Zlinebelow'] = 0x1E94;
  9260. t['Zmonospace'] = 0xFF3A;
  9261. t['Zsmall'] = 0xF77A;
  9262. t['Zstroke'] = 0x01B5;
  9263. t['a'] = 0x0061;
  9264. t['aabengali'] = 0x0986;
  9265. t['aacute'] = 0x00E1;
  9266. t['aadeva'] = 0x0906;
  9267. t['aagujarati'] = 0x0A86;
  9268. t['aagurmukhi'] = 0x0A06;
  9269. t['aamatragurmukhi'] = 0x0A3E;
  9270. t['aarusquare'] = 0x3303;
  9271. t['aavowelsignbengali'] = 0x09BE;
  9272. t['aavowelsigndeva'] = 0x093E;
  9273. t['aavowelsigngujarati'] = 0x0ABE;
  9274. t['abbreviationmarkarmenian'] = 0x055F;
  9275. t['abbreviationsigndeva'] = 0x0970;
  9276. t['abengali'] = 0x0985;
  9277. t['abopomofo'] = 0x311A;
  9278. t['abreve'] = 0x0103;
  9279. t['abreveacute'] = 0x1EAF;
  9280. t['abrevecyrillic'] = 0x04D1;
  9281. t['abrevedotbelow'] = 0x1EB7;
  9282. t['abrevegrave'] = 0x1EB1;
  9283. t['abrevehookabove'] = 0x1EB3;
  9284. t['abrevetilde'] = 0x1EB5;
  9285. t['acaron'] = 0x01CE;
  9286. t['acircle'] = 0x24D0;
  9287. t['acircumflex'] = 0x00E2;
  9288. t['acircumflexacute'] = 0x1EA5;
  9289. t['acircumflexdotbelow'] = 0x1EAD;
  9290. t['acircumflexgrave'] = 0x1EA7;
  9291. t['acircumflexhookabove'] = 0x1EA9;
  9292. t['acircumflextilde'] = 0x1EAB;
  9293. t['acute'] = 0x00B4;
  9294. t['acutebelowcmb'] = 0x0317;
  9295. t['acutecmb'] = 0x0301;
  9296. t['acutecomb'] = 0x0301;
  9297. t['acutedeva'] = 0x0954;
  9298. t['acutelowmod'] = 0x02CF;
  9299. t['acutetonecmb'] = 0x0341;
  9300. t['acyrillic'] = 0x0430;
  9301. t['adblgrave'] = 0x0201;
  9302. t['addakgurmukhi'] = 0x0A71;
  9303. t['adeva'] = 0x0905;
  9304. t['adieresis'] = 0x00E4;
  9305. t['adieresiscyrillic'] = 0x04D3;
  9306. t['adieresismacron'] = 0x01DF;
  9307. t['adotbelow'] = 0x1EA1;
  9308. t['adotmacron'] = 0x01E1;
  9309. t['ae'] = 0x00E6;
  9310. t['aeacute'] = 0x01FD;
  9311. t['aekorean'] = 0x3150;
  9312. t['aemacron'] = 0x01E3;
  9313. t['afii00208'] = 0x2015;
  9314. t['afii08941'] = 0x20A4;
  9315. t['afii10017'] = 0x0410;
  9316. t['afii10018'] = 0x0411;
  9317. t['afii10019'] = 0x0412;
  9318. t['afii10020'] = 0x0413;
  9319. t['afii10021'] = 0x0414;
  9320. t['afii10022'] = 0x0415;
  9321. t['afii10023'] = 0x0401;
  9322. t['afii10024'] = 0x0416;
  9323. t['afii10025'] = 0x0417;
  9324. t['afii10026'] = 0x0418;
  9325. t['afii10027'] = 0x0419;
  9326. t['afii10028'] = 0x041A;
  9327. t['afii10029'] = 0x041B;
  9328. t['afii10030'] = 0x041C;
  9329. t['afii10031'] = 0x041D;
  9330. t['afii10032'] = 0x041E;
  9331. t['afii10033'] = 0x041F;
  9332. t['afii10034'] = 0x0420;
  9333. t['afii10035'] = 0x0421;
  9334. t['afii10036'] = 0x0422;
  9335. t['afii10037'] = 0x0423;
  9336. t['afii10038'] = 0x0424;
  9337. t['afii10039'] = 0x0425;
  9338. t['afii10040'] = 0x0426;
  9339. t['afii10041'] = 0x0427;
  9340. t['afii10042'] = 0x0428;
  9341. t['afii10043'] = 0x0429;
  9342. t['afii10044'] = 0x042A;
  9343. t['afii10045'] = 0x042B;
  9344. t['afii10046'] = 0x042C;
  9345. t['afii10047'] = 0x042D;
  9346. t['afii10048'] = 0x042E;
  9347. t['afii10049'] = 0x042F;
  9348. t['afii10050'] = 0x0490;
  9349. t['afii10051'] = 0x0402;
  9350. t['afii10052'] = 0x0403;
  9351. t['afii10053'] = 0x0404;
  9352. t['afii10054'] = 0x0405;
  9353. t['afii10055'] = 0x0406;
  9354. t['afii10056'] = 0x0407;
  9355. t['afii10057'] = 0x0408;
  9356. t['afii10058'] = 0x0409;
  9357. t['afii10059'] = 0x040A;
  9358. t['afii10060'] = 0x040B;
  9359. t['afii10061'] = 0x040C;
  9360. t['afii10062'] = 0x040E;
  9361. t['afii10063'] = 0xF6C4;
  9362. t['afii10064'] = 0xF6C5;
  9363. t['afii10065'] = 0x0430;
  9364. t['afii10066'] = 0x0431;
  9365. t['afii10067'] = 0x0432;
  9366. t['afii10068'] = 0x0433;
  9367. t['afii10069'] = 0x0434;
  9368. t['afii10070'] = 0x0435;
  9369. t['afii10071'] = 0x0451;
  9370. t['afii10072'] = 0x0436;
  9371. t['afii10073'] = 0x0437;
  9372. t['afii10074'] = 0x0438;
  9373. t['afii10075'] = 0x0439;
  9374. t['afii10076'] = 0x043A;
  9375. t['afii10077'] = 0x043B;
  9376. t['afii10078'] = 0x043C;
  9377. t['afii10079'] = 0x043D;
  9378. t['afii10080'] = 0x043E;
  9379. t['afii10081'] = 0x043F;
  9380. t['afii10082'] = 0x0440;
  9381. t['afii10083'] = 0x0441;
  9382. t['afii10084'] = 0x0442;
  9383. t['afii10085'] = 0x0443;
  9384. t['afii10086'] = 0x0444;
  9385. t['afii10087'] = 0x0445;
  9386. t['afii10088'] = 0x0446;
  9387. t['afii10089'] = 0x0447;
  9388. t['afii10090'] = 0x0448;
  9389. t['afii10091'] = 0x0449;
  9390. t['afii10092'] = 0x044A;
  9391. t['afii10093'] = 0x044B;
  9392. t['afii10094'] = 0x044C;
  9393. t['afii10095'] = 0x044D;
  9394. t['afii10096'] = 0x044E;
  9395. t['afii10097'] = 0x044F;
  9396. t['afii10098'] = 0x0491;
  9397. t['afii10099'] = 0x0452;
  9398. t['afii10100'] = 0x0453;
  9399. t['afii10101'] = 0x0454;
  9400. t['afii10102'] = 0x0455;
  9401. t['afii10103'] = 0x0456;
  9402. t['afii10104'] = 0x0457;
  9403. t['afii10105'] = 0x0458;
  9404. t['afii10106'] = 0x0459;
  9405. t['afii10107'] = 0x045A;
  9406. t['afii10108'] = 0x045B;
  9407. t['afii10109'] = 0x045C;
  9408. t['afii10110'] = 0x045E;
  9409. t['afii10145'] = 0x040F;
  9410. t['afii10146'] = 0x0462;
  9411. t['afii10147'] = 0x0472;
  9412. t['afii10148'] = 0x0474;
  9413. t['afii10192'] = 0xF6C6;
  9414. t['afii10193'] = 0x045F;
  9415. t['afii10194'] = 0x0463;
  9416. t['afii10195'] = 0x0473;
  9417. t['afii10196'] = 0x0475;
  9418. t['afii10831'] = 0xF6C7;
  9419. t['afii10832'] = 0xF6C8;
  9420. t['afii10846'] = 0x04D9;
  9421. t['afii299'] = 0x200E;
  9422. t['afii300'] = 0x200F;
  9423. t['afii301'] = 0x200D;
  9424. t['afii57381'] = 0x066A;
  9425. t['afii57388'] = 0x060C;
  9426. t['afii57392'] = 0x0660;
  9427. t['afii57393'] = 0x0661;
  9428. t['afii57394'] = 0x0662;
  9429. t['afii57395'] = 0x0663;
  9430. t['afii57396'] = 0x0664;
  9431. t['afii57397'] = 0x0665;
  9432. t['afii57398'] = 0x0666;
  9433. t['afii57399'] = 0x0667;
  9434. t['afii57400'] = 0x0668;
  9435. t['afii57401'] = 0x0669;
  9436. t['afii57403'] = 0x061B;
  9437. t['afii57407'] = 0x061F;
  9438. t['afii57409'] = 0x0621;
  9439. t['afii57410'] = 0x0622;
  9440. t['afii57411'] = 0x0623;
  9441. t['afii57412'] = 0x0624;
  9442. t['afii57413'] = 0x0625;
  9443. t['afii57414'] = 0x0626;
  9444. t['afii57415'] = 0x0627;
  9445. t['afii57416'] = 0x0628;
  9446. t['afii57417'] = 0x0629;
  9447. t['afii57418'] = 0x062A;
  9448. t['afii57419'] = 0x062B;
  9449. t['afii57420'] = 0x062C;
  9450. t['afii57421'] = 0x062D;
  9451. t['afii57422'] = 0x062E;
  9452. t['afii57423'] = 0x062F;
  9453. t['afii57424'] = 0x0630;
  9454. t['afii57425'] = 0x0631;
  9455. t['afii57426'] = 0x0632;
  9456. t['afii57427'] = 0x0633;
  9457. t['afii57428'] = 0x0634;
  9458. t['afii57429'] = 0x0635;
  9459. t['afii57430'] = 0x0636;
  9460. t['afii57431'] = 0x0637;
  9461. t['afii57432'] = 0x0638;
  9462. t['afii57433'] = 0x0639;
  9463. t['afii57434'] = 0x063A;
  9464. t['afii57440'] = 0x0640;
  9465. t['afii57441'] = 0x0641;
  9466. t['afii57442'] = 0x0642;
  9467. t['afii57443'] = 0x0643;
  9468. t['afii57444'] = 0x0644;
  9469. t['afii57445'] = 0x0645;
  9470. t['afii57446'] = 0x0646;
  9471. t['afii57448'] = 0x0648;
  9472. t['afii57449'] = 0x0649;
  9473. t['afii57450'] = 0x064A;
  9474. t['afii57451'] = 0x064B;
  9475. t['afii57452'] = 0x064C;
  9476. t['afii57453'] = 0x064D;
  9477. t['afii57454'] = 0x064E;
  9478. t['afii57455'] = 0x064F;
  9479. t['afii57456'] = 0x0650;
  9480. t['afii57457'] = 0x0651;
  9481. t['afii57458'] = 0x0652;
  9482. t['afii57470'] = 0x0647;
  9483. t['afii57505'] = 0x06A4;
  9484. t['afii57506'] = 0x067E;
  9485. t['afii57507'] = 0x0686;
  9486. t['afii57508'] = 0x0698;
  9487. t['afii57509'] = 0x06AF;
  9488. t['afii57511'] = 0x0679;
  9489. t['afii57512'] = 0x0688;
  9490. t['afii57513'] = 0x0691;
  9491. t['afii57514'] = 0x06BA;
  9492. t['afii57519'] = 0x06D2;
  9493. t['afii57534'] = 0x06D5;
  9494. t['afii57636'] = 0x20AA;
  9495. t['afii57645'] = 0x05BE;
  9496. t['afii57658'] = 0x05C3;
  9497. t['afii57664'] = 0x05D0;
  9498. t['afii57665'] = 0x05D1;
  9499. t['afii57666'] = 0x05D2;
  9500. t['afii57667'] = 0x05D3;
  9501. t['afii57668'] = 0x05D4;
  9502. t['afii57669'] = 0x05D5;
  9503. t['afii57670'] = 0x05D6;
  9504. t['afii57671'] = 0x05D7;
  9505. t['afii57672'] = 0x05D8;
  9506. t['afii57673'] = 0x05D9;
  9507. t['afii57674'] = 0x05DA;
  9508. t['afii57675'] = 0x05DB;
  9509. t['afii57676'] = 0x05DC;
  9510. t['afii57677'] = 0x05DD;
  9511. t['afii57678'] = 0x05DE;
  9512. t['afii57679'] = 0x05DF;
  9513. t['afii57680'] = 0x05E0;
  9514. t['afii57681'] = 0x05E1;
  9515. t['afii57682'] = 0x05E2;
  9516. t['afii57683'] = 0x05E3;
  9517. t['afii57684'] = 0x05E4;
  9518. t['afii57685'] = 0x05E5;
  9519. t['afii57686'] = 0x05E6;
  9520. t['afii57687'] = 0x05E7;
  9521. t['afii57688'] = 0x05E8;
  9522. t['afii57689'] = 0x05E9;
  9523. t['afii57690'] = 0x05EA;
  9524. t['afii57694'] = 0xFB2A;
  9525. t['afii57695'] = 0xFB2B;
  9526. t['afii57700'] = 0xFB4B;
  9527. t['afii57705'] = 0xFB1F;
  9528. t['afii57716'] = 0x05F0;
  9529. t['afii57717'] = 0x05F1;
  9530. t['afii57718'] = 0x05F2;
  9531. t['afii57723'] = 0xFB35;
  9532. t['afii57793'] = 0x05B4;
  9533. t['afii57794'] = 0x05B5;
  9534. t['afii57795'] = 0x05B6;
  9535. t['afii57796'] = 0x05BB;
  9536. t['afii57797'] = 0x05B8;
  9537. t['afii57798'] = 0x05B7;
  9538. t['afii57799'] = 0x05B0;
  9539. t['afii57800'] = 0x05B2;
  9540. t['afii57801'] = 0x05B1;
  9541. t['afii57802'] = 0x05B3;
  9542. t['afii57803'] = 0x05C2;
  9543. t['afii57804'] = 0x05C1;
  9544. t['afii57806'] = 0x05B9;
  9545. t['afii57807'] = 0x05BC;
  9546. t['afii57839'] = 0x05BD;
  9547. t['afii57841'] = 0x05BF;
  9548. t['afii57842'] = 0x05C0;
  9549. t['afii57929'] = 0x02BC;
  9550. t['afii61248'] = 0x2105;
  9551. t['afii61289'] = 0x2113;
  9552. t['afii61352'] = 0x2116;
  9553. t['afii61573'] = 0x202C;
  9554. t['afii61574'] = 0x202D;
  9555. t['afii61575'] = 0x202E;
  9556. t['afii61664'] = 0x200C;
  9557. t['afii63167'] = 0x066D;
  9558. t['afii64937'] = 0x02BD;
  9559. t['agrave'] = 0x00E0;
  9560. t['agujarati'] = 0x0A85;
  9561. t['agurmukhi'] = 0x0A05;
  9562. t['ahiragana'] = 0x3042;
  9563. t['ahookabove'] = 0x1EA3;
  9564. t['aibengali'] = 0x0990;
  9565. t['aibopomofo'] = 0x311E;
  9566. t['aideva'] = 0x0910;
  9567. t['aiecyrillic'] = 0x04D5;
  9568. t['aigujarati'] = 0x0A90;
  9569. t['aigurmukhi'] = 0x0A10;
  9570. t['aimatragurmukhi'] = 0x0A48;
  9571. t['ainarabic'] = 0x0639;
  9572. t['ainfinalarabic'] = 0xFECA;
  9573. t['aininitialarabic'] = 0xFECB;
  9574. t['ainmedialarabic'] = 0xFECC;
  9575. t['ainvertedbreve'] = 0x0203;
  9576. t['aivowelsignbengali'] = 0x09C8;
  9577. t['aivowelsigndeva'] = 0x0948;
  9578. t['aivowelsigngujarati'] = 0x0AC8;
  9579. t['akatakana'] = 0x30A2;
  9580. t['akatakanahalfwidth'] = 0xFF71;
  9581. t['akorean'] = 0x314F;
  9582. t['alef'] = 0x05D0;
  9583. t['alefarabic'] = 0x0627;
  9584. t['alefdageshhebrew'] = 0xFB30;
  9585. t['aleffinalarabic'] = 0xFE8E;
  9586. t['alefhamzaabovearabic'] = 0x0623;
  9587. t['alefhamzaabovefinalarabic'] = 0xFE84;
  9588. t['alefhamzabelowarabic'] = 0x0625;
  9589. t['alefhamzabelowfinalarabic'] = 0xFE88;
  9590. t['alefhebrew'] = 0x05D0;
  9591. t['aleflamedhebrew'] = 0xFB4F;
  9592. t['alefmaddaabovearabic'] = 0x0622;
  9593. t['alefmaddaabovefinalarabic'] = 0xFE82;
  9594. t['alefmaksuraarabic'] = 0x0649;
  9595. t['alefmaksurafinalarabic'] = 0xFEF0;
  9596. t['alefmaksurainitialarabic'] = 0xFEF3;
  9597. t['alefmaksuramedialarabic'] = 0xFEF4;
  9598. t['alefpatahhebrew'] = 0xFB2E;
  9599. t['alefqamatshebrew'] = 0xFB2F;
  9600. t['aleph'] = 0x2135;
  9601. t['allequal'] = 0x224C;
  9602. t['alpha'] = 0x03B1;
  9603. t['alphatonos'] = 0x03AC;
  9604. t['amacron'] = 0x0101;
  9605. t['amonospace'] = 0xFF41;
  9606. t['ampersand'] = 0x0026;
  9607. t['ampersandmonospace'] = 0xFF06;
  9608. t['ampersandsmall'] = 0xF726;
  9609. t['amsquare'] = 0x33C2;
  9610. t['anbopomofo'] = 0x3122;
  9611. t['angbopomofo'] = 0x3124;
  9612. t['angbracketleft'] = 0x3008;
  9613. t['angbracketright'] = 0x3009;
  9614. t['angkhankhuthai'] = 0x0E5A;
  9615. t['angle'] = 0x2220;
  9616. t['anglebracketleft'] = 0x3008;
  9617. t['anglebracketleftvertical'] = 0xFE3F;
  9618. t['anglebracketright'] = 0x3009;
  9619. t['anglebracketrightvertical'] = 0xFE40;
  9620. t['angleleft'] = 0x2329;
  9621. t['angleright'] = 0x232A;
  9622. t['angstrom'] = 0x212B;
  9623. t['anoteleia'] = 0x0387;
  9624. t['anudattadeva'] = 0x0952;
  9625. t['anusvarabengali'] = 0x0982;
  9626. t['anusvaradeva'] = 0x0902;
  9627. t['anusvaragujarati'] = 0x0A82;
  9628. t['aogonek'] = 0x0105;
  9629. t['apaatosquare'] = 0x3300;
  9630. t['aparen'] = 0x249C;
  9631. t['apostrophearmenian'] = 0x055A;
  9632. t['apostrophemod'] = 0x02BC;
  9633. t['apple'] = 0xF8FF;
  9634. t['approaches'] = 0x2250;
  9635. t['approxequal'] = 0x2248;
  9636. t['approxequalorimage'] = 0x2252;
  9637. t['approximatelyequal'] = 0x2245;
  9638. t['araeaekorean'] = 0x318E;
  9639. t['araeakorean'] = 0x318D;
  9640. t['arc'] = 0x2312;
  9641. t['arighthalfring'] = 0x1E9A;
  9642. t['aring'] = 0x00E5;
  9643. t['aringacute'] = 0x01FB;
  9644. t['aringbelow'] = 0x1E01;
  9645. t['arrowboth'] = 0x2194;
  9646. t['arrowdashdown'] = 0x21E3;
  9647. t['arrowdashleft'] = 0x21E0;
  9648. t['arrowdashright'] = 0x21E2;
  9649. t['arrowdashup'] = 0x21E1;
  9650. t['arrowdblboth'] = 0x21D4;
  9651. t['arrowdbldown'] = 0x21D3;
  9652. t['arrowdblleft'] = 0x21D0;
  9653. t['arrowdblright'] = 0x21D2;
  9654. t['arrowdblup'] = 0x21D1;
  9655. t['arrowdown'] = 0x2193;
  9656. t['arrowdownleft'] = 0x2199;
  9657. t['arrowdownright'] = 0x2198;
  9658. t['arrowdownwhite'] = 0x21E9;
  9659. t['arrowheaddownmod'] = 0x02C5;
  9660. t['arrowheadleftmod'] = 0x02C2;
  9661. t['arrowheadrightmod'] = 0x02C3;
  9662. t['arrowheadupmod'] = 0x02C4;
  9663. t['arrowhorizex'] = 0xF8E7;
  9664. t['arrowleft'] = 0x2190;
  9665. t['arrowleftdbl'] = 0x21D0;
  9666. t['arrowleftdblstroke'] = 0x21CD;
  9667. t['arrowleftoverright'] = 0x21C6;
  9668. t['arrowleftwhite'] = 0x21E6;
  9669. t['arrowright'] = 0x2192;
  9670. t['arrowrightdblstroke'] = 0x21CF;
  9671. t['arrowrightheavy'] = 0x279E;
  9672. t['arrowrightoverleft'] = 0x21C4;
  9673. t['arrowrightwhite'] = 0x21E8;
  9674. t['arrowtableft'] = 0x21E4;
  9675. t['arrowtabright'] = 0x21E5;
  9676. t['arrowup'] = 0x2191;
  9677. t['arrowupdn'] = 0x2195;
  9678. t['arrowupdnbse'] = 0x21A8;
  9679. t['arrowupdownbase'] = 0x21A8;
  9680. t['arrowupleft'] = 0x2196;
  9681. t['arrowupleftofdown'] = 0x21C5;
  9682. t['arrowupright'] = 0x2197;
  9683. t['arrowupwhite'] = 0x21E7;
  9684. t['arrowvertex'] = 0xF8E6;
  9685. t['asciicircum'] = 0x005E;
  9686. t['asciicircummonospace'] = 0xFF3E;
  9687. t['asciitilde'] = 0x007E;
  9688. t['asciitildemonospace'] = 0xFF5E;
  9689. t['ascript'] = 0x0251;
  9690. t['ascriptturned'] = 0x0252;
  9691. t['asmallhiragana'] = 0x3041;
  9692. t['asmallkatakana'] = 0x30A1;
  9693. t['asmallkatakanahalfwidth'] = 0xFF67;
  9694. t['asterisk'] = 0x002A;
  9695. t['asteriskaltonearabic'] = 0x066D;
  9696. t['asteriskarabic'] = 0x066D;
  9697. t['asteriskmath'] = 0x2217;
  9698. t['asteriskmonospace'] = 0xFF0A;
  9699. t['asterisksmall'] = 0xFE61;
  9700. t['asterism'] = 0x2042;
  9701. t['asuperior'] = 0xF6E9;
  9702. t['asymptoticallyequal'] = 0x2243;
  9703. t['at'] = 0x0040;
  9704. t['atilde'] = 0x00E3;
  9705. t['atmonospace'] = 0xFF20;
  9706. t['atsmall'] = 0xFE6B;
  9707. t['aturned'] = 0x0250;
  9708. t['aubengali'] = 0x0994;
  9709. t['aubopomofo'] = 0x3120;
  9710. t['audeva'] = 0x0914;
  9711. t['augujarati'] = 0x0A94;
  9712. t['augurmukhi'] = 0x0A14;
  9713. t['aulengthmarkbengali'] = 0x09D7;
  9714. t['aumatragurmukhi'] = 0x0A4C;
  9715. t['auvowelsignbengali'] = 0x09CC;
  9716. t['auvowelsigndeva'] = 0x094C;
  9717. t['auvowelsigngujarati'] = 0x0ACC;
  9718. t['avagrahadeva'] = 0x093D;
  9719. t['aybarmenian'] = 0x0561;
  9720. t['ayin'] = 0x05E2;
  9721. t['ayinaltonehebrew'] = 0xFB20;
  9722. t['ayinhebrew'] = 0x05E2;
  9723. t['b'] = 0x0062;
  9724. t['babengali'] = 0x09AC;
  9725. t['backslash'] = 0x005C;
  9726. t['backslashmonospace'] = 0xFF3C;
  9727. t['badeva'] = 0x092C;
  9728. t['bagujarati'] = 0x0AAC;
  9729. t['bagurmukhi'] = 0x0A2C;
  9730. t['bahiragana'] = 0x3070;
  9731. t['bahtthai'] = 0x0E3F;
  9732. t['bakatakana'] = 0x30D0;
  9733. t['bar'] = 0x007C;
  9734. t['barmonospace'] = 0xFF5C;
  9735. t['bbopomofo'] = 0x3105;
  9736. t['bcircle'] = 0x24D1;
  9737. t['bdotaccent'] = 0x1E03;
  9738. t['bdotbelow'] = 0x1E05;
  9739. t['beamedsixteenthnotes'] = 0x266C;
  9740. t['because'] = 0x2235;
  9741. t['becyrillic'] = 0x0431;
  9742. t['beharabic'] = 0x0628;
  9743. t['behfinalarabic'] = 0xFE90;
  9744. t['behinitialarabic'] = 0xFE91;
  9745. t['behiragana'] = 0x3079;
  9746. t['behmedialarabic'] = 0xFE92;
  9747. t['behmeeminitialarabic'] = 0xFC9F;
  9748. t['behmeemisolatedarabic'] = 0xFC08;
  9749. t['behnoonfinalarabic'] = 0xFC6D;
  9750. t['bekatakana'] = 0x30D9;
  9751. t['benarmenian'] = 0x0562;
  9752. t['bet'] = 0x05D1;
  9753. t['beta'] = 0x03B2;
  9754. t['betasymbolgreek'] = 0x03D0;
  9755. t['betdagesh'] = 0xFB31;
  9756. t['betdageshhebrew'] = 0xFB31;
  9757. t['bethebrew'] = 0x05D1;
  9758. t['betrafehebrew'] = 0xFB4C;
  9759. t['bhabengali'] = 0x09AD;
  9760. t['bhadeva'] = 0x092D;
  9761. t['bhagujarati'] = 0x0AAD;
  9762. t['bhagurmukhi'] = 0x0A2D;
  9763. t['bhook'] = 0x0253;
  9764. t['bihiragana'] = 0x3073;
  9765. t['bikatakana'] = 0x30D3;
  9766. t['bilabialclick'] = 0x0298;
  9767. t['bindigurmukhi'] = 0x0A02;
  9768. t['birusquare'] = 0x3331;
  9769. t['blackcircle'] = 0x25CF;
  9770. t['blackdiamond'] = 0x25C6;
  9771. t['blackdownpointingtriangle'] = 0x25BC;
  9772. t['blackleftpointingpointer'] = 0x25C4;
  9773. t['blackleftpointingtriangle'] = 0x25C0;
  9774. t['blacklenticularbracketleft'] = 0x3010;
  9775. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  9776. t['blacklenticularbracketright'] = 0x3011;
  9777. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  9778. t['blacklowerlefttriangle'] = 0x25E3;
  9779. t['blacklowerrighttriangle'] = 0x25E2;
  9780. t['blackrectangle'] = 0x25AC;
  9781. t['blackrightpointingpointer'] = 0x25BA;
  9782. t['blackrightpointingtriangle'] = 0x25B6;
  9783. t['blacksmallsquare'] = 0x25AA;
  9784. t['blacksmilingface'] = 0x263B;
  9785. t['blacksquare'] = 0x25A0;
  9786. t['blackstar'] = 0x2605;
  9787. t['blackupperlefttriangle'] = 0x25E4;
  9788. t['blackupperrighttriangle'] = 0x25E5;
  9789. t['blackuppointingsmalltriangle'] = 0x25B4;
  9790. t['blackuppointingtriangle'] = 0x25B2;
  9791. t['blank'] = 0x2423;
  9792. t['blinebelow'] = 0x1E07;
  9793. t['block'] = 0x2588;
  9794. t['bmonospace'] = 0xFF42;
  9795. t['bobaimaithai'] = 0x0E1A;
  9796. t['bohiragana'] = 0x307C;
  9797. t['bokatakana'] = 0x30DC;
  9798. t['bparen'] = 0x249D;
  9799. t['bqsquare'] = 0x33C3;
  9800. t['braceex'] = 0xF8F4;
  9801. t['braceleft'] = 0x007B;
  9802. t['braceleftbt'] = 0xF8F3;
  9803. t['braceleftmid'] = 0xF8F2;
  9804. t['braceleftmonospace'] = 0xFF5B;
  9805. t['braceleftsmall'] = 0xFE5B;
  9806. t['bracelefttp'] = 0xF8F1;
  9807. t['braceleftvertical'] = 0xFE37;
  9808. t['braceright'] = 0x007D;
  9809. t['bracerightbt'] = 0xF8FE;
  9810. t['bracerightmid'] = 0xF8FD;
  9811. t['bracerightmonospace'] = 0xFF5D;
  9812. t['bracerightsmall'] = 0xFE5C;
  9813. t['bracerighttp'] = 0xF8FC;
  9814. t['bracerightvertical'] = 0xFE38;
  9815. t['bracketleft'] = 0x005B;
  9816. t['bracketleftbt'] = 0xF8F0;
  9817. t['bracketleftex'] = 0xF8EF;
  9818. t['bracketleftmonospace'] = 0xFF3B;
  9819. t['bracketlefttp'] = 0xF8EE;
  9820. t['bracketright'] = 0x005D;
  9821. t['bracketrightbt'] = 0xF8FB;
  9822. t['bracketrightex'] = 0xF8FA;
  9823. t['bracketrightmonospace'] = 0xFF3D;
  9824. t['bracketrighttp'] = 0xF8F9;
  9825. t['breve'] = 0x02D8;
  9826. t['brevebelowcmb'] = 0x032E;
  9827. t['brevecmb'] = 0x0306;
  9828. t['breveinvertedbelowcmb'] = 0x032F;
  9829. t['breveinvertedcmb'] = 0x0311;
  9830. t['breveinverteddoublecmb'] = 0x0361;
  9831. t['bridgebelowcmb'] = 0x032A;
  9832. t['bridgeinvertedbelowcmb'] = 0x033A;
  9833. t['brokenbar'] = 0x00A6;
  9834. t['bstroke'] = 0x0180;
  9835. t['bsuperior'] = 0xF6EA;
  9836. t['btopbar'] = 0x0183;
  9837. t['buhiragana'] = 0x3076;
  9838. t['bukatakana'] = 0x30D6;
  9839. t['bullet'] = 0x2022;
  9840. t['bulletinverse'] = 0x25D8;
  9841. t['bulletoperator'] = 0x2219;
  9842. t['bullseye'] = 0x25CE;
  9843. t['c'] = 0x0063;
  9844. t['caarmenian'] = 0x056E;
  9845. t['cabengali'] = 0x099A;
  9846. t['cacute'] = 0x0107;
  9847. t['cadeva'] = 0x091A;
  9848. t['cagujarati'] = 0x0A9A;
  9849. t['cagurmukhi'] = 0x0A1A;
  9850. t['calsquare'] = 0x3388;
  9851. t['candrabindubengali'] = 0x0981;
  9852. t['candrabinducmb'] = 0x0310;
  9853. t['candrabindudeva'] = 0x0901;
  9854. t['candrabindugujarati'] = 0x0A81;
  9855. t['capslock'] = 0x21EA;
  9856. t['careof'] = 0x2105;
  9857. t['caron'] = 0x02C7;
  9858. t['caronbelowcmb'] = 0x032C;
  9859. t['caroncmb'] = 0x030C;
  9860. t['carriagereturn'] = 0x21B5;
  9861. t['cbopomofo'] = 0x3118;
  9862. t['ccaron'] = 0x010D;
  9863. t['ccedilla'] = 0x00E7;
  9864. t['ccedillaacute'] = 0x1E09;
  9865. t['ccircle'] = 0x24D2;
  9866. t['ccircumflex'] = 0x0109;
  9867. t['ccurl'] = 0x0255;
  9868. t['cdot'] = 0x010B;
  9869. t['cdotaccent'] = 0x010B;
  9870. t['cdsquare'] = 0x33C5;
  9871. t['cedilla'] = 0x00B8;
  9872. t['cedillacmb'] = 0x0327;
  9873. t['cent'] = 0x00A2;
  9874. t['centigrade'] = 0x2103;
  9875. t['centinferior'] = 0xF6DF;
  9876. t['centmonospace'] = 0xFFE0;
  9877. t['centoldstyle'] = 0xF7A2;
  9878. t['centsuperior'] = 0xF6E0;
  9879. t['chaarmenian'] = 0x0579;
  9880. t['chabengali'] = 0x099B;
  9881. t['chadeva'] = 0x091B;
  9882. t['chagujarati'] = 0x0A9B;
  9883. t['chagurmukhi'] = 0x0A1B;
  9884. t['chbopomofo'] = 0x3114;
  9885. t['cheabkhasiancyrillic'] = 0x04BD;
  9886. t['checkmark'] = 0x2713;
  9887. t['checyrillic'] = 0x0447;
  9888. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  9889. t['chedescendercyrillic'] = 0x04B7;
  9890. t['chedieresiscyrillic'] = 0x04F5;
  9891. t['cheharmenian'] = 0x0573;
  9892. t['chekhakassiancyrillic'] = 0x04CC;
  9893. t['cheverticalstrokecyrillic'] = 0x04B9;
  9894. t['chi'] = 0x03C7;
  9895. t['chieuchacirclekorean'] = 0x3277;
  9896. t['chieuchaparenkorean'] = 0x3217;
  9897. t['chieuchcirclekorean'] = 0x3269;
  9898. t['chieuchkorean'] = 0x314A;
  9899. t['chieuchparenkorean'] = 0x3209;
  9900. t['chochangthai'] = 0x0E0A;
  9901. t['chochanthai'] = 0x0E08;
  9902. t['chochingthai'] = 0x0E09;
  9903. t['chochoethai'] = 0x0E0C;
  9904. t['chook'] = 0x0188;
  9905. t['cieucacirclekorean'] = 0x3276;
  9906. t['cieucaparenkorean'] = 0x3216;
  9907. t['cieuccirclekorean'] = 0x3268;
  9908. t['cieuckorean'] = 0x3148;
  9909. t['cieucparenkorean'] = 0x3208;
  9910. t['cieucuparenkorean'] = 0x321C;
  9911. t['circle'] = 0x25CB;
  9912. t['circlecopyrt'] = 0x00A9;
  9913. t['circlemultiply'] = 0x2297;
  9914. t['circleot'] = 0x2299;
  9915. t['circleplus'] = 0x2295;
  9916. t['circlepostalmark'] = 0x3036;
  9917. t['circlewithlefthalfblack'] = 0x25D0;
  9918. t['circlewithrighthalfblack'] = 0x25D1;
  9919. t['circumflex'] = 0x02C6;
  9920. t['circumflexbelowcmb'] = 0x032D;
  9921. t['circumflexcmb'] = 0x0302;
  9922. t['clear'] = 0x2327;
  9923. t['clickalveolar'] = 0x01C2;
  9924. t['clickdental'] = 0x01C0;
  9925. t['clicklateral'] = 0x01C1;
  9926. t['clickretroflex'] = 0x01C3;
  9927. t['club'] = 0x2663;
  9928. t['clubsuitblack'] = 0x2663;
  9929. t['clubsuitwhite'] = 0x2667;
  9930. t['cmcubedsquare'] = 0x33A4;
  9931. t['cmonospace'] = 0xFF43;
  9932. t['cmsquaredsquare'] = 0x33A0;
  9933. t['coarmenian'] = 0x0581;
  9934. t['colon'] = 0x003A;
  9935. t['colonmonetary'] = 0x20A1;
  9936. t['colonmonospace'] = 0xFF1A;
  9937. t['colonsign'] = 0x20A1;
  9938. t['colonsmall'] = 0xFE55;
  9939. t['colontriangularhalfmod'] = 0x02D1;
  9940. t['colontriangularmod'] = 0x02D0;
  9941. t['comma'] = 0x002C;
  9942. t['commaabovecmb'] = 0x0313;
  9943. t['commaaboverightcmb'] = 0x0315;
  9944. t['commaaccent'] = 0xF6C3;
  9945. t['commaarabic'] = 0x060C;
  9946. t['commaarmenian'] = 0x055D;
  9947. t['commainferior'] = 0xF6E1;
  9948. t['commamonospace'] = 0xFF0C;
  9949. t['commareversedabovecmb'] = 0x0314;
  9950. t['commareversedmod'] = 0x02BD;
  9951. t['commasmall'] = 0xFE50;
  9952. t['commasuperior'] = 0xF6E2;
  9953. t['commaturnedabovecmb'] = 0x0312;
  9954. t['commaturnedmod'] = 0x02BB;
  9955. t['compass'] = 0x263C;
  9956. t['congruent'] = 0x2245;
  9957. t['contourintegral'] = 0x222E;
  9958. t['control'] = 0x2303;
  9959. t['controlACK'] = 0x0006;
  9960. t['controlBEL'] = 0x0007;
  9961. t['controlBS'] = 0x0008;
  9962. t['controlCAN'] = 0x0018;
  9963. t['controlCR'] = 0x000D;
  9964. t['controlDC1'] = 0x0011;
  9965. t['controlDC2'] = 0x0012;
  9966. t['controlDC3'] = 0x0013;
  9967. t['controlDC4'] = 0x0014;
  9968. t['controlDEL'] = 0x007F;
  9969. t['controlDLE'] = 0x0010;
  9970. t['controlEM'] = 0x0019;
  9971. t['controlENQ'] = 0x0005;
  9972. t['controlEOT'] = 0x0004;
  9973. t['controlESC'] = 0x001B;
  9974. t['controlETB'] = 0x0017;
  9975. t['controlETX'] = 0x0003;
  9976. t['controlFF'] = 0x000C;
  9977. t['controlFS'] = 0x001C;
  9978. t['controlGS'] = 0x001D;
  9979. t['controlHT'] = 0x0009;
  9980. t['controlLF'] = 0x000A;
  9981. t['controlNAK'] = 0x0015;
  9982. t['controlNULL'] = 0x0000;
  9983. t['controlRS'] = 0x001E;
  9984. t['controlSI'] = 0x000F;
  9985. t['controlSO'] = 0x000E;
  9986. t['controlSOT'] = 0x0002;
  9987. t['controlSTX'] = 0x0001;
  9988. t['controlSUB'] = 0x001A;
  9989. t['controlSYN'] = 0x0016;
  9990. t['controlUS'] = 0x001F;
  9991. t['controlVT'] = 0x000B;
  9992. t['copyright'] = 0x00A9;
  9993. t['copyrightsans'] = 0xF8E9;
  9994. t['copyrightserif'] = 0xF6D9;
  9995. t['cornerbracketleft'] = 0x300C;
  9996. t['cornerbracketlefthalfwidth'] = 0xFF62;
  9997. t['cornerbracketleftvertical'] = 0xFE41;
  9998. t['cornerbracketright'] = 0x300D;
  9999. t['cornerbracketrighthalfwidth'] = 0xFF63;
  10000. t['cornerbracketrightvertical'] = 0xFE42;
  10001. t['corporationsquare'] = 0x337F;
  10002. t['cosquare'] = 0x33C7;
  10003. t['coverkgsquare'] = 0x33C6;
  10004. t['cparen'] = 0x249E;
  10005. t['cruzeiro'] = 0x20A2;
  10006. t['cstretched'] = 0x0297;
  10007. t['curlyand'] = 0x22CF;
  10008. t['curlyor'] = 0x22CE;
  10009. t['currency'] = 0x00A4;
  10010. t['cyrBreve'] = 0xF6D1;
  10011. t['cyrFlex'] = 0xF6D2;
  10012. t['cyrbreve'] = 0xF6D4;
  10013. t['cyrflex'] = 0xF6D5;
  10014. t['d'] = 0x0064;
  10015. t['daarmenian'] = 0x0564;
  10016. t['dabengali'] = 0x09A6;
  10017. t['dadarabic'] = 0x0636;
  10018. t['dadeva'] = 0x0926;
  10019. t['dadfinalarabic'] = 0xFEBE;
  10020. t['dadinitialarabic'] = 0xFEBF;
  10021. t['dadmedialarabic'] = 0xFEC0;
  10022. t['dagesh'] = 0x05BC;
  10023. t['dageshhebrew'] = 0x05BC;
  10024. t['dagger'] = 0x2020;
  10025. t['daggerdbl'] = 0x2021;
  10026. t['dagujarati'] = 0x0AA6;
  10027. t['dagurmukhi'] = 0x0A26;
  10028. t['dahiragana'] = 0x3060;
  10029. t['dakatakana'] = 0x30C0;
  10030. t['dalarabic'] = 0x062F;
  10031. t['dalet'] = 0x05D3;
  10032. t['daletdagesh'] = 0xFB33;
  10033. t['daletdageshhebrew'] = 0xFB33;
  10034. t['dalethebrew'] = 0x05D3;
  10035. t['dalfinalarabic'] = 0xFEAA;
  10036. t['dammaarabic'] = 0x064F;
  10037. t['dammalowarabic'] = 0x064F;
  10038. t['dammatanaltonearabic'] = 0x064C;
  10039. t['dammatanarabic'] = 0x064C;
  10040. t['danda'] = 0x0964;
  10041. t['dargahebrew'] = 0x05A7;
  10042. t['dargalefthebrew'] = 0x05A7;
  10043. t['dasiapneumatacyrilliccmb'] = 0x0485;
  10044. t['dblGrave'] = 0xF6D3;
  10045. t['dblanglebracketleft'] = 0x300A;
  10046. t['dblanglebracketleftvertical'] = 0xFE3D;
  10047. t['dblanglebracketright'] = 0x300B;
  10048. t['dblanglebracketrightvertical'] = 0xFE3E;
  10049. t['dblarchinvertedbelowcmb'] = 0x032B;
  10050. t['dblarrowleft'] = 0x21D4;
  10051. t['dblarrowright'] = 0x21D2;
  10052. t['dbldanda'] = 0x0965;
  10053. t['dblgrave'] = 0xF6D6;
  10054. t['dblgravecmb'] = 0x030F;
  10055. t['dblintegral'] = 0x222C;
  10056. t['dbllowline'] = 0x2017;
  10057. t['dbllowlinecmb'] = 0x0333;
  10058. t['dbloverlinecmb'] = 0x033F;
  10059. t['dblprimemod'] = 0x02BA;
  10060. t['dblverticalbar'] = 0x2016;
  10061. t['dblverticallineabovecmb'] = 0x030E;
  10062. t['dbopomofo'] = 0x3109;
  10063. t['dbsquare'] = 0x33C8;
  10064. t['dcaron'] = 0x010F;
  10065. t['dcedilla'] = 0x1E11;
  10066. t['dcircle'] = 0x24D3;
  10067. t['dcircumflexbelow'] = 0x1E13;
  10068. t['dcroat'] = 0x0111;
  10069. t['ddabengali'] = 0x09A1;
  10070. t['ddadeva'] = 0x0921;
  10071. t['ddagujarati'] = 0x0AA1;
  10072. t['ddagurmukhi'] = 0x0A21;
  10073. t['ddalarabic'] = 0x0688;
  10074. t['ddalfinalarabic'] = 0xFB89;
  10075. t['dddhadeva'] = 0x095C;
  10076. t['ddhabengali'] = 0x09A2;
  10077. t['ddhadeva'] = 0x0922;
  10078. t['ddhagujarati'] = 0x0AA2;
  10079. t['ddhagurmukhi'] = 0x0A22;
  10080. t['ddotaccent'] = 0x1E0B;
  10081. t['ddotbelow'] = 0x1E0D;
  10082. t['decimalseparatorarabic'] = 0x066B;
  10083. t['decimalseparatorpersian'] = 0x066B;
  10084. t['decyrillic'] = 0x0434;
  10085. t['degree'] = 0x00B0;
  10086. t['dehihebrew'] = 0x05AD;
  10087. t['dehiragana'] = 0x3067;
  10088. t['deicoptic'] = 0x03EF;
  10089. t['dekatakana'] = 0x30C7;
  10090. t['deleteleft'] = 0x232B;
  10091. t['deleteright'] = 0x2326;
  10092. t['delta'] = 0x03B4;
  10093. t['deltaturned'] = 0x018D;
  10094. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  10095. t['dezh'] = 0x02A4;
  10096. t['dhabengali'] = 0x09A7;
  10097. t['dhadeva'] = 0x0927;
  10098. t['dhagujarati'] = 0x0AA7;
  10099. t['dhagurmukhi'] = 0x0A27;
  10100. t['dhook'] = 0x0257;
  10101. t['dialytikatonos'] = 0x0385;
  10102. t['dialytikatonoscmb'] = 0x0344;
  10103. t['diamond'] = 0x2666;
  10104. t['diamondsuitwhite'] = 0x2662;
  10105. t['dieresis'] = 0x00A8;
  10106. t['dieresisacute'] = 0xF6D7;
  10107. t['dieresisbelowcmb'] = 0x0324;
  10108. t['dieresiscmb'] = 0x0308;
  10109. t['dieresisgrave'] = 0xF6D8;
  10110. t['dieresistonos'] = 0x0385;
  10111. t['dihiragana'] = 0x3062;
  10112. t['dikatakana'] = 0x30C2;
  10113. t['dittomark'] = 0x3003;
  10114. t['divide'] = 0x00F7;
  10115. t['divides'] = 0x2223;
  10116. t['divisionslash'] = 0x2215;
  10117. t['djecyrillic'] = 0x0452;
  10118. t['dkshade'] = 0x2593;
  10119. t['dlinebelow'] = 0x1E0F;
  10120. t['dlsquare'] = 0x3397;
  10121. t['dmacron'] = 0x0111;
  10122. t['dmonospace'] = 0xFF44;
  10123. t['dnblock'] = 0x2584;
  10124. t['dochadathai'] = 0x0E0E;
  10125. t['dodekthai'] = 0x0E14;
  10126. t['dohiragana'] = 0x3069;
  10127. t['dokatakana'] = 0x30C9;
  10128. t['dollar'] = 0x0024;
  10129. t['dollarinferior'] = 0xF6E3;
  10130. t['dollarmonospace'] = 0xFF04;
  10131. t['dollaroldstyle'] = 0xF724;
  10132. t['dollarsmall'] = 0xFE69;
  10133. t['dollarsuperior'] = 0xF6E4;
  10134. t['dong'] = 0x20AB;
  10135. t['dorusquare'] = 0x3326;
  10136. t['dotaccent'] = 0x02D9;
  10137. t['dotaccentcmb'] = 0x0307;
  10138. t['dotbelowcmb'] = 0x0323;
  10139. t['dotbelowcomb'] = 0x0323;
  10140. t['dotkatakana'] = 0x30FB;
  10141. t['dotlessi'] = 0x0131;
  10142. t['dotlessj'] = 0xF6BE;
  10143. t['dotlessjstrokehook'] = 0x0284;
  10144. t['dotmath'] = 0x22C5;
  10145. t['dottedcircle'] = 0x25CC;
  10146. t['doubleyodpatah'] = 0xFB1F;
  10147. t['doubleyodpatahhebrew'] = 0xFB1F;
  10148. t['downtackbelowcmb'] = 0x031E;
  10149. t['downtackmod'] = 0x02D5;
  10150. t['dparen'] = 0x249F;
  10151. t['dsuperior'] = 0xF6EB;
  10152. t['dtail'] = 0x0256;
  10153. t['dtopbar'] = 0x018C;
  10154. t['duhiragana'] = 0x3065;
  10155. t['dukatakana'] = 0x30C5;
  10156. t['dz'] = 0x01F3;
  10157. t['dzaltone'] = 0x02A3;
  10158. t['dzcaron'] = 0x01C6;
  10159. t['dzcurl'] = 0x02A5;
  10160. t['dzeabkhasiancyrillic'] = 0x04E1;
  10161. t['dzecyrillic'] = 0x0455;
  10162. t['dzhecyrillic'] = 0x045F;
  10163. t['e'] = 0x0065;
  10164. t['eacute'] = 0x00E9;
  10165. t['earth'] = 0x2641;
  10166. t['ebengali'] = 0x098F;
  10167. t['ebopomofo'] = 0x311C;
  10168. t['ebreve'] = 0x0115;
  10169. t['ecandradeva'] = 0x090D;
  10170. t['ecandragujarati'] = 0x0A8D;
  10171. t['ecandravowelsigndeva'] = 0x0945;
  10172. t['ecandravowelsigngujarati'] = 0x0AC5;
  10173. t['ecaron'] = 0x011B;
  10174. t['ecedillabreve'] = 0x1E1D;
  10175. t['echarmenian'] = 0x0565;
  10176. t['echyiwnarmenian'] = 0x0587;
  10177. t['ecircle'] = 0x24D4;
  10178. t['ecircumflex'] = 0x00EA;
  10179. t['ecircumflexacute'] = 0x1EBF;
  10180. t['ecircumflexbelow'] = 0x1E19;
  10181. t['ecircumflexdotbelow'] = 0x1EC7;
  10182. t['ecircumflexgrave'] = 0x1EC1;
  10183. t['ecircumflexhookabove'] = 0x1EC3;
  10184. t['ecircumflextilde'] = 0x1EC5;
  10185. t['ecyrillic'] = 0x0454;
  10186. t['edblgrave'] = 0x0205;
  10187. t['edeva'] = 0x090F;
  10188. t['edieresis'] = 0x00EB;
  10189. t['edot'] = 0x0117;
  10190. t['edotaccent'] = 0x0117;
  10191. t['edotbelow'] = 0x1EB9;
  10192. t['eegurmukhi'] = 0x0A0F;
  10193. t['eematragurmukhi'] = 0x0A47;
  10194. t['efcyrillic'] = 0x0444;
  10195. t['egrave'] = 0x00E8;
  10196. t['egujarati'] = 0x0A8F;
  10197. t['eharmenian'] = 0x0567;
  10198. t['ehbopomofo'] = 0x311D;
  10199. t['ehiragana'] = 0x3048;
  10200. t['ehookabove'] = 0x1EBB;
  10201. t['eibopomofo'] = 0x311F;
  10202. t['eight'] = 0x0038;
  10203. t['eightarabic'] = 0x0668;
  10204. t['eightbengali'] = 0x09EE;
  10205. t['eightcircle'] = 0x2467;
  10206. t['eightcircleinversesansserif'] = 0x2791;
  10207. t['eightdeva'] = 0x096E;
  10208. t['eighteencircle'] = 0x2471;
  10209. t['eighteenparen'] = 0x2485;
  10210. t['eighteenperiod'] = 0x2499;
  10211. t['eightgujarati'] = 0x0AEE;
  10212. t['eightgurmukhi'] = 0x0A6E;
  10213. t['eighthackarabic'] = 0x0668;
  10214. t['eighthangzhou'] = 0x3028;
  10215. t['eighthnotebeamed'] = 0x266B;
  10216. t['eightideographicparen'] = 0x3227;
  10217. t['eightinferior'] = 0x2088;
  10218. t['eightmonospace'] = 0xFF18;
  10219. t['eightoldstyle'] = 0xF738;
  10220. t['eightparen'] = 0x247B;
  10221. t['eightperiod'] = 0x248F;
  10222. t['eightpersian'] = 0x06F8;
  10223. t['eightroman'] = 0x2177;
  10224. t['eightsuperior'] = 0x2078;
  10225. t['eightthai'] = 0x0E58;
  10226. t['einvertedbreve'] = 0x0207;
  10227. t['eiotifiedcyrillic'] = 0x0465;
  10228. t['ekatakana'] = 0x30A8;
  10229. t['ekatakanahalfwidth'] = 0xFF74;
  10230. t['ekonkargurmukhi'] = 0x0A74;
  10231. t['ekorean'] = 0x3154;
  10232. t['elcyrillic'] = 0x043B;
  10233. t['element'] = 0x2208;
  10234. t['elevencircle'] = 0x246A;
  10235. t['elevenparen'] = 0x247E;
  10236. t['elevenperiod'] = 0x2492;
  10237. t['elevenroman'] = 0x217A;
  10238. t['ellipsis'] = 0x2026;
  10239. t['ellipsisvertical'] = 0x22EE;
  10240. t['emacron'] = 0x0113;
  10241. t['emacronacute'] = 0x1E17;
  10242. t['emacrongrave'] = 0x1E15;
  10243. t['emcyrillic'] = 0x043C;
  10244. t['emdash'] = 0x2014;
  10245. t['emdashvertical'] = 0xFE31;
  10246. t['emonospace'] = 0xFF45;
  10247. t['emphasismarkarmenian'] = 0x055B;
  10248. t['emptyset'] = 0x2205;
  10249. t['enbopomofo'] = 0x3123;
  10250. t['encyrillic'] = 0x043D;
  10251. t['endash'] = 0x2013;
  10252. t['endashvertical'] = 0xFE32;
  10253. t['endescendercyrillic'] = 0x04A3;
  10254. t['eng'] = 0x014B;
  10255. t['engbopomofo'] = 0x3125;
  10256. t['enghecyrillic'] = 0x04A5;
  10257. t['enhookcyrillic'] = 0x04C8;
  10258. t['enspace'] = 0x2002;
  10259. t['eogonek'] = 0x0119;
  10260. t['eokorean'] = 0x3153;
  10261. t['eopen'] = 0x025B;
  10262. t['eopenclosed'] = 0x029A;
  10263. t['eopenreversed'] = 0x025C;
  10264. t['eopenreversedclosed'] = 0x025E;
  10265. t['eopenreversedhook'] = 0x025D;
  10266. t['eparen'] = 0x24A0;
  10267. t['epsilon'] = 0x03B5;
  10268. t['epsilontonos'] = 0x03AD;
  10269. t['equal'] = 0x003D;
  10270. t['equalmonospace'] = 0xFF1D;
  10271. t['equalsmall'] = 0xFE66;
  10272. t['equalsuperior'] = 0x207C;
  10273. t['equivalence'] = 0x2261;
  10274. t['erbopomofo'] = 0x3126;
  10275. t['ercyrillic'] = 0x0440;
  10276. t['ereversed'] = 0x0258;
  10277. t['ereversedcyrillic'] = 0x044D;
  10278. t['escyrillic'] = 0x0441;
  10279. t['esdescendercyrillic'] = 0x04AB;
  10280. t['esh'] = 0x0283;
  10281. t['eshcurl'] = 0x0286;
  10282. t['eshortdeva'] = 0x090E;
  10283. t['eshortvowelsigndeva'] = 0x0946;
  10284. t['eshreversedloop'] = 0x01AA;
  10285. t['eshsquatreversed'] = 0x0285;
  10286. t['esmallhiragana'] = 0x3047;
  10287. t['esmallkatakana'] = 0x30A7;
  10288. t['esmallkatakanahalfwidth'] = 0xFF6A;
  10289. t['estimated'] = 0x212E;
  10290. t['esuperior'] = 0xF6EC;
  10291. t['eta'] = 0x03B7;
  10292. t['etarmenian'] = 0x0568;
  10293. t['etatonos'] = 0x03AE;
  10294. t['eth'] = 0x00F0;
  10295. t['etilde'] = 0x1EBD;
  10296. t['etildebelow'] = 0x1E1B;
  10297. t['etnahtafoukhhebrew'] = 0x0591;
  10298. t['etnahtafoukhlefthebrew'] = 0x0591;
  10299. t['etnahtahebrew'] = 0x0591;
  10300. t['etnahtalefthebrew'] = 0x0591;
  10301. t['eturned'] = 0x01DD;
  10302. t['eukorean'] = 0x3161;
  10303. t['euro'] = 0x20AC;
  10304. t['evowelsignbengali'] = 0x09C7;
  10305. t['evowelsigndeva'] = 0x0947;
  10306. t['evowelsigngujarati'] = 0x0AC7;
  10307. t['exclam'] = 0x0021;
  10308. t['exclamarmenian'] = 0x055C;
  10309. t['exclamdbl'] = 0x203C;
  10310. t['exclamdown'] = 0x00A1;
  10311. t['exclamdownsmall'] = 0xF7A1;
  10312. t['exclammonospace'] = 0xFF01;
  10313. t['exclamsmall'] = 0xF721;
  10314. t['existential'] = 0x2203;
  10315. t['ezh'] = 0x0292;
  10316. t['ezhcaron'] = 0x01EF;
  10317. t['ezhcurl'] = 0x0293;
  10318. t['ezhreversed'] = 0x01B9;
  10319. t['ezhtail'] = 0x01BA;
  10320. t['f'] = 0x0066;
  10321. t['fadeva'] = 0x095E;
  10322. t['fagurmukhi'] = 0x0A5E;
  10323. t['fahrenheit'] = 0x2109;
  10324. t['fathaarabic'] = 0x064E;
  10325. t['fathalowarabic'] = 0x064E;
  10326. t['fathatanarabic'] = 0x064B;
  10327. t['fbopomofo'] = 0x3108;
  10328. t['fcircle'] = 0x24D5;
  10329. t['fdotaccent'] = 0x1E1F;
  10330. t['feharabic'] = 0x0641;
  10331. t['feharmenian'] = 0x0586;
  10332. t['fehfinalarabic'] = 0xFED2;
  10333. t['fehinitialarabic'] = 0xFED3;
  10334. t['fehmedialarabic'] = 0xFED4;
  10335. t['feicoptic'] = 0x03E5;
  10336. t['female'] = 0x2640;
  10337. t['ff'] = 0xFB00;
  10338. t['ffi'] = 0xFB03;
  10339. t['ffl'] = 0xFB04;
  10340. t['fi'] = 0xFB01;
  10341. t['fifteencircle'] = 0x246E;
  10342. t['fifteenparen'] = 0x2482;
  10343. t['fifteenperiod'] = 0x2496;
  10344. t['figuredash'] = 0x2012;
  10345. t['filledbox'] = 0x25A0;
  10346. t['filledrect'] = 0x25AC;
  10347. t['finalkaf'] = 0x05DA;
  10348. t['finalkafdagesh'] = 0xFB3A;
  10349. t['finalkafdageshhebrew'] = 0xFB3A;
  10350. t['finalkafhebrew'] = 0x05DA;
  10351. t['finalmem'] = 0x05DD;
  10352. t['finalmemhebrew'] = 0x05DD;
  10353. t['finalnun'] = 0x05DF;
  10354. t['finalnunhebrew'] = 0x05DF;
  10355. t['finalpe'] = 0x05E3;
  10356. t['finalpehebrew'] = 0x05E3;
  10357. t['finaltsadi'] = 0x05E5;
  10358. t['finaltsadihebrew'] = 0x05E5;
  10359. t['firsttonechinese'] = 0x02C9;
  10360. t['fisheye'] = 0x25C9;
  10361. t['fitacyrillic'] = 0x0473;
  10362. t['five'] = 0x0035;
  10363. t['fivearabic'] = 0x0665;
  10364. t['fivebengali'] = 0x09EB;
  10365. t['fivecircle'] = 0x2464;
  10366. t['fivecircleinversesansserif'] = 0x278E;
  10367. t['fivedeva'] = 0x096B;
  10368. t['fiveeighths'] = 0x215D;
  10369. t['fivegujarati'] = 0x0AEB;
  10370. t['fivegurmukhi'] = 0x0A6B;
  10371. t['fivehackarabic'] = 0x0665;
  10372. t['fivehangzhou'] = 0x3025;
  10373. t['fiveideographicparen'] = 0x3224;
  10374. t['fiveinferior'] = 0x2085;
  10375. t['fivemonospace'] = 0xFF15;
  10376. t['fiveoldstyle'] = 0xF735;
  10377. t['fiveparen'] = 0x2478;
  10378. t['fiveperiod'] = 0x248C;
  10379. t['fivepersian'] = 0x06F5;
  10380. t['fiveroman'] = 0x2174;
  10381. t['fivesuperior'] = 0x2075;
  10382. t['fivethai'] = 0x0E55;
  10383. t['fl'] = 0xFB02;
  10384. t['florin'] = 0x0192;
  10385. t['fmonospace'] = 0xFF46;
  10386. t['fmsquare'] = 0x3399;
  10387. t['fofanthai'] = 0x0E1F;
  10388. t['fofathai'] = 0x0E1D;
  10389. t['fongmanthai'] = 0x0E4F;
  10390. t['forall'] = 0x2200;
  10391. t['four'] = 0x0034;
  10392. t['fourarabic'] = 0x0664;
  10393. t['fourbengali'] = 0x09EA;
  10394. t['fourcircle'] = 0x2463;
  10395. t['fourcircleinversesansserif'] = 0x278D;
  10396. t['fourdeva'] = 0x096A;
  10397. t['fourgujarati'] = 0x0AEA;
  10398. t['fourgurmukhi'] = 0x0A6A;
  10399. t['fourhackarabic'] = 0x0664;
  10400. t['fourhangzhou'] = 0x3024;
  10401. t['fourideographicparen'] = 0x3223;
  10402. t['fourinferior'] = 0x2084;
  10403. t['fourmonospace'] = 0xFF14;
  10404. t['fournumeratorbengali'] = 0x09F7;
  10405. t['fouroldstyle'] = 0xF734;
  10406. t['fourparen'] = 0x2477;
  10407. t['fourperiod'] = 0x248B;
  10408. t['fourpersian'] = 0x06F4;
  10409. t['fourroman'] = 0x2173;
  10410. t['foursuperior'] = 0x2074;
  10411. t['fourteencircle'] = 0x246D;
  10412. t['fourteenparen'] = 0x2481;
  10413. t['fourteenperiod'] = 0x2495;
  10414. t['fourthai'] = 0x0E54;
  10415. t['fourthtonechinese'] = 0x02CB;
  10416. t['fparen'] = 0x24A1;
  10417. t['fraction'] = 0x2044;
  10418. t['franc'] = 0x20A3;
  10419. t['g'] = 0x0067;
  10420. t['gabengali'] = 0x0997;
  10421. t['gacute'] = 0x01F5;
  10422. t['gadeva'] = 0x0917;
  10423. t['gafarabic'] = 0x06AF;
  10424. t['gaffinalarabic'] = 0xFB93;
  10425. t['gafinitialarabic'] = 0xFB94;
  10426. t['gafmedialarabic'] = 0xFB95;
  10427. t['gagujarati'] = 0x0A97;
  10428. t['gagurmukhi'] = 0x0A17;
  10429. t['gahiragana'] = 0x304C;
  10430. t['gakatakana'] = 0x30AC;
  10431. t['gamma'] = 0x03B3;
  10432. t['gammalatinsmall'] = 0x0263;
  10433. t['gammasuperior'] = 0x02E0;
  10434. t['gangiacoptic'] = 0x03EB;
  10435. t['gbopomofo'] = 0x310D;
  10436. t['gbreve'] = 0x011F;
  10437. t['gcaron'] = 0x01E7;
  10438. t['gcedilla'] = 0x0123;
  10439. t['gcircle'] = 0x24D6;
  10440. t['gcircumflex'] = 0x011D;
  10441. t['gcommaaccent'] = 0x0123;
  10442. t['gdot'] = 0x0121;
  10443. t['gdotaccent'] = 0x0121;
  10444. t['gecyrillic'] = 0x0433;
  10445. t['gehiragana'] = 0x3052;
  10446. t['gekatakana'] = 0x30B2;
  10447. t['geometricallyequal'] = 0x2251;
  10448. t['gereshaccenthebrew'] = 0x059C;
  10449. t['gereshhebrew'] = 0x05F3;
  10450. t['gereshmuqdamhebrew'] = 0x059D;
  10451. t['germandbls'] = 0x00DF;
  10452. t['gershayimaccenthebrew'] = 0x059E;
  10453. t['gershayimhebrew'] = 0x05F4;
  10454. t['getamark'] = 0x3013;
  10455. t['ghabengali'] = 0x0998;
  10456. t['ghadarmenian'] = 0x0572;
  10457. t['ghadeva'] = 0x0918;
  10458. t['ghagujarati'] = 0x0A98;
  10459. t['ghagurmukhi'] = 0x0A18;
  10460. t['ghainarabic'] = 0x063A;
  10461. t['ghainfinalarabic'] = 0xFECE;
  10462. t['ghaininitialarabic'] = 0xFECF;
  10463. t['ghainmedialarabic'] = 0xFED0;
  10464. t['ghemiddlehookcyrillic'] = 0x0495;
  10465. t['ghestrokecyrillic'] = 0x0493;
  10466. t['gheupturncyrillic'] = 0x0491;
  10467. t['ghhadeva'] = 0x095A;
  10468. t['ghhagurmukhi'] = 0x0A5A;
  10469. t['ghook'] = 0x0260;
  10470. t['ghzsquare'] = 0x3393;
  10471. t['gihiragana'] = 0x304E;
  10472. t['gikatakana'] = 0x30AE;
  10473. t['gimarmenian'] = 0x0563;
  10474. t['gimel'] = 0x05D2;
  10475. t['gimeldagesh'] = 0xFB32;
  10476. t['gimeldageshhebrew'] = 0xFB32;
  10477. t['gimelhebrew'] = 0x05D2;
  10478. t['gjecyrillic'] = 0x0453;
  10479. t['glottalinvertedstroke'] = 0x01BE;
  10480. t['glottalstop'] = 0x0294;
  10481. t['glottalstopinverted'] = 0x0296;
  10482. t['glottalstopmod'] = 0x02C0;
  10483. t['glottalstopreversed'] = 0x0295;
  10484. t['glottalstopreversedmod'] = 0x02C1;
  10485. t['glottalstopreversedsuperior'] = 0x02E4;
  10486. t['glottalstopstroke'] = 0x02A1;
  10487. t['glottalstopstrokereversed'] = 0x02A2;
  10488. t['gmacron'] = 0x1E21;
  10489. t['gmonospace'] = 0xFF47;
  10490. t['gohiragana'] = 0x3054;
  10491. t['gokatakana'] = 0x30B4;
  10492. t['gparen'] = 0x24A2;
  10493. t['gpasquare'] = 0x33AC;
  10494. t['gradient'] = 0x2207;
  10495. t['grave'] = 0x0060;
  10496. t['gravebelowcmb'] = 0x0316;
  10497. t['gravecmb'] = 0x0300;
  10498. t['gravecomb'] = 0x0300;
  10499. t['gravedeva'] = 0x0953;
  10500. t['gravelowmod'] = 0x02CE;
  10501. t['gravemonospace'] = 0xFF40;
  10502. t['gravetonecmb'] = 0x0340;
  10503. t['greater'] = 0x003E;
  10504. t['greaterequal'] = 0x2265;
  10505. t['greaterequalorless'] = 0x22DB;
  10506. t['greatermonospace'] = 0xFF1E;
  10507. t['greaterorequivalent'] = 0x2273;
  10508. t['greaterorless'] = 0x2277;
  10509. t['greateroverequal'] = 0x2267;
  10510. t['greatersmall'] = 0xFE65;
  10511. t['gscript'] = 0x0261;
  10512. t['gstroke'] = 0x01E5;
  10513. t['guhiragana'] = 0x3050;
  10514. t['guillemotleft'] = 0x00AB;
  10515. t['guillemotright'] = 0x00BB;
  10516. t['guilsinglleft'] = 0x2039;
  10517. t['guilsinglright'] = 0x203A;
  10518. t['gukatakana'] = 0x30B0;
  10519. t['guramusquare'] = 0x3318;
  10520. t['gysquare'] = 0x33C9;
  10521. t['h'] = 0x0068;
  10522. t['haabkhasiancyrillic'] = 0x04A9;
  10523. t['haaltonearabic'] = 0x06C1;
  10524. t['habengali'] = 0x09B9;
  10525. t['hadescendercyrillic'] = 0x04B3;
  10526. t['hadeva'] = 0x0939;
  10527. t['hagujarati'] = 0x0AB9;
  10528. t['hagurmukhi'] = 0x0A39;
  10529. t['haharabic'] = 0x062D;
  10530. t['hahfinalarabic'] = 0xFEA2;
  10531. t['hahinitialarabic'] = 0xFEA3;
  10532. t['hahiragana'] = 0x306F;
  10533. t['hahmedialarabic'] = 0xFEA4;
  10534. t['haitusquare'] = 0x332A;
  10535. t['hakatakana'] = 0x30CF;
  10536. t['hakatakanahalfwidth'] = 0xFF8A;
  10537. t['halantgurmukhi'] = 0x0A4D;
  10538. t['hamzaarabic'] = 0x0621;
  10539. t['hamzalowarabic'] = 0x0621;
  10540. t['hangulfiller'] = 0x3164;
  10541. t['hardsigncyrillic'] = 0x044A;
  10542. t['harpoonleftbarbup'] = 0x21BC;
  10543. t['harpoonrightbarbup'] = 0x21C0;
  10544. t['hasquare'] = 0x33CA;
  10545. t['hatafpatah'] = 0x05B2;
  10546. t['hatafpatah16'] = 0x05B2;
  10547. t['hatafpatah23'] = 0x05B2;
  10548. t['hatafpatah2f'] = 0x05B2;
  10549. t['hatafpatahhebrew'] = 0x05B2;
  10550. t['hatafpatahnarrowhebrew'] = 0x05B2;
  10551. t['hatafpatahquarterhebrew'] = 0x05B2;
  10552. t['hatafpatahwidehebrew'] = 0x05B2;
  10553. t['hatafqamats'] = 0x05B3;
  10554. t['hatafqamats1b'] = 0x05B3;
  10555. t['hatafqamats28'] = 0x05B3;
  10556. t['hatafqamats34'] = 0x05B3;
  10557. t['hatafqamatshebrew'] = 0x05B3;
  10558. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  10559. t['hatafqamatsquarterhebrew'] = 0x05B3;
  10560. t['hatafqamatswidehebrew'] = 0x05B3;
  10561. t['hatafsegol'] = 0x05B1;
  10562. t['hatafsegol17'] = 0x05B1;
  10563. t['hatafsegol24'] = 0x05B1;
  10564. t['hatafsegol30'] = 0x05B1;
  10565. t['hatafsegolhebrew'] = 0x05B1;
  10566. t['hatafsegolnarrowhebrew'] = 0x05B1;
  10567. t['hatafsegolquarterhebrew'] = 0x05B1;
  10568. t['hatafsegolwidehebrew'] = 0x05B1;
  10569. t['hbar'] = 0x0127;
  10570. t['hbopomofo'] = 0x310F;
  10571. t['hbrevebelow'] = 0x1E2B;
  10572. t['hcedilla'] = 0x1E29;
  10573. t['hcircle'] = 0x24D7;
  10574. t['hcircumflex'] = 0x0125;
  10575. t['hdieresis'] = 0x1E27;
  10576. t['hdotaccent'] = 0x1E23;
  10577. t['hdotbelow'] = 0x1E25;
  10578. t['he'] = 0x05D4;
  10579. t['heart'] = 0x2665;
  10580. t['heartsuitblack'] = 0x2665;
  10581. t['heartsuitwhite'] = 0x2661;
  10582. t['hedagesh'] = 0xFB34;
  10583. t['hedageshhebrew'] = 0xFB34;
  10584. t['hehaltonearabic'] = 0x06C1;
  10585. t['heharabic'] = 0x0647;
  10586. t['hehebrew'] = 0x05D4;
  10587. t['hehfinalaltonearabic'] = 0xFBA7;
  10588. t['hehfinalalttwoarabic'] = 0xFEEA;
  10589. t['hehfinalarabic'] = 0xFEEA;
  10590. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  10591. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  10592. t['hehinitialaltonearabic'] = 0xFBA8;
  10593. t['hehinitialarabic'] = 0xFEEB;
  10594. t['hehiragana'] = 0x3078;
  10595. t['hehmedialaltonearabic'] = 0xFBA9;
  10596. t['hehmedialarabic'] = 0xFEEC;
  10597. t['heiseierasquare'] = 0x337B;
  10598. t['hekatakana'] = 0x30D8;
  10599. t['hekatakanahalfwidth'] = 0xFF8D;
  10600. t['hekutaarusquare'] = 0x3336;
  10601. t['henghook'] = 0x0267;
  10602. t['herutusquare'] = 0x3339;
  10603. t['het'] = 0x05D7;
  10604. t['hethebrew'] = 0x05D7;
  10605. t['hhook'] = 0x0266;
  10606. t['hhooksuperior'] = 0x02B1;
  10607. t['hieuhacirclekorean'] = 0x327B;
  10608. t['hieuhaparenkorean'] = 0x321B;
  10609. t['hieuhcirclekorean'] = 0x326D;
  10610. t['hieuhkorean'] = 0x314E;
  10611. t['hieuhparenkorean'] = 0x320D;
  10612. t['hihiragana'] = 0x3072;
  10613. t['hikatakana'] = 0x30D2;
  10614. t['hikatakanahalfwidth'] = 0xFF8B;
  10615. t['hiriq'] = 0x05B4;
  10616. t['hiriq14'] = 0x05B4;
  10617. t['hiriq21'] = 0x05B4;
  10618. t['hiriq2d'] = 0x05B4;
  10619. t['hiriqhebrew'] = 0x05B4;
  10620. t['hiriqnarrowhebrew'] = 0x05B4;
  10621. t['hiriqquarterhebrew'] = 0x05B4;
  10622. t['hiriqwidehebrew'] = 0x05B4;
  10623. t['hlinebelow'] = 0x1E96;
  10624. t['hmonospace'] = 0xFF48;
  10625. t['hoarmenian'] = 0x0570;
  10626. t['hohipthai'] = 0x0E2B;
  10627. t['hohiragana'] = 0x307B;
  10628. t['hokatakana'] = 0x30DB;
  10629. t['hokatakanahalfwidth'] = 0xFF8E;
  10630. t['holam'] = 0x05B9;
  10631. t['holam19'] = 0x05B9;
  10632. t['holam26'] = 0x05B9;
  10633. t['holam32'] = 0x05B9;
  10634. t['holamhebrew'] = 0x05B9;
  10635. t['holamnarrowhebrew'] = 0x05B9;
  10636. t['holamquarterhebrew'] = 0x05B9;
  10637. t['holamwidehebrew'] = 0x05B9;
  10638. t['honokhukthai'] = 0x0E2E;
  10639. t['hookabovecomb'] = 0x0309;
  10640. t['hookcmb'] = 0x0309;
  10641. t['hookpalatalizedbelowcmb'] = 0x0321;
  10642. t['hookretroflexbelowcmb'] = 0x0322;
  10643. t['hoonsquare'] = 0x3342;
  10644. t['horicoptic'] = 0x03E9;
  10645. t['horizontalbar'] = 0x2015;
  10646. t['horncmb'] = 0x031B;
  10647. t['hotsprings'] = 0x2668;
  10648. t['house'] = 0x2302;
  10649. t['hparen'] = 0x24A3;
  10650. t['hsuperior'] = 0x02B0;
  10651. t['hturned'] = 0x0265;
  10652. t['huhiragana'] = 0x3075;
  10653. t['huiitosquare'] = 0x3333;
  10654. t['hukatakana'] = 0x30D5;
  10655. t['hukatakanahalfwidth'] = 0xFF8C;
  10656. t['hungarumlaut'] = 0x02DD;
  10657. t['hungarumlautcmb'] = 0x030B;
  10658. t['hv'] = 0x0195;
  10659. t['hyphen'] = 0x002D;
  10660. t['hypheninferior'] = 0xF6E5;
  10661. t['hyphenmonospace'] = 0xFF0D;
  10662. t['hyphensmall'] = 0xFE63;
  10663. t['hyphensuperior'] = 0xF6E6;
  10664. t['hyphentwo'] = 0x2010;
  10665. t['i'] = 0x0069;
  10666. t['iacute'] = 0x00ED;
  10667. t['iacyrillic'] = 0x044F;
  10668. t['ibengali'] = 0x0987;
  10669. t['ibopomofo'] = 0x3127;
  10670. t['ibreve'] = 0x012D;
  10671. t['icaron'] = 0x01D0;
  10672. t['icircle'] = 0x24D8;
  10673. t['icircumflex'] = 0x00EE;
  10674. t['icyrillic'] = 0x0456;
  10675. t['idblgrave'] = 0x0209;
  10676. t['ideographearthcircle'] = 0x328F;
  10677. t['ideographfirecircle'] = 0x328B;
  10678. t['ideographicallianceparen'] = 0x323F;
  10679. t['ideographiccallparen'] = 0x323A;
  10680. t['ideographiccentrecircle'] = 0x32A5;
  10681. t['ideographicclose'] = 0x3006;
  10682. t['ideographiccomma'] = 0x3001;
  10683. t['ideographiccommaleft'] = 0xFF64;
  10684. t['ideographiccongratulationparen'] = 0x3237;
  10685. t['ideographiccorrectcircle'] = 0x32A3;
  10686. t['ideographicearthparen'] = 0x322F;
  10687. t['ideographicenterpriseparen'] = 0x323D;
  10688. t['ideographicexcellentcircle'] = 0x329D;
  10689. t['ideographicfestivalparen'] = 0x3240;
  10690. t['ideographicfinancialcircle'] = 0x3296;
  10691. t['ideographicfinancialparen'] = 0x3236;
  10692. t['ideographicfireparen'] = 0x322B;
  10693. t['ideographichaveparen'] = 0x3232;
  10694. t['ideographichighcircle'] = 0x32A4;
  10695. t['ideographiciterationmark'] = 0x3005;
  10696. t['ideographiclaborcircle'] = 0x3298;
  10697. t['ideographiclaborparen'] = 0x3238;
  10698. t['ideographicleftcircle'] = 0x32A7;
  10699. t['ideographiclowcircle'] = 0x32A6;
  10700. t['ideographicmedicinecircle'] = 0x32A9;
  10701. t['ideographicmetalparen'] = 0x322E;
  10702. t['ideographicmoonparen'] = 0x322A;
  10703. t['ideographicnameparen'] = 0x3234;
  10704. t['ideographicperiod'] = 0x3002;
  10705. t['ideographicprintcircle'] = 0x329E;
  10706. t['ideographicreachparen'] = 0x3243;
  10707. t['ideographicrepresentparen'] = 0x3239;
  10708. t['ideographicresourceparen'] = 0x323E;
  10709. t['ideographicrightcircle'] = 0x32A8;
  10710. t['ideographicsecretcircle'] = 0x3299;
  10711. t['ideographicselfparen'] = 0x3242;
  10712. t['ideographicsocietyparen'] = 0x3233;
  10713. t['ideographicspace'] = 0x3000;
  10714. t['ideographicspecialparen'] = 0x3235;
  10715. t['ideographicstockparen'] = 0x3231;
  10716. t['ideographicstudyparen'] = 0x323B;
  10717. t['ideographicsunparen'] = 0x3230;
  10718. t['ideographicsuperviseparen'] = 0x323C;
  10719. t['ideographicwaterparen'] = 0x322C;
  10720. t['ideographicwoodparen'] = 0x322D;
  10721. t['ideographiczero'] = 0x3007;
  10722. t['ideographmetalcircle'] = 0x328E;
  10723. t['ideographmooncircle'] = 0x328A;
  10724. t['ideographnamecircle'] = 0x3294;
  10725. t['ideographsuncircle'] = 0x3290;
  10726. t['ideographwatercircle'] = 0x328C;
  10727. t['ideographwoodcircle'] = 0x328D;
  10728. t['ideva'] = 0x0907;
  10729. t['idieresis'] = 0x00EF;
  10730. t['idieresisacute'] = 0x1E2F;
  10731. t['idieresiscyrillic'] = 0x04E5;
  10732. t['idotbelow'] = 0x1ECB;
  10733. t['iebrevecyrillic'] = 0x04D7;
  10734. t['iecyrillic'] = 0x0435;
  10735. t['ieungacirclekorean'] = 0x3275;
  10736. t['ieungaparenkorean'] = 0x3215;
  10737. t['ieungcirclekorean'] = 0x3267;
  10738. t['ieungkorean'] = 0x3147;
  10739. t['ieungparenkorean'] = 0x3207;
  10740. t['igrave'] = 0x00EC;
  10741. t['igujarati'] = 0x0A87;
  10742. t['igurmukhi'] = 0x0A07;
  10743. t['ihiragana'] = 0x3044;
  10744. t['ihookabove'] = 0x1EC9;
  10745. t['iibengali'] = 0x0988;
  10746. t['iicyrillic'] = 0x0438;
  10747. t['iideva'] = 0x0908;
  10748. t['iigujarati'] = 0x0A88;
  10749. t['iigurmukhi'] = 0x0A08;
  10750. t['iimatragurmukhi'] = 0x0A40;
  10751. t['iinvertedbreve'] = 0x020B;
  10752. t['iishortcyrillic'] = 0x0439;
  10753. t['iivowelsignbengali'] = 0x09C0;
  10754. t['iivowelsigndeva'] = 0x0940;
  10755. t['iivowelsigngujarati'] = 0x0AC0;
  10756. t['ij'] = 0x0133;
  10757. t['ikatakana'] = 0x30A4;
  10758. t['ikatakanahalfwidth'] = 0xFF72;
  10759. t['ikorean'] = 0x3163;
  10760. t['ilde'] = 0x02DC;
  10761. t['iluyhebrew'] = 0x05AC;
  10762. t['imacron'] = 0x012B;
  10763. t['imacroncyrillic'] = 0x04E3;
  10764. t['imageorapproximatelyequal'] = 0x2253;
  10765. t['imatragurmukhi'] = 0x0A3F;
  10766. t['imonospace'] = 0xFF49;
  10767. t['increment'] = 0x2206;
  10768. t['infinity'] = 0x221E;
  10769. t['iniarmenian'] = 0x056B;
  10770. t['integral'] = 0x222B;
  10771. t['integralbottom'] = 0x2321;
  10772. t['integralbt'] = 0x2321;
  10773. t['integralex'] = 0xF8F5;
  10774. t['integraltop'] = 0x2320;
  10775. t['integraltp'] = 0x2320;
  10776. t['intersection'] = 0x2229;
  10777. t['intisquare'] = 0x3305;
  10778. t['invbullet'] = 0x25D8;
  10779. t['invcircle'] = 0x25D9;
  10780. t['invsmileface'] = 0x263B;
  10781. t['iocyrillic'] = 0x0451;
  10782. t['iogonek'] = 0x012F;
  10783. t['iota'] = 0x03B9;
  10784. t['iotadieresis'] = 0x03CA;
  10785. t['iotadieresistonos'] = 0x0390;
  10786. t['iotalatin'] = 0x0269;
  10787. t['iotatonos'] = 0x03AF;
  10788. t['iparen'] = 0x24A4;
  10789. t['irigurmukhi'] = 0x0A72;
  10790. t['ismallhiragana'] = 0x3043;
  10791. t['ismallkatakana'] = 0x30A3;
  10792. t['ismallkatakanahalfwidth'] = 0xFF68;
  10793. t['issharbengali'] = 0x09FA;
  10794. t['istroke'] = 0x0268;
  10795. t['isuperior'] = 0xF6ED;
  10796. t['iterationhiragana'] = 0x309D;
  10797. t['iterationkatakana'] = 0x30FD;
  10798. t['itilde'] = 0x0129;
  10799. t['itildebelow'] = 0x1E2D;
  10800. t['iubopomofo'] = 0x3129;
  10801. t['iucyrillic'] = 0x044E;
  10802. t['ivowelsignbengali'] = 0x09BF;
  10803. t['ivowelsigndeva'] = 0x093F;
  10804. t['ivowelsigngujarati'] = 0x0ABF;
  10805. t['izhitsacyrillic'] = 0x0475;
  10806. t['izhitsadblgravecyrillic'] = 0x0477;
  10807. t['j'] = 0x006A;
  10808. t['jaarmenian'] = 0x0571;
  10809. t['jabengali'] = 0x099C;
  10810. t['jadeva'] = 0x091C;
  10811. t['jagujarati'] = 0x0A9C;
  10812. t['jagurmukhi'] = 0x0A1C;
  10813. t['jbopomofo'] = 0x3110;
  10814. t['jcaron'] = 0x01F0;
  10815. t['jcircle'] = 0x24D9;
  10816. t['jcircumflex'] = 0x0135;
  10817. t['jcrossedtail'] = 0x029D;
  10818. t['jdotlessstroke'] = 0x025F;
  10819. t['jecyrillic'] = 0x0458;
  10820. t['jeemarabic'] = 0x062C;
  10821. t['jeemfinalarabic'] = 0xFE9E;
  10822. t['jeeminitialarabic'] = 0xFE9F;
  10823. t['jeemmedialarabic'] = 0xFEA0;
  10824. t['jeharabic'] = 0x0698;
  10825. t['jehfinalarabic'] = 0xFB8B;
  10826. t['jhabengali'] = 0x099D;
  10827. t['jhadeva'] = 0x091D;
  10828. t['jhagujarati'] = 0x0A9D;
  10829. t['jhagurmukhi'] = 0x0A1D;
  10830. t['jheharmenian'] = 0x057B;
  10831. t['jis'] = 0x3004;
  10832. t['jmonospace'] = 0xFF4A;
  10833. t['jparen'] = 0x24A5;
  10834. t['jsuperior'] = 0x02B2;
  10835. t['k'] = 0x006B;
  10836. t['kabashkircyrillic'] = 0x04A1;
  10837. t['kabengali'] = 0x0995;
  10838. t['kacute'] = 0x1E31;
  10839. t['kacyrillic'] = 0x043A;
  10840. t['kadescendercyrillic'] = 0x049B;
  10841. t['kadeva'] = 0x0915;
  10842. t['kaf'] = 0x05DB;
  10843. t['kafarabic'] = 0x0643;
  10844. t['kafdagesh'] = 0xFB3B;
  10845. t['kafdageshhebrew'] = 0xFB3B;
  10846. t['kaffinalarabic'] = 0xFEDA;
  10847. t['kafhebrew'] = 0x05DB;
  10848. t['kafinitialarabic'] = 0xFEDB;
  10849. t['kafmedialarabic'] = 0xFEDC;
  10850. t['kafrafehebrew'] = 0xFB4D;
  10851. t['kagujarati'] = 0x0A95;
  10852. t['kagurmukhi'] = 0x0A15;
  10853. t['kahiragana'] = 0x304B;
  10854. t['kahookcyrillic'] = 0x04C4;
  10855. t['kakatakana'] = 0x30AB;
  10856. t['kakatakanahalfwidth'] = 0xFF76;
  10857. t['kappa'] = 0x03BA;
  10858. t['kappasymbolgreek'] = 0x03F0;
  10859. t['kapyeounmieumkorean'] = 0x3171;
  10860. t['kapyeounphieuphkorean'] = 0x3184;
  10861. t['kapyeounpieupkorean'] = 0x3178;
  10862. t['kapyeounssangpieupkorean'] = 0x3179;
  10863. t['karoriisquare'] = 0x330D;
  10864. t['kashidaautoarabic'] = 0x0640;
  10865. t['kashidaautonosidebearingarabic'] = 0x0640;
  10866. t['kasmallkatakana'] = 0x30F5;
  10867. t['kasquare'] = 0x3384;
  10868. t['kasraarabic'] = 0x0650;
  10869. t['kasratanarabic'] = 0x064D;
  10870. t['kastrokecyrillic'] = 0x049F;
  10871. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  10872. t['kaverticalstrokecyrillic'] = 0x049D;
  10873. t['kbopomofo'] = 0x310E;
  10874. t['kcalsquare'] = 0x3389;
  10875. t['kcaron'] = 0x01E9;
  10876. t['kcedilla'] = 0x0137;
  10877. t['kcircle'] = 0x24DA;
  10878. t['kcommaaccent'] = 0x0137;
  10879. t['kdotbelow'] = 0x1E33;
  10880. t['keharmenian'] = 0x0584;
  10881. t['kehiragana'] = 0x3051;
  10882. t['kekatakana'] = 0x30B1;
  10883. t['kekatakanahalfwidth'] = 0xFF79;
  10884. t['kenarmenian'] = 0x056F;
  10885. t['kesmallkatakana'] = 0x30F6;
  10886. t['kgreenlandic'] = 0x0138;
  10887. t['khabengali'] = 0x0996;
  10888. t['khacyrillic'] = 0x0445;
  10889. t['khadeva'] = 0x0916;
  10890. t['khagujarati'] = 0x0A96;
  10891. t['khagurmukhi'] = 0x0A16;
  10892. t['khaharabic'] = 0x062E;
  10893. t['khahfinalarabic'] = 0xFEA6;
  10894. t['khahinitialarabic'] = 0xFEA7;
  10895. t['khahmedialarabic'] = 0xFEA8;
  10896. t['kheicoptic'] = 0x03E7;
  10897. t['khhadeva'] = 0x0959;
  10898. t['khhagurmukhi'] = 0x0A59;
  10899. t['khieukhacirclekorean'] = 0x3278;
  10900. t['khieukhaparenkorean'] = 0x3218;
  10901. t['khieukhcirclekorean'] = 0x326A;
  10902. t['khieukhkorean'] = 0x314B;
  10903. t['khieukhparenkorean'] = 0x320A;
  10904. t['khokhaithai'] = 0x0E02;
  10905. t['khokhonthai'] = 0x0E05;
  10906. t['khokhuatthai'] = 0x0E03;
  10907. t['khokhwaithai'] = 0x0E04;
  10908. t['khomutthai'] = 0x0E5B;
  10909. t['khook'] = 0x0199;
  10910. t['khorakhangthai'] = 0x0E06;
  10911. t['khzsquare'] = 0x3391;
  10912. t['kihiragana'] = 0x304D;
  10913. t['kikatakana'] = 0x30AD;
  10914. t['kikatakanahalfwidth'] = 0xFF77;
  10915. t['kiroguramusquare'] = 0x3315;
  10916. t['kiromeetorusquare'] = 0x3316;
  10917. t['kirosquare'] = 0x3314;
  10918. t['kiyeokacirclekorean'] = 0x326E;
  10919. t['kiyeokaparenkorean'] = 0x320E;
  10920. t['kiyeokcirclekorean'] = 0x3260;
  10921. t['kiyeokkorean'] = 0x3131;
  10922. t['kiyeokparenkorean'] = 0x3200;
  10923. t['kiyeoksioskorean'] = 0x3133;
  10924. t['kjecyrillic'] = 0x045C;
  10925. t['klinebelow'] = 0x1E35;
  10926. t['klsquare'] = 0x3398;
  10927. t['kmcubedsquare'] = 0x33A6;
  10928. t['kmonospace'] = 0xFF4B;
  10929. t['kmsquaredsquare'] = 0x33A2;
  10930. t['kohiragana'] = 0x3053;
  10931. t['kohmsquare'] = 0x33C0;
  10932. t['kokaithai'] = 0x0E01;
  10933. t['kokatakana'] = 0x30B3;
  10934. t['kokatakanahalfwidth'] = 0xFF7A;
  10935. t['kooposquare'] = 0x331E;
  10936. t['koppacyrillic'] = 0x0481;
  10937. t['koreanstandardsymbol'] = 0x327F;
  10938. t['koroniscmb'] = 0x0343;
  10939. t['kparen'] = 0x24A6;
  10940. t['kpasquare'] = 0x33AA;
  10941. t['ksicyrillic'] = 0x046F;
  10942. t['ktsquare'] = 0x33CF;
  10943. t['kturned'] = 0x029E;
  10944. t['kuhiragana'] = 0x304F;
  10945. t['kukatakana'] = 0x30AF;
  10946. t['kukatakanahalfwidth'] = 0xFF78;
  10947. t['kvsquare'] = 0x33B8;
  10948. t['kwsquare'] = 0x33BE;
  10949. t['l'] = 0x006C;
  10950. t['labengali'] = 0x09B2;
  10951. t['lacute'] = 0x013A;
  10952. t['ladeva'] = 0x0932;
  10953. t['lagujarati'] = 0x0AB2;
  10954. t['lagurmukhi'] = 0x0A32;
  10955. t['lakkhangyaothai'] = 0x0E45;
  10956. t['lamaleffinalarabic'] = 0xFEFC;
  10957. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  10958. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  10959. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  10960. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  10961. t['lamalefisolatedarabic'] = 0xFEFB;
  10962. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  10963. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  10964. t['lamarabic'] = 0x0644;
  10965. t['lambda'] = 0x03BB;
  10966. t['lambdastroke'] = 0x019B;
  10967. t['lamed'] = 0x05DC;
  10968. t['lameddagesh'] = 0xFB3C;
  10969. t['lameddageshhebrew'] = 0xFB3C;
  10970. t['lamedhebrew'] = 0x05DC;
  10971. t['lamfinalarabic'] = 0xFEDE;
  10972. t['lamhahinitialarabic'] = 0xFCCA;
  10973. t['laminitialarabic'] = 0xFEDF;
  10974. t['lamjeeminitialarabic'] = 0xFCC9;
  10975. t['lamkhahinitialarabic'] = 0xFCCB;
  10976. t['lamlamhehisolatedarabic'] = 0xFDF2;
  10977. t['lammedialarabic'] = 0xFEE0;
  10978. t['lammeemhahinitialarabic'] = 0xFD88;
  10979. t['lammeeminitialarabic'] = 0xFCCC;
  10980. t['largecircle'] = 0x25EF;
  10981. t['lbar'] = 0x019A;
  10982. t['lbelt'] = 0x026C;
  10983. t['lbopomofo'] = 0x310C;
  10984. t['lcaron'] = 0x013E;
  10985. t['lcedilla'] = 0x013C;
  10986. t['lcircle'] = 0x24DB;
  10987. t['lcircumflexbelow'] = 0x1E3D;
  10988. t['lcommaaccent'] = 0x013C;
  10989. t['ldot'] = 0x0140;
  10990. t['ldotaccent'] = 0x0140;
  10991. t['ldotbelow'] = 0x1E37;
  10992. t['ldotbelowmacron'] = 0x1E39;
  10993. t['leftangleabovecmb'] = 0x031A;
  10994. t['lefttackbelowcmb'] = 0x0318;
  10995. t['less'] = 0x003C;
  10996. t['lessequal'] = 0x2264;
  10997. t['lessequalorgreater'] = 0x22DA;
  10998. t['lessmonospace'] = 0xFF1C;
  10999. t['lessorequivalent'] = 0x2272;
  11000. t['lessorgreater'] = 0x2276;
  11001. t['lessoverequal'] = 0x2266;
  11002. t['lesssmall'] = 0xFE64;
  11003. t['lezh'] = 0x026E;
  11004. t['lfblock'] = 0x258C;
  11005. t['lhookretroflex'] = 0x026D;
  11006. t['lira'] = 0x20A4;
  11007. t['liwnarmenian'] = 0x056C;
  11008. t['lj'] = 0x01C9;
  11009. t['ljecyrillic'] = 0x0459;
  11010. t['ll'] = 0xF6C0;
  11011. t['lladeva'] = 0x0933;
  11012. t['llagujarati'] = 0x0AB3;
  11013. t['llinebelow'] = 0x1E3B;
  11014. t['llladeva'] = 0x0934;
  11015. t['llvocalicbengali'] = 0x09E1;
  11016. t['llvocalicdeva'] = 0x0961;
  11017. t['llvocalicvowelsignbengali'] = 0x09E3;
  11018. t['llvocalicvowelsigndeva'] = 0x0963;
  11019. t['lmiddletilde'] = 0x026B;
  11020. t['lmonospace'] = 0xFF4C;
  11021. t['lmsquare'] = 0x33D0;
  11022. t['lochulathai'] = 0x0E2C;
  11023. t['logicaland'] = 0x2227;
  11024. t['logicalnot'] = 0x00AC;
  11025. t['logicalnotreversed'] = 0x2310;
  11026. t['logicalor'] = 0x2228;
  11027. t['lolingthai'] = 0x0E25;
  11028. t['longs'] = 0x017F;
  11029. t['lowlinecenterline'] = 0xFE4E;
  11030. t['lowlinecmb'] = 0x0332;
  11031. t['lowlinedashed'] = 0xFE4D;
  11032. t['lozenge'] = 0x25CA;
  11033. t['lparen'] = 0x24A7;
  11034. t['lslash'] = 0x0142;
  11035. t['lsquare'] = 0x2113;
  11036. t['lsuperior'] = 0xF6EE;
  11037. t['ltshade'] = 0x2591;
  11038. t['luthai'] = 0x0E26;
  11039. t['lvocalicbengali'] = 0x098C;
  11040. t['lvocalicdeva'] = 0x090C;
  11041. t['lvocalicvowelsignbengali'] = 0x09E2;
  11042. t['lvocalicvowelsigndeva'] = 0x0962;
  11043. t['lxsquare'] = 0x33D3;
  11044. t['m'] = 0x006D;
  11045. t['mabengali'] = 0x09AE;
  11046. t['macron'] = 0x00AF;
  11047. t['macronbelowcmb'] = 0x0331;
  11048. t['macroncmb'] = 0x0304;
  11049. t['macronlowmod'] = 0x02CD;
  11050. t['macronmonospace'] = 0xFFE3;
  11051. t['macute'] = 0x1E3F;
  11052. t['madeva'] = 0x092E;
  11053. t['magujarati'] = 0x0AAE;
  11054. t['magurmukhi'] = 0x0A2E;
  11055. t['mahapakhhebrew'] = 0x05A4;
  11056. t['mahapakhlefthebrew'] = 0x05A4;
  11057. t['mahiragana'] = 0x307E;
  11058. t['maichattawalowleftthai'] = 0xF895;
  11059. t['maichattawalowrightthai'] = 0xF894;
  11060. t['maichattawathai'] = 0x0E4B;
  11061. t['maichattawaupperleftthai'] = 0xF893;
  11062. t['maieklowleftthai'] = 0xF88C;
  11063. t['maieklowrightthai'] = 0xF88B;
  11064. t['maiekthai'] = 0x0E48;
  11065. t['maiekupperleftthai'] = 0xF88A;
  11066. t['maihanakatleftthai'] = 0xF884;
  11067. t['maihanakatthai'] = 0x0E31;
  11068. t['maitaikhuleftthai'] = 0xF889;
  11069. t['maitaikhuthai'] = 0x0E47;
  11070. t['maitholowleftthai'] = 0xF88F;
  11071. t['maitholowrightthai'] = 0xF88E;
  11072. t['maithothai'] = 0x0E49;
  11073. t['maithoupperleftthai'] = 0xF88D;
  11074. t['maitrilowleftthai'] = 0xF892;
  11075. t['maitrilowrightthai'] = 0xF891;
  11076. t['maitrithai'] = 0x0E4A;
  11077. t['maitriupperleftthai'] = 0xF890;
  11078. t['maiyamokthai'] = 0x0E46;
  11079. t['makatakana'] = 0x30DE;
  11080. t['makatakanahalfwidth'] = 0xFF8F;
  11081. t['male'] = 0x2642;
  11082. t['mansyonsquare'] = 0x3347;
  11083. t['maqafhebrew'] = 0x05BE;
  11084. t['mars'] = 0x2642;
  11085. t['masoracirclehebrew'] = 0x05AF;
  11086. t['masquare'] = 0x3383;
  11087. t['mbopomofo'] = 0x3107;
  11088. t['mbsquare'] = 0x33D4;
  11089. t['mcircle'] = 0x24DC;
  11090. t['mcubedsquare'] = 0x33A5;
  11091. t['mdotaccent'] = 0x1E41;
  11092. t['mdotbelow'] = 0x1E43;
  11093. t['meemarabic'] = 0x0645;
  11094. t['meemfinalarabic'] = 0xFEE2;
  11095. t['meeminitialarabic'] = 0xFEE3;
  11096. t['meemmedialarabic'] = 0xFEE4;
  11097. t['meemmeeminitialarabic'] = 0xFCD1;
  11098. t['meemmeemisolatedarabic'] = 0xFC48;
  11099. t['meetorusquare'] = 0x334D;
  11100. t['mehiragana'] = 0x3081;
  11101. t['meizierasquare'] = 0x337E;
  11102. t['mekatakana'] = 0x30E1;
  11103. t['mekatakanahalfwidth'] = 0xFF92;
  11104. t['mem'] = 0x05DE;
  11105. t['memdagesh'] = 0xFB3E;
  11106. t['memdageshhebrew'] = 0xFB3E;
  11107. t['memhebrew'] = 0x05DE;
  11108. t['menarmenian'] = 0x0574;
  11109. t['merkhahebrew'] = 0x05A5;
  11110. t['merkhakefulahebrew'] = 0x05A6;
  11111. t['merkhakefulalefthebrew'] = 0x05A6;
  11112. t['merkhalefthebrew'] = 0x05A5;
  11113. t['mhook'] = 0x0271;
  11114. t['mhzsquare'] = 0x3392;
  11115. t['middledotkatakanahalfwidth'] = 0xFF65;
  11116. t['middot'] = 0x00B7;
  11117. t['mieumacirclekorean'] = 0x3272;
  11118. t['mieumaparenkorean'] = 0x3212;
  11119. t['mieumcirclekorean'] = 0x3264;
  11120. t['mieumkorean'] = 0x3141;
  11121. t['mieumpansioskorean'] = 0x3170;
  11122. t['mieumparenkorean'] = 0x3204;
  11123. t['mieumpieupkorean'] = 0x316E;
  11124. t['mieumsioskorean'] = 0x316F;
  11125. t['mihiragana'] = 0x307F;
  11126. t['mikatakana'] = 0x30DF;
  11127. t['mikatakanahalfwidth'] = 0xFF90;
  11128. t['minus'] = 0x2212;
  11129. t['minusbelowcmb'] = 0x0320;
  11130. t['minuscircle'] = 0x2296;
  11131. t['minusmod'] = 0x02D7;
  11132. t['minusplus'] = 0x2213;
  11133. t['minute'] = 0x2032;
  11134. t['miribaarusquare'] = 0x334A;
  11135. t['mirisquare'] = 0x3349;
  11136. t['mlonglegturned'] = 0x0270;
  11137. t['mlsquare'] = 0x3396;
  11138. t['mmcubedsquare'] = 0x33A3;
  11139. t['mmonospace'] = 0xFF4D;
  11140. t['mmsquaredsquare'] = 0x339F;
  11141. t['mohiragana'] = 0x3082;
  11142. t['mohmsquare'] = 0x33C1;
  11143. t['mokatakana'] = 0x30E2;
  11144. t['mokatakanahalfwidth'] = 0xFF93;
  11145. t['molsquare'] = 0x33D6;
  11146. t['momathai'] = 0x0E21;
  11147. t['moverssquare'] = 0x33A7;
  11148. t['moverssquaredsquare'] = 0x33A8;
  11149. t['mparen'] = 0x24A8;
  11150. t['mpasquare'] = 0x33AB;
  11151. t['mssquare'] = 0x33B3;
  11152. t['msuperior'] = 0xF6EF;
  11153. t['mturned'] = 0x026F;
  11154. t['mu'] = 0x00B5;
  11155. t['mu1'] = 0x00B5;
  11156. t['muasquare'] = 0x3382;
  11157. t['muchgreater'] = 0x226B;
  11158. t['muchless'] = 0x226A;
  11159. t['mufsquare'] = 0x338C;
  11160. t['mugreek'] = 0x03BC;
  11161. t['mugsquare'] = 0x338D;
  11162. t['muhiragana'] = 0x3080;
  11163. t['mukatakana'] = 0x30E0;
  11164. t['mukatakanahalfwidth'] = 0xFF91;
  11165. t['mulsquare'] = 0x3395;
  11166. t['multiply'] = 0x00D7;
  11167. t['mumsquare'] = 0x339B;
  11168. t['munahhebrew'] = 0x05A3;
  11169. t['munahlefthebrew'] = 0x05A3;
  11170. t['musicalnote'] = 0x266A;
  11171. t['musicalnotedbl'] = 0x266B;
  11172. t['musicflatsign'] = 0x266D;
  11173. t['musicsharpsign'] = 0x266F;
  11174. t['mussquare'] = 0x33B2;
  11175. t['muvsquare'] = 0x33B6;
  11176. t['muwsquare'] = 0x33BC;
  11177. t['mvmegasquare'] = 0x33B9;
  11178. t['mvsquare'] = 0x33B7;
  11179. t['mwmegasquare'] = 0x33BF;
  11180. t['mwsquare'] = 0x33BD;
  11181. t['n'] = 0x006E;
  11182. t['nabengali'] = 0x09A8;
  11183. t['nabla'] = 0x2207;
  11184. t['nacute'] = 0x0144;
  11185. t['nadeva'] = 0x0928;
  11186. t['nagujarati'] = 0x0AA8;
  11187. t['nagurmukhi'] = 0x0A28;
  11188. t['nahiragana'] = 0x306A;
  11189. t['nakatakana'] = 0x30CA;
  11190. t['nakatakanahalfwidth'] = 0xFF85;
  11191. t['napostrophe'] = 0x0149;
  11192. t['nasquare'] = 0x3381;
  11193. t['nbopomofo'] = 0x310B;
  11194. t['nbspace'] = 0x00A0;
  11195. t['ncaron'] = 0x0148;
  11196. t['ncedilla'] = 0x0146;
  11197. t['ncircle'] = 0x24DD;
  11198. t['ncircumflexbelow'] = 0x1E4B;
  11199. t['ncommaaccent'] = 0x0146;
  11200. t['ndotaccent'] = 0x1E45;
  11201. t['ndotbelow'] = 0x1E47;
  11202. t['nehiragana'] = 0x306D;
  11203. t['nekatakana'] = 0x30CD;
  11204. t['nekatakanahalfwidth'] = 0xFF88;
  11205. t['newsheqelsign'] = 0x20AA;
  11206. t['nfsquare'] = 0x338B;
  11207. t['ngabengali'] = 0x0999;
  11208. t['ngadeva'] = 0x0919;
  11209. t['ngagujarati'] = 0x0A99;
  11210. t['ngagurmukhi'] = 0x0A19;
  11211. t['ngonguthai'] = 0x0E07;
  11212. t['nhiragana'] = 0x3093;
  11213. t['nhookleft'] = 0x0272;
  11214. t['nhookretroflex'] = 0x0273;
  11215. t['nieunacirclekorean'] = 0x326F;
  11216. t['nieunaparenkorean'] = 0x320F;
  11217. t['nieuncieuckorean'] = 0x3135;
  11218. t['nieuncirclekorean'] = 0x3261;
  11219. t['nieunhieuhkorean'] = 0x3136;
  11220. t['nieunkorean'] = 0x3134;
  11221. t['nieunpansioskorean'] = 0x3168;
  11222. t['nieunparenkorean'] = 0x3201;
  11223. t['nieunsioskorean'] = 0x3167;
  11224. t['nieuntikeutkorean'] = 0x3166;
  11225. t['nihiragana'] = 0x306B;
  11226. t['nikatakana'] = 0x30CB;
  11227. t['nikatakanahalfwidth'] = 0xFF86;
  11228. t['nikhahitleftthai'] = 0xF899;
  11229. t['nikhahitthai'] = 0x0E4D;
  11230. t['nine'] = 0x0039;
  11231. t['ninearabic'] = 0x0669;
  11232. t['ninebengali'] = 0x09EF;
  11233. t['ninecircle'] = 0x2468;
  11234. t['ninecircleinversesansserif'] = 0x2792;
  11235. t['ninedeva'] = 0x096F;
  11236. t['ninegujarati'] = 0x0AEF;
  11237. t['ninegurmukhi'] = 0x0A6F;
  11238. t['ninehackarabic'] = 0x0669;
  11239. t['ninehangzhou'] = 0x3029;
  11240. t['nineideographicparen'] = 0x3228;
  11241. t['nineinferior'] = 0x2089;
  11242. t['ninemonospace'] = 0xFF19;
  11243. t['nineoldstyle'] = 0xF739;
  11244. t['nineparen'] = 0x247C;
  11245. t['nineperiod'] = 0x2490;
  11246. t['ninepersian'] = 0x06F9;
  11247. t['nineroman'] = 0x2178;
  11248. t['ninesuperior'] = 0x2079;
  11249. t['nineteencircle'] = 0x2472;
  11250. t['nineteenparen'] = 0x2486;
  11251. t['nineteenperiod'] = 0x249A;
  11252. t['ninethai'] = 0x0E59;
  11253. t['nj'] = 0x01CC;
  11254. t['njecyrillic'] = 0x045A;
  11255. t['nkatakana'] = 0x30F3;
  11256. t['nkatakanahalfwidth'] = 0xFF9D;
  11257. t['nlegrightlong'] = 0x019E;
  11258. t['nlinebelow'] = 0x1E49;
  11259. t['nmonospace'] = 0xFF4E;
  11260. t['nmsquare'] = 0x339A;
  11261. t['nnabengali'] = 0x09A3;
  11262. t['nnadeva'] = 0x0923;
  11263. t['nnagujarati'] = 0x0AA3;
  11264. t['nnagurmukhi'] = 0x0A23;
  11265. t['nnnadeva'] = 0x0929;
  11266. t['nohiragana'] = 0x306E;
  11267. t['nokatakana'] = 0x30CE;
  11268. t['nokatakanahalfwidth'] = 0xFF89;
  11269. t['nonbreakingspace'] = 0x00A0;
  11270. t['nonenthai'] = 0x0E13;
  11271. t['nonuthai'] = 0x0E19;
  11272. t['noonarabic'] = 0x0646;
  11273. t['noonfinalarabic'] = 0xFEE6;
  11274. t['noonghunnaarabic'] = 0x06BA;
  11275. t['noonghunnafinalarabic'] = 0xFB9F;
  11276. t['nooninitialarabic'] = 0xFEE7;
  11277. t['noonjeeminitialarabic'] = 0xFCD2;
  11278. t['noonjeemisolatedarabic'] = 0xFC4B;
  11279. t['noonmedialarabic'] = 0xFEE8;
  11280. t['noonmeeminitialarabic'] = 0xFCD5;
  11281. t['noonmeemisolatedarabic'] = 0xFC4E;
  11282. t['noonnoonfinalarabic'] = 0xFC8D;
  11283. t['notcontains'] = 0x220C;
  11284. t['notelement'] = 0x2209;
  11285. t['notelementof'] = 0x2209;
  11286. t['notequal'] = 0x2260;
  11287. t['notgreater'] = 0x226F;
  11288. t['notgreaternorequal'] = 0x2271;
  11289. t['notgreaternorless'] = 0x2279;
  11290. t['notidentical'] = 0x2262;
  11291. t['notless'] = 0x226E;
  11292. t['notlessnorequal'] = 0x2270;
  11293. t['notparallel'] = 0x2226;
  11294. t['notprecedes'] = 0x2280;
  11295. t['notsubset'] = 0x2284;
  11296. t['notsucceeds'] = 0x2281;
  11297. t['notsuperset'] = 0x2285;
  11298. t['nowarmenian'] = 0x0576;
  11299. t['nparen'] = 0x24A9;
  11300. t['nssquare'] = 0x33B1;
  11301. t['nsuperior'] = 0x207F;
  11302. t['ntilde'] = 0x00F1;
  11303. t['nu'] = 0x03BD;
  11304. t['nuhiragana'] = 0x306C;
  11305. t['nukatakana'] = 0x30CC;
  11306. t['nukatakanahalfwidth'] = 0xFF87;
  11307. t['nuktabengali'] = 0x09BC;
  11308. t['nuktadeva'] = 0x093C;
  11309. t['nuktagujarati'] = 0x0ABC;
  11310. t['nuktagurmukhi'] = 0x0A3C;
  11311. t['numbersign'] = 0x0023;
  11312. t['numbersignmonospace'] = 0xFF03;
  11313. t['numbersignsmall'] = 0xFE5F;
  11314. t['numeralsigngreek'] = 0x0374;
  11315. t['numeralsignlowergreek'] = 0x0375;
  11316. t['numero'] = 0x2116;
  11317. t['nun'] = 0x05E0;
  11318. t['nundagesh'] = 0xFB40;
  11319. t['nundageshhebrew'] = 0xFB40;
  11320. t['nunhebrew'] = 0x05E0;
  11321. t['nvsquare'] = 0x33B5;
  11322. t['nwsquare'] = 0x33BB;
  11323. t['nyabengali'] = 0x099E;
  11324. t['nyadeva'] = 0x091E;
  11325. t['nyagujarati'] = 0x0A9E;
  11326. t['nyagurmukhi'] = 0x0A1E;
  11327. t['o'] = 0x006F;
  11328. t['oacute'] = 0x00F3;
  11329. t['oangthai'] = 0x0E2D;
  11330. t['obarred'] = 0x0275;
  11331. t['obarredcyrillic'] = 0x04E9;
  11332. t['obarreddieresiscyrillic'] = 0x04EB;
  11333. t['obengali'] = 0x0993;
  11334. t['obopomofo'] = 0x311B;
  11335. t['obreve'] = 0x014F;
  11336. t['ocandradeva'] = 0x0911;
  11337. t['ocandragujarati'] = 0x0A91;
  11338. t['ocandravowelsigndeva'] = 0x0949;
  11339. t['ocandravowelsigngujarati'] = 0x0AC9;
  11340. t['ocaron'] = 0x01D2;
  11341. t['ocircle'] = 0x24DE;
  11342. t['ocircumflex'] = 0x00F4;
  11343. t['ocircumflexacute'] = 0x1ED1;
  11344. t['ocircumflexdotbelow'] = 0x1ED9;
  11345. t['ocircumflexgrave'] = 0x1ED3;
  11346. t['ocircumflexhookabove'] = 0x1ED5;
  11347. t['ocircumflextilde'] = 0x1ED7;
  11348. t['ocyrillic'] = 0x043E;
  11349. t['odblacute'] = 0x0151;
  11350. t['odblgrave'] = 0x020D;
  11351. t['odeva'] = 0x0913;
  11352. t['odieresis'] = 0x00F6;
  11353. t['odieresiscyrillic'] = 0x04E7;
  11354. t['odotbelow'] = 0x1ECD;
  11355. t['oe'] = 0x0153;
  11356. t['oekorean'] = 0x315A;
  11357. t['ogonek'] = 0x02DB;
  11358. t['ogonekcmb'] = 0x0328;
  11359. t['ograve'] = 0x00F2;
  11360. t['ogujarati'] = 0x0A93;
  11361. t['oharmenian'] = 0x0585;
  11362. t['ohiragana'] = 0x304A;
  11363. t['ohookabove'] = 0x1ECF;
  11364. t['ohorn'] = 0x01A1;
  11365. t['ohornacute'] = 0x1EDB;
  11366. t['ohorndotbelow'] = 0x1EE3;
  11367. t['ohorngrave'] = 0x1EDD;
  11368. t['ohornhookabove'] = 0x1EDF;
  11369. t['ohorntilde'] = 0x1EE1;
  11370. t['ohungarumlaut'] = 0x0151;
  11371. t['oi'] = 0x01A3;
  11372. t['oinvertedbreve'] = 0x020F;
  11373. t['okatakana'] = 0x30AA;
  11374. t['okatakanahalfwidth'] = 0xFF75;
  11375. t['okorean'] = 0x3157;
  11376. t['olehebrew'] = 0x05AB;
  11377. t['omacron'] = 0x014D;
  11378. t['omacronacute'] = 0x1E53;
  11379. t['omacrongrave'] = 0x1E51;
  11380. t['omdeva'] = 0x0950;
  11381. t['omega'] = 0x03C9;
  11382. t['omega1'] = 0x03D6;
  11383. t['omegacyrillic'] = 0x0461;
  11384. t['omegalatinclosed'] = 0x0277;
  11385. t['omegaroundcyrillic'] = 0x047B;
  11386. t['omegatitlocyrillic'] = 0x047D;
  11387. t['omegatonos'] = 0x03CE;
  11388. t['omgujarati'] = 0x0AD0;
  11389. t['omicron'] = 0x03BF;
  11390. t['omicrontonos'] = 0x03CC;
  11391. t['omonospace'] = 0xFF4F;
  11392. t['one'] = 0x0031;
  11393. t['onearabic'] = 0x0661;
  11394. t['onebengali'] = 0x09E7;
  11395. t['onecircle'] = 0x2460;
  11396. t['onecircleinversesansserif'] = 0x278A;
  11397. t['onedeva'] = 0x0967;
  11398. t['onedotenleader'] = 0x2024;
  11399. t['oneeighth'] = 0x215B;
  11400. t['onefitted'] = 0xF6DC;
  11401. t['onegujarati'] = 0x0AE7;
  11402. t['onegurmukhi'] = 0x0A67;
  11403. t['onehackarabic'] = 0x0661;
  11404. t['onehalf'] = 0x00BD;
  11405. t['onehangzhou'] = 0x3021;
  11406. t['oneideographicparen'] = 0x3220;
  11407. t['oneinferior'] = 0x2081;
  11408. t['onemonospace'] = 0xFF11;
  11409. t['onenumeratorbengali'] = 0x09F4;
  11410. t['oneoldstyle'] = 0xF731;
  11411. t['oneparen'] = 0x2474;
  11412. t['oneperiod'] = 0x2488;
  11413. t['onepersian'] = 0x06F1;
  11414. t['onequarter'] = 0x00BC;
  11415. t['oneroman'] = 0x2170;
  11416. t['onesuperior'] = 0x00B9;
  11417. t['onethai'] = 0x0E51;
  11418. t['onethird'] = 0x2153;
  11419. t['oogonek'] = 0x01EB;
  11420. t['oogonekmacron'] = 0x01ED;
  11421. t['oogurmukhi'] = 0x0A13;
  11422. t['oomatragurmukhi'] = 0x0A4B;
  11423. t['oopen'] = 0x0254;
  11424. t['oparen'] = 0x24AA;
  11425. t['openbullet'] = 0x25E6;
  11426. t['option'] = 0x2325;
  11427. t['ordfeminine'] = 0x00AA;
  11428. t['ordmasculine'] = 0x00BA;
  11429. t['orthogonal'] = 0x221F;
  11430. t['oshortdeva'] = 0x0912;
  11431. t['oshortvowelsigndeva'] = 0x094A;
  11432. t['oslash'] = 0x00F8;
  11433. t['oslashacute'] = 0x01FF;
  11434. t['osmallhiragana'] = 0x3049;
  11435. t['osmallkatakana'] = 0x30A9;
  11436. t['osmallkatakanahalfwidth'] = 0xFF6B;
  11437. t['ostrokeacute'] = 0x01FF;
  11438. t['osuperior'] = 0xF6F0;
  11439. t['otcyrillic'] = 0x047F;
  11440. t['otilde'] = 0x00F5;
  11441. t['otildeacute'] = 0x1E4D;
  11442. t['otildedieresis'] = 0x1E4F;
  11443. t['oubopomofo'] = 0x3121;
  11444. t['overline'] = 0x203E;
  11445. t['overlinecenterline'] = 0xFE4A;
  11446. t['overlinecmb'] = 0x0305;
  11447. t['overlinedashed'] = 0xFE49;
  11448. t['overlinedblwavy'] = 0xFE4C;
  11449. t['overlinewavy'] = 0xFE4B;
  11450. t['overscore'] = 0x00AF;
  11451. t['ovowelsignbengali'] = 0x09CB;
  11452. t['ovowelsigndeva'] = 0x094B;
  11453. t['ovowelsigngujarati'] = 0x0ACB;
  11454. t['p'] = 0x0070;
  11455. t['paampssquare'] = 0x3380;
  11456. t['paasentosquare'] = 0x332B;
  11457. t['pabengali'] = 0x09AA;
  11458. t['pacute'] = 0x1E55;
  11459. t['padeva'] = 0x092A;
  11460. t['pagedown'] = 0x21DF;
  11461. t['pageup'] = 0x21DE;
  11462. t['pagujarati'] = 0x0AAA;
  11463. t['pagurmukhi'] = 0x0A2A;
  11464. t['pahiragana'] = 0x3071;
  11465. t['paiyannoithai'] = 0x0E2F;
  11466. t['pakatakana'] = 0x30D1;
  11467. t['palatalizationcyrilliccmb'] = 0x0484;
  11468. t['palochkacyrillic'] = 0x04C0;
  11469. t['pansioskorean'] = 0x317F;
  11470. t['paragraph'] = 0x00B6;
  11471. t['parallel'] = 0x2225;
  11472. t['parenleft'] = 0x0028;
  11473. t['parenleftaltonearabic'] = 0xFD3E;
  11474. t['parenleftbt'] = 0xF8ED;
  11475. t['parenleftex'] = 0xF8EC;
  11476. t['parenleftinferior'] = 0x208D;
  11477. t['parenleftmonospace'] = 0xFF08;
  11478. t['parenleftsmall'] = 0xFE59;
  11479. t['parenleftsuperior'] = 0x207D;
  11480. t['parenlefttp'] = 0xF8EB;
  11481. t['parenleftvertical'] = 0xFE35;
  11482. t['parenright'] = 0x0029;
  11483. t['parenrightaltonearabic'] = 0xFD3F;
  11484. t['parenrightbt'] = 0xF8F8;
  11485. t['parenrightex'] = 0xF8F7;
  11486. t['parenrightinferior'] = 0x208E;
  11487. t['parenrightmonospace'] = 0xFF09;
  11488. t['parenrightsmall'] = 0xFE5A;
  11489. t['parenrightsuperior'] = 0x207E;
  11490. t['parenrighttp'] = 0xF8F6;
  11491. t['parenrightvertical'] = 0xFE36;
  11492. t['partialdiff'] = 0x2202;
  11493. t['paseqhebrew'] = 0x05C0;
  11494. t['pashtahebrew'] = 0x0599;
  11495. t['pasquare'] = 0x33A9;
  11496. t['patah'] = 0x05B7;
  11497. t['patah11'] = 0x05B7;
  11498. t['patah1d'] = 0x05B7;
  11499. t['patah2a'] = 0x05B7;
  11500. t['patahhebrew'] = 0x05B7;
  11501. t['patahnarrowhebrew'] = 0x05B7;
  11502. t['patahquarterhebrew'] = 0x05B7;
  11503. t['patahwidehebrew'] = 0x05B7;
  11504. t['pazerhebrew'] = 0x05A1;
  11505. t['pbopomofo'] = 0x3106;
  11506. t['pcircle'] = 0x24DF;
  11507. t['pdotaccent'] = 0x1E57;
  11508. t['pe'] = 0x05E4;
  11509. t['pecyrillic'] = 0x043F;
  11510. t['pedagesh'] = 0xFB44;
  11511. t['pedageshhebrew'] = 0xFB44;
  11512. t['peezisquare'] = 0x333B;
  11513. t['pefinaldageshhebrew'] = 0xFB43;
  11514. t['peharabic'] = 0x067E;
  11515. t['peharmenian'] = 0x057A;
  11516. t['pehebrew'] = 0x05E4;
  11517. t['pehfinalarabic'] = 0xFB57;
  11518. t['pehinitialarabic'] = 0xFB58;
  11519. t['pehiragana'] = 0x307A;
  11520. t['pehmedialarabic'] = 0xFB59;
  11521. t['pekatakana'] = 0x30DA;
  11522. t['pemiddlehookcyrillic'] = 0x04A7;
  11523. t['perafehebrew'] = 0xFB4E;
  11524. t['percent'] = 0x0025;
  11525. t['percentarabic'] = 0x066A;
  11526. t['percentmonospace'] = 0xFF05;
  11527. t['percentsmall'] = 0xFE6A;
  11528. t['period'] = 0x002E;
  11529. t['periodarmenian'] = 0x0589;
  11530. t['periodcentered'] = 0x00B7;
  11531. t['periodhalfwidth'] = 0xFF61;
  11532. t['periodinferior'] = 0xF6E7;
  11533. t['periodmonospace'] = 0xFF0E;
  11534. t['periodsmall'] = 0xFE52;
  11535. t['periodsuperior'] = 0xF6E8;
  11536. t['perispomenigreekcmb'] = 0x0342;
  11537. t['perpendicular'] = 0x22A5;
  11538. t['perthousand'] = 0x2030;
  11539. t['peseta'] = 0x20A7;
  11540. t['pfsquare'] = 0x338A;
  11541. t['phabengali'] = 0x09AB;
  11542. t['phadeva'] = 0x092B;
  11543. t['phagujarati'] = 0x0AAB;
  11544. t['phagurmukhi'] = 0x0A2B;
  11545. t['phi'] = 0x03C6;
  11546. t['phi1'] = 0x03D5;
  11547. t['phieuphacirclekorean'] = 0x327A;
  11548. t['phieuphaparenkorean'] = 0x321A;
  11549. t['phieuphcirclekorean'] = 0x326C;
  11550. t['phieuphkorean'] = 0x314D;
  11551. t['phieuphparenkorean'] = 0x320C;
  11552. t['philatin'] = 0x0278;
  11553. t['phinthuthai'] = 0x0E3A;
  11554. t['phisymbolgreek'] = 0x03D5;
  11555. t['phook'] = 0x01A5;
  11556. t['phophanthai'] = 0x0E1E;
  11557. t['phophungthai'] = 0x0E1C;
  11558. t['phosamphaothai'] = 0x0E20;
  11559. t['pi'] = 0x03C0;
  11560. t['pieupacirclekorean'] = 0x3273;
  11561. t['pieupaparenkorean'] = 0x3213;
  11562. t['pieupcieuckorean'] = 0x3176;
  11563. t['pieupcirclekorean'] = 0x3265;
  11564. t['pieupkiyeokkorean'] = 0x3172;
  11565. t['pieupkorean'] = 0x3142;
  11566. t['pieupparenkorean'] = 0x3205;
  11567. t['pieupsioskiyeokkorean'] = 0x3174;
  11568. t['pieupsioskorean'] = 0x3144;
  11569. t['pieupsiostikeutkorean'] = 0x3175;
  11570. t['pieupthieuthkorean'] = 0x3177;
  11571. t['pieuptikeutkorean'] = 0x3173;
  11572. t['pihiragana'] = 0x3074;
  11573. t['pikatakana'] = 0x30D4;
  11574. t['pisymbolgreek'] = 0x03D6;
  11575. t['piwrarmenian'] = 0x0583;
  11576. t['plus'] = 0x002B;
  11577. t['plusbelowcmb'] = 0x031F;
  11578. t['pluscircle'] = 0x2295;
  11579. t['plusminus'] = 0x00B1;
  11580. t['plusmod'] = 0x02D6;
  11581. t['plusmonospace'] = 0xFF0B;
  11582. t['plussmall'] = 0xFE62;
  11583. t['plussuperior'] = 0x207A;
  11584. t['pmonospace'] = 0xFF50;
  11585. t['pmsquare'] = 0x33D8;
  11586. t['pohiragana'] = 0x307D;
  11587. t['pointingindexdownwhite'] = 0x261F;
  11588. t['pointingindexleftwhite'] = 0x261C;
  11589. t['pointingindexrightwhite'] = 0x261E;
  11590. t['pointingindexupwhite'] = 0x261D;
  11591. t['pokatakana'] = 0x30DD;
  11592. t['poplathai'] = 0x0E1B;
  11593. t['postalmark'] = 0x3012;
  11594. t['postalmarkface'] = 0x3020;
  11595. t['pparen'] = 0x24AB;
  11596. t['precedes'] = 0x227A;
  11597. t['prescription'] = 0x211E;
  11598. t['primemod'] = 0x02B9;
  11599. t['primereversed'] = 0x2035;
  11600. t['product'] = 0x220F;
  11601. t['projective'] = 0x2305;
  11602. t['prolongedkana'] = 0x30FC;
  11603. t['propellor'] = 0x2318;
  11604. t['propersubset'] = 0x2282;
  11605. t['propersuperset'] = 0x2283;
  11606. t['proportion'] = 0x2237;
  11607. t['proportional'] = 0x221D;
  11608. t['psi'] = 0x03C8;
  11609. t['psicyrillic'] = 0x0471;
  11610. t['psilipneumatacyrilliccmb'] = 0x0486;
  11611. t['pssquare'] = 0x33B0;
  11612. t['puhiragana'] = 0x3077;
  11613. t['pukatakana'] = 0x30D7;
  11614. t['pvsquare'] = 0x33B4;
  11615. t['pwsquare'] = 0x33BA;
  11616. t['q'] = 0x0071;
  11617. t['qadeva'] = 0x0958;
  11618. t['qadmahebrew'] = 0x05A8;
  11619. t['qafarabic'] = 0x0642;
  11620. t['qaffinalarabic'] = 0xFED6;
  11621. t['qafinitialarabic'] = 0xFED7;
  11622. t['qafmedialarabic'] = 0xFED8;
  11623. t['qamats'] = 0x05B8;
  11624. t['qamats10'] = 0x05B8;
  11625. t['qamats1a'] = 0x05B8;
  11626. t['qamats1c'] = 0x05B8;
  11627. t['qamats27'] = 0x05B8;
  11628. t['qamats29'] = 0x05B8;
  11629. t['qamats33'] = 0x05B8;
  11630. t['qamatsde'] = 0x05B8;
  11631. t['qamatshebrew'] = 0x05B8;
  11632. t['qamatsnarrowhebrew'] = 0x05B8;
  11633. t['qamatsqatanhebrew'] = 0x05B8;
  11634. t['qamatsqatannarrowhebrew'] = 0x05B8;
  11635. t['qamatsqatanquarterhebrew'] = 0x05B8;
  11636. t['qamatsqatanwidehebrew'] = 0x05B8;
  11637. t['qamatsquarterhebrew'] = 0x05B8;
  11638. t['qamatswidehebrew'] = 0x05B8;
  11639. t['qarneyparahebrew'] = 0x059F;
  11640. t['qbopomofo'] = 0x3111;
  11641. t['qcircle'] = 0x24E0;
  11642. t['qhook'] = 0x02A0;
  11643. t['qmonospace'] = 0xFF51;
  11644. t['qof'] = 0x05E7;
  11645. t['qofdagesh'] = 0xFB47;
  11646. t['qofdageshhebrew'] = 0xFB47;
  11647. t['qofhebrew'] = 0x05E7;
  11648. t['qparen'] = 0x24AC;
  11649. t['quarternote'] = 0x2669;
  11650. t['qubuts'] = 0x05BB;
  11651. t['qubuts18'] = 0x05BB;
  11652. t['qubuts25'] = 0x05BB;
  11653. t['qubuts31'] = 0x05BB;
  11654. t['qubutshebrew'] = 0x05BB;
  11655. t['qubutsnarrowhebrew'] = 0x05BB;
  11656. t['qubutsquarterhebrew'] = 0x05BB;
  11657. t['qubutswidehebrew'] = 0x05BB;
  11658. t['question'] = 0x003F;
  11659. t['questionarabic'] = 0x061F;
  11660. t['questionarmenian'] = 0x055E;
  11661. t['questiondown'] = 0x00BF;
  11662. t['questiondownsmall'] = 0xF7BF;
  11663. t['questiongreek'] = 0x037E;
  11664. t['questionmonospace'] = 0xFF1F;
  11665. t['questionsmall'] = 0xF73F;
  11666. t['quotedbl'] = 0x0022;
  11667. t['quotedblbase'] = 0x201E;
  11668. t['quotedblleft'] = 0x201C;
  11669. t['quotedblmonospace'] = 0xFF02;
  11670. t['quotedblprime'] = 0x301E;
  11671. t['quotedblprimereversed'] = 0x301D;
  11672. t['quotedblright'] = 0x201D;
  11673. t['quoteleft'] = 0x2018;
  11674. t['quoteleftreversed'] = 0x201B;
  11675. t['quotereversed'] = 0x201B;
  11676. t['quoteright'] = 0x2019;
  11677. t['quoterightn'] = 0x0149;
  11678. t['quotesinglbase'] = 0x201A;
  11679. t['quotesingle'] = 0x0027;
  11680. t['quotesinglemonospace'] = 0xFF07;
  11681. t['r'] = 0x0072;
  11682. t['raarmenian'] = 0x057C;
  11683. t['rabengali'] = 0x09B0;
  11684. t['racute'] = 0x0155;
  11685. t['radeva'] = 0x0930;
  11686. t['radical'] = 0x221A;
  11687. t['radicalex'] = 0xF8E5;
  11688. t['radoverssquare'] = 0x33AE;
  11689. t['radoverssquaredsquare'] = 0x33AF;
  11690. t['radsquare'] = 0x33AD;
  11691. t['rafe'] = 0x05BF;
  11692. t['rafehebrew'] = 0x05BF;
  11693. t['ragujarati'] = 0x0AB0;
  11694. t['ragurmukhi'] = 0x0A30;
  11695. t['rahiragana'] = 0x3089;
  11696. t['rakatakana'] = 0x30E9;
  11697. t['rakatakanahalfwidth'] = 0xFF97;
  11698. t['ralowerdiagonalbengali'] = 0x09F1;
  11699. t['ramiddlediagonalbengali'] = 0x09F0;
  11700. t['ramshorn'] = 0x0264;
  11701. t['ratio'] = 0x2236;
  11702. t['rbopomofo'] = 0x3116;
  11703. t['rcaron'] = 0x0159;
  11704. t['rcedilla'] = 0x0157;
  11705. t['rcircle'] = 0x24E1;
  11706. t['rcommaaccent'] = 0x0157;
  11707. t['rdblgrave'] = 0x0211;
  11708. t['rdotaccent'] = 0x1E59;
  11709. t['rdotbelow'] = 0x1E5B;
  11710. t['rdotbelowmacron'] = 0x1E5D;
  11711. t['referencemark'] = 0x203B;
  11712. t['reflexsubset'] = 0x2286;
  11713. t['reflexsuperset'] = 0x2287;
  11714. t['registered'] = 0x00AE;
  11715. t['registersans'] = 0xF8E8;
  11716. t['registerserif'] = 0xF6DA;
  11717. t['reharabic'] = 0x0631;
  11718. t['reharmenian'] = 0x0580;
  11719. t['rehfinalarabic'] = 0xFEAE;
  11720. t['rehiragana'] = 0x308C;
  11721. t['rekatakana'] = 0x30EC;
  11722. t['rekatakanahalfwidth'] = 0xFF9A;
  11723. t['resh'] = 0x05E8;
  11724. t['reshdageshhebrew'] = 0xFB48;
  11725. t['reshhebrew'] = 0x05E8;
  11726. t['reversedtilde'] = 0x223D;
  11727. t['reviahebrew'] = 0x0597;
  11728. t['reviamugrashhebrew'] = 0x0597;
  11729. t['revlogicalnot'] = 0x2310;
  11730. t['rfishhook'] = 0x027E;
  11731. t['rfishhookreversed'] = 0x027F;
  11732. t['rhabengali'] = 0x09DD;
  11733. t['rhadeva'] = 0x095D;
  11734. t['rho'] = 0x03C1;
  11735. t['rhook'] = 0x027D;
  11736. t['rhookturned'] = 0x027B;
  11737. t['rhookturnedsuperior'] = 0x02B5;
  11738. t['rhosymbolgreek'] = 0x03F1;
  11739. t['rhotichookmod'] = 0x02DE;
  11740. t['rieulacirclekorean'] = 0x3271;
  11741. t['rieulaparenkorean'] = 0x3211;
  11742. t['rieulcirclekorean'] = 0x3263;
  11743. t['rieulhieuhkorean'] = 0x3140;
  11744. t['rieulkiyeokkorean'] = 0x313A;
  11745. t['rieulkiyeoksioskorean'] = 0x3169;
  11746. t['rieulkorean'] = 0x3139;
  11747. t['rieulmieumkorean'] = 0x313B;
  11748. t['rieulpansioskorean'] = 0x316C;
  11749. t['rieulparenkorean'] = 0x3203;
  11750. t['rieulphieuphkorean'] = 0x313F;
  11751. t['rieulpieupkorean'] = 0x313C;
  11752. t['rieulpieupsioskorean'] = 0x316B;
  11753. t['rieulsioskorean'] = 0x313D;
  11754. t['rieulthieuthkorean'] = 0x313E;
  11755. t['rieultikeutkorean'] = 0x316A;
  11756. t['rieulyeorinhieuhkorean'] = 0x316D;
  11757. t['rightangle'] = 0x221F;
  11758. t['righttackbelowcmb'] = 0x0319;
  11759. t['righttriangle'] = 0x22BF;
  11760. t['rihiragana'] = 0x308A;
  11761. t['rikatakana'] = 0x30EA;
  11762. t['rikatakanahalfwidth'] = 0xFF98;
  11763. t['ring'] = 0x02DA;
  11764. t['ringbelowcmb'] = 0x0325;
  11765. t['ringcmb'] = 0x030A;
  11766. t['ringhalfleft'] = 0x02BF;
  11767. t['ringhalfleftarmenian'] = 0x0559;
  11768. t['ringhalfleftbelowcmb'] = 0x031C;
  11769. t['ringhalfleftcentered'] = 0x02D3;
  11770. t['ringhalfright'] = 0x02BE;
  11771. t['ringhalfrightbelowcmb'] = 0x0339;
  11772. t['ringhalfrightcentered'] = 0x02D2;
  11773. t['rinvertedbreve'] = 0x0213;
  11774. t['rittorusquare'] = 0x3351;
  11775. t['rlinebelow'] = 0x1E5F;
  11776. t['rlongleg'] = 0x027C;
  11777. t['rlonglegturned'] = 0x027A;
  11778. t['rmonospace'] = 0xFF52;
  11779. t['rohiragana'] = 0x308D;
  11780. t['rokatakana'] = 0x30ED;
  11781. t['rokatakanahalfwidth'] = 0xFF9B;
  11782. t['roruathai'] = 0x0E23;
  11783. t['rparen'] = 0x24AD;
  11784. t['rrabengali'] = 0x09DC;
  11785. t['rradeva'] = 0x0931;
  11786. t['rragurmukhi'] = 0x0A5C;
  11787. t['rreharabic'] = 0x0691;
  11788. t['rrehfinalarabic'] = 0xFB8D;
  11789. t['rrvocalicbengali'] = 0x09E0;
  11790. t['rrvocalicdeva'] = 0x0960;
  11791. t['rrvocalicgujarati'] = 0x0AE0;
  11792. t['rrvocalicvowelsignbengali'] = 0x09C4;
  11793. t['rrvocalicvowelsigndeva'] = 0x0944;
  11794. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  11795. t['rsuperior'] = 0xF6F1;
  11796. t['rtblock'] = 0x2590;
  11797. t['rturned'] = 0x0279;
  11798. t['rturnedsuperior'] = 0x02B4;
  11799. t['ruhiragana'] = 0x308B;
  11800. t['rukatakana'] = 0x30EB;
  11801. t['rukatakanahalfwidth'] = 0xFF99;
  11802. t['rupeemarkbengali'] = 0x09F2;
  11803. t['rupeesignbengali'] = 0x09F3;
  11804. t['rupiah'] = 0xF6DD;
  11805. t['ruthai'] = 0x0E24;
  11806. t['rvocalicbengali'] = 0x098B;
  11807. t['rvocalicdeva'] = 0x090B;
  11808. t['rvocalicgujarati'] = 0x0A8B;
  11809. t['rvocalicvowelsignbengali'] = 0x09C3;
  11810. t['rvocalicvowelsigndeva'] = 0x0943;
  11811. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  11812. t['s'] = 0x0073;
  11813. t['sabengali'] = 0x09B8;
  11814. t['sacute'] = 0x015B;
  11815. t['sacutedotaccent'] = 0x1E65;
  11816. t['sadarabic'] = 0x0635;
  11817. t['sadeva'] = 0x0938;
  11818. t['sadfinalarabic'] = 0xFEBA;
  11819. t['sadinitialarabic'] = 0xFEBB;
  11820. t['sadmedialarabic'] = 0xFEBC;
  11821. t['sagujarati'] = 0x0AB8;
  11822. t['sagurmukhi'] = 0x0A38;
  11823. t['sahiragana'] = 0x3055;
  11824. t['sakatakana'] = 0x30B5;
  11825. t['sakatakanahalfwidth'] = 0xFF7B;
  11826. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  11827. t['samekh'] = 0x05E1;
  11828. t['samekhdagesh'] = 0xFB41;
  11829. t['samekhdageshhebrew'] = 0xFB41;
  11830. t['samekhhebrew'] = 0x05E1;
  11831. t['saraaathai'] = 0x0E32;
  11832. t['saraaethai'] = 0x0E41;
  11833. t['saraaimaimalaithai'] = 0x0E44;
  11834. t['saraaimaimuanthai'] = 0x0E43;
  11835. t['saraamthai'] = 0x0E33;
  11836. t['saraathai'] = 0x0E30;
  11837. t['saraethai'] = 0x0E40;
  11838. t['saraiileftthai'] = 0xF886;
  11839. t['saraiithai'] = 0x0E35;
  11840. t['saraileftthai'] = 0xF885;
  11841. t['saraithai'] = 0x0E34;
  11842. t['saraothai'] = 0x0E42;
  11843. t['saraueeleftthai'] = 0xF888;
  11844. t['saraueethai'] = 0x0E37;
  11845. t['saraueleftthai'] = 0xF887;
  11846. t['sarauethai'] = 0x0E36;
  11847. t['sarauthai'] = 0x0E38;
  11848. t['sarauuthai'] = 0x0E39;
  11849. t['sbopomofo'] = 0x3119;
  11850. t['scaron'] = 0x0161;
  11851. t['scarondotaccent'] = 0x1E67;
  11852. t['scedilla'] = 0x015F;
  11853. t['schwa'] = 0x0259;
  11854. t['schwacyrillic'] = 0x04D9;
  11855. t['schwadieresiscyrillic'] = 0x04DB;
  11856. t['schwahook'] = 0x025A;
  11857. t['scircle'] = 0x24E2;
  11858. t['scircumflex'] = 0x015D;
  11859. t['scommaaccent'] = 0x0219;
  11860. t['sdotaccent'] = 0x1E61;
  11861. t['sdotbelow'] = 0x1E63;
  11862. t['sdotbelowdotaccent'] = 0x1E69;
  11863. t['seagullbelowcmb'] = 0x033C;
  11864. t['second'] = 0x2033;
  11865. t['secondtonechinese'] = 0x02CA;
  11866. t['section'] = 0x00A7;
  11867. t['seenarabic'] = 0x0633;
  11868. t['seenfinalarabic'] = 0xFEB2;
  11869. t['seeninitialarabic'] = 0xFEB3;
  11870. t['seenmedialarabic'] = 0xFEB4;
  11871. t['segol'] = 0x05B6;
  11872. t['segol13'] = 0x05B6;
  11873. t['segol1f'] = 0x05B6;
  11874. t['segol2c'] = 0x05B6;
  11875. t['segolhebrew'] = 0x05B6;
  11876. t['segolnarrowhebrew'] = 0x05B6;
  11877. t['segolquarterhebrew'] = 0x05B6;
  11878. t['segoltahebrew'] = 0x0592;
  11879. t['segolwidehebrew'] = 0x05B6;
  11880. t['seharmenian'] = 0x057D;
  11881. t['sehiragana'] = 0x305B;
  11882. t['sekatakana'] = 0x30BB;
  11883. t['sekatakanahalfwidth'] = 0xFF7E;
  11884. t['semicolon'] = 0x003B;
  11885. t['semicolonarabic'] = 0x061B;
  11886. t['semicolonmonospace'] = 0xFF1B;
  11887. t['semicolonsmall'] = 0xFE54;
  11888. t['semivoicedmarkkana'] = 0x309C;
  11889. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  11890. t['sentisquare'] = 0x3322;
  11891. t['sentosquare'] = 0x3323;
  11892. t['seven'] = 0x0037;
  11893. t['sevenarabic'] = 0x0667;
  11894. t['sevenbengali'] = 0x09ED;
  11895. t['sevencircle'] = 0x2466;
  11896. t['sevencircleinversesansserif'] = 0x2790;
  11897. t['sevendeva'] = 0x096D;
  11898. t['seveneighths'] = 0x215E;
  11899. t['sevengujarati'] = 0x0AED;
  11900. t['sevengurmukhi'] = 0x0A6D;
  11901. t['sevenhackarabic'] = 0x0667;
  11902. t['sevenhangzhou'] = 0x3027;
  11903. t['sevenideographicparen'] = 0x3226;
  11904. t['seveninferior'] = 0x2087;
  11905. t['sevenmonospace'] = 0xFF17;
  11906. t['sevenoldstyle'] = 0xF737;
  11907. t['sevenparen'] = 0x247A;
  11908. t['sevenperiod'] = 0x248E;
  11909. t['sevenpersian'] = 0x06F7;
  11910. t['sevenroman'] = 0x2176;
  11911. t['sevensuperior'] = 0x2077;
  11912. t['seventeencircle'] = 0x2470;
  11913. t['seventeenparen'] = 0x2484;
  11914. t['seventeenperiod'] = 0x2498;
  11915. t['seventhai'] = 0x0E57;
  11916. t['sfthyphen'] = 0x00AD;
  11917. t['shaarmenian'] = 0x0577;
  11918. t['shabengali'] = 0x09B6;
  11919. t['shacyrillic'] = 0x0448;
  11920. t['shaddaarabic'] = 0x0651;
  11921. t['shaddadammaarabic'] = 0xFC61;
  11922. t['shaddadammatanarabic'] = 0xFC5E;
  11923. t['shaddafathaarabic'] = 0xFC60;
  11924. t['shaddakasraarabic'] = 0xFC62;
  11925. t['shaddakasratanarabic'] = 0xFC5F;
  11926. t['shade'] = 0x2592;
  11927. t['shadedark'] = 0x2593;
  11928. t['shadelight'] = 0x2591;
  11929. t['shademedium'] = 0x2592;
  11930. t['shadeva'] = 0x0936;
  11931. t['shagujarati'] = 0x0AB6;
  11932. t['shagurmukhi'] = 0x0A36;
  11933. t['shalshelethebrew'] = 0x0593;
  11934. t['shbopomofo'] = 0x3115;
  11935. t['shchacyrillic'] = 0x0449;
  11936. t['sheenarabic'] = 0x0634;
  11937. t['sheenfinalarabic'] = 0xFEB6;
  11938. t['sheeninitialarabic'] = 0xFEB7;
  11939. t['sheenmedialarabic'] = 0xFEB8;
  11940. t['sheicoptic'] = 0x03E3;
  11941. t['sheqel'] = 0x20AA;
  11942. t['sheqelhebrew'] = 0x20AA;
  11943. t['sheva'] = 0x05B0;
  11944. t['sheva115'] = 0x05B0;
  11945. t['sheva15'] = 0x05B0;
  11946. t['sheva22'] = 0x05B0;
  11947. t['sheva2e'] = 0x05B0;
  11948. t['shevahebrew'] = 0x05B0;
  11949. t['shevanarrowhebrew'] = 0x05B0;
  11950. t['shevaquarterhebrew'] = 0x05B0;
  11951. t['shevawidehebrew'] = 0x05B0;
  11952. t['shhacyrillic'] = 0x04BB;
  11953. t['shimacoptic'] = 0x03ED;
  11954. t['shin'] = 0x05E9;
  11955. t['shindagesh'] = 0xFB49;
  11956. t['shindageshhebrew'] = 0xFB49;
  11957. t['shindageshshindot'] = 0xFB2C;
  11958. t['shindageshshindothebrew'] = 0xFB2C;
  11959. t['shindageshsindot'] = 0xFB2D;
  11960. t['shindageshsindothebrew'] = 0xFB2D;
  11961. t['shindothebrew'] = 0x05C1;
  11962. t['shinhebrew'] = 0x05E9;
  11963. t['shinshindot'] = 0xFB2A;
  11964. t['shinshindothebrew'] = 0xFB2A;
  11965. t['shinsindot'] = 0xFB2B;
  11966. t['shinsindothebrew'] = 0xFB2B;
  11967. t['shook'] = 0x0282;
  11968. t['sigma'] = 0x03C3;
  11969. t['sigma1'] = 0x03C2;
  11970. t['sigmafinal'] = 0x03C2;
  11971. t['sigmalunatesymbolgreek'] = 0x03F2;
  11972. t['sihiragana'] = 0x3057;
  11973. t['sikatakana'] = 0x30B7;
  11974. t['sikatakanahalfwidth'] = 0xFF7C;
  11975. t['siluqhebrew'] = 0x05BD;
  11976. t['siluqlefthebrew'] = 0x05BD;
  11977. t['similar'] = 0x223C;
  11978. t['sindothebrew'] = 0x05C2;
  11979. t['siosacirclekorean'] = 0x3274;
  11980. t['siosaparenkorean'] = 0x3214;
  11981. t['sioscieuckorean'] = 0x317E;
  11982. t['sioscirclekorean'] = 0x3266;
  11983. t['sioskiyeokkorean'] = 0x317A;
  11984. t['sioskorean'] = 0x3145;
  11985. t['siosnieunkorean'] = 0x317B;
  11986. t['siosparenkorean'] = 0x3206;
  11987. t['siospieupkorean'] = 0x317D;
  11988. t['siostikeutkorean'] = 0x317C;
  11989. t['six'] = 0x0036;
  11990. t['sixarabic'] = 0x0666;
  11991. t['sixbengali'] = 0x09EC;
  11992. t['sixcircle'] = 0x2465;
  11993. t['sixcircleinversesansserif'] = 0x278F;
  11994. t['sixdeva'] = 0x096C;
  11995. t['sixgujarati'] = 0x0AEC;
  11996. t['sixgurmukhi'] = 0x0A6C;
  11997. t['sixhackarabic'] = 0x0666;
  11998. t['sixhangzhou'] = 0x3026;
  11999. t['sixideographicparen'] = 0x3225;
  12000. t['sixinferior'] = 0x2086;
  12001. t['sixmonospace'] = 0xFF16;
  12002. t['sixoldstyle'] = 0xF736;
  12003. t['sixparen'] = 0x2479;
  12004. t['sixperiod'] = 0x248D;
  12005. t['sixpersian'] = 0x06F6;
  12006. t['sixroman'] = 0x2175;
  12007. t['sixsuperior'] = 0x2076;
  12008. t['sixteencircle'] = 0x246F;
  12009. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  12010. t['sixteenparen'] = 0x2483;
  12011. t['sixteenperiod'] = 0x2497;
  12012. t['sixthai'] = 0x0E56;
  12013. t['slash'] = 0x002F;
  12014. t['slashmonospace'] = 0xFF0F;
  12015. t['slong'] = 0x017F;
  12016. t['slongdotaccent'] = 0x1E9B;
  12017. t['smileface'] = 0x263A;
  12018. t['smonospace'] = 0xFF53;
  12019. t['sofpasuqhebrew'] = 0x05C3;
  12020. t['softhyphen'] = 0x00AD;
  12021. t['softsigncyrillic'] = 0x044C;
  12022. t['sohiragana'] = 0x305D;
  12023. t['sokatakana'] = 0x30BD;
  12024. t['sokatakanahalfwidth'] = 0xFF7F;
  12025. t['soliduslongoverlaycmb'] = 0x0338;
  12026. t['solidusshortoverlaycmb'] = 0x0337;
  12027. t['sorusithai'] = 0x0E29;
  12028. t['sosalathai'] = 0x0E28;
  12029. t['sosothai'] = 0x0E0B;
  12030. t['sosuathai'] = 0x0E2A;
  12031. t['space'] = 0x0020;
  12032. t['spacehackarabic'] = 0x0020;
  12033. t['spade'] = 0x2660;
  12034. t['spadesuitblack'] = 0x2660;
  12035. t['spadesuitwhite'] = 0x2664;
  12036. t['sparen'] = 0x24AE;
  12037. t['squarebelowcmb'] = 0x033B;
  12038. t['squarecc'] = 0x33C4;
  12039. t['squarecm'] = 0x339D;
  12040. t['squarediagonalcrosshatchfill'] = 0x25A9;
  12041. t['squarehorizontalfill'] = 0x25A4;
  12042. t['squarekg'] = 0x338F;
  12043. t['squarekm'] = 0x339E;
  12044. t['squarekmcapital'] = 0x33CE;
  12045. t['squareln'] = 0x33D1;
  12046. t['squarelog'] = 0x33D2;
  12047. t['squaremg'] = 0x338E;
  12048. t['squaremil'] = 0x33D5;
  12049. t['squaremm'] = 0x339C;
  12050. t['squaremsquared'] = 0x33A1;
  12051. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  12052. t['squareupperlefttolowerrightfill'] = 0x25A7;
  12053. t['squareupperrighttolowerleftfill'] = 0x25A8;
  12054. t['squareverticalfill'] = 0x25A5;
  12055. t['squarewhitewithsmallblack'] = 0x25A3;
  12056. t['srsquare'] = 0x33DB;
  12057. t['ssabengali'] = 0x09B7;
  12058. t['ssadeva'] = 0x0937;
  12059. t['ssagujarati'] = 0x0AB7;
  12060. t['ssangcieuckorean'] = 0x3149;
  12061. t['ssanghieuhkorean'] = 0x3185;
  12062. t['ssangieungkorean'] = 0x3180;
  12063. t['ssangkiyeokkorean'] = 0x3132;
  12064. t['ssangnieunkorean'] = 0x3165;
  12065. t['ssangpieupkorean'] = 0x3143;
  12066. t['ssangsioskorean'] = 0x3146;
  12067. t['ssangtikeutkorean'] = 0x3138;
  12068. t['ssuperior'] = 0xF6F2;
  12069. t['sterling'] = 0x00A3;
  12070. t['sterlingmonospace'] = 0xFFE1;
  12071. t['strokelongoverlaycmb'] = 0x0336;
  12072. t['strokeshortoverlaycmb'] = 0x0335;
  12073. t['subset'] = 0x2282;
  12074. t['subsetnotequal'] = 0x228A;
  12075. t['subsetorequal'] = 0x2286;
  12076. t['succeeds'] = 0x227B;
  12077. t['suchthat'] = 0x220B;
  12078. t['suhiragana'] = 0x3059;
  12079. t['sukatakana'] = 0x30B9;
  12080. t['sukatakanahalfwidth'] = 0xFF7D;
  12081. t['sukunarabic'] = 0x0652;
  12082. t['summation'] = 0x2211;
  12083. t['sun'] = 0x263C;
  12084. t['superset'] = 0x2283;
  12085. t['supersetnotequal'] = 0x228B;
  12086. t['supersetorequal'] = 0x2287;
  12087. t['svsquare'] = 0x33DC;
  12088. t['syouwaerasquare'] = 0x337C;
  12089. t['t'] = 0x0074;
  12090. t['tabengali'] = 0x09A4;
  12091. t['tackdown'] = 0x22A4;
  12092. t['tackleft'] = 0x22A3;
  12093. t['tadeva'] = 0x0924;
  12094. t['tagujarati'] = 0x0AA4;
  12095. t['tagurmukhi'] = 0x0A24;
  12096. t['taharabic'] = 0x0637;
  12097. t['tahfinalarabic'] = 0xFEC2;
  12098. t['tahinitialarabic'] = 0xFEC3;
  12099. t['tahiragana'] = 0x305F;
  12100. t['tahmedialarabic'] = 0xFEC4;
  12101. t['taisyouerasquare'] = 0x337D;
  12102. t['takatakana'] = 0x30BF;
  12103. t['takatakanahalfwidth'] = 0xFF80;
  12104. t['tatweelarabic'] = 0x0640;
  12105. t['tau'] = 0x03C4;
  12106. t['tav'] = 0x05EA;
  12107. t['tavdages'] = 0xFB4A;
  12108. t['tavdagesh'] = 0xFB4A;
  12109. t['tavdageshhebrew'] = 0xFB4A;
  12110. t['tavhebrew'] = 0x05EA;
  12111. t['tbar'] = 0x0167;
  12112. t['tbopomofo'] = 0x310A;
  12113. t['tcaron'] = 0x0165;
  12114. t['tccurl'] = 0x02A8;
  12115. t['tcedilla'] = 0x0163;
  12116. t['tcheharabic'] = 0x0686;
  12117. t['tchehfinalarabic'] = 0xFB7B;
  12118. t['tchehinitialarabic'] = 0xFB7C;
  12119. t['tchehmedialarabic'] = 0xFB7D;
  12120. t['tcircle'] = 0x24E3;
  12121. t['tcircumflexbelow'] = 0x1E71;
  12122. t['tcommaaccent'] = 0x0163;
  12123. t['tdieresis'] = 0x1E97;
  12124. t['tdotaccent'] = 0x1E6B;
  12125. t['tdotbelow'] = 0x1E6D;
  12126. t['tecyrillic'] = 0x0442;
  12127. t['tedescendercyrillic'] = 0x04AD;
  12128. t['teharabic'] = 0x062A;
  12129. t['tehfinalarabic'] = 0xFE96;
  12130. t['tehhahinitialarabic'] = 0xFCA2;
  12131. t['tehhahisolatedarabic'] = 0xFC0C;
  12132. t['tehinitialarabic'] = 0xFE97;
  12133. t['tehiragana'] = 0x3066;
  12134. t['tehjeeminitialarabic'] = 0xFCA1;
  12135. t['tehjeemisolatedarabic'] = 0xFC0B;
  12136. t['tehmarbutaarabic'] = 0x0629;
  12137. t['tehmarbutafinalarabic'] = 0xFE94;
  12138. t['tehmedialarabic'] = 0xFE98;
  12139. t['tehmeeminitialarabic'] = 0xFCA4;
  12140. t['tehmeemisolatedarabic'] = 0xFC0E;
  12141. t['tehnoonfinalarabic'] = 0xFC73;
  12142. t['tekatakana'] = 0x30C6;
  12143. t['tekatakanahalfwidth'] = 0xFF83;
  12144. t['telephone'] = 0x2121;
  12145. t['telephoneblack'] = 0x260E;
  12146. t['telishagedolahebrew'] = 0x05A0;
  12147. t['telishaqetanahebrew'] = 0x05A9;
  12148. t['tencircle'] = 0x2469;
  12149. t['tenideographicparen'] = 0x3229;
  12150. t['tenparen'] = 0x247D;
  12151. t['tenperiod'] = 0x2491;
  12152. t['tenroman'] = 0x2179;
  12153. t['tesh'] = 0x02A7;
  12154. t['tet'] = 0x05D8;
  12155. t['tetdagesh'] = 0xFB38;
  12156. t['tetdageshhebrew'] = 0xFB38;
  12157. t['tethebrew'] = 0x05D8;
  12158. t['tetsecyrillic'] = 0x04B5;
  12159. t['tevirhebrew'] = 0x059B;
  12160. t['tevirlefthebrew'] = 0x059B;
  12161. t['thabengali'] = 0x09A5;
  12162. t['thadeva'] = 0x0925;
  12163. t['thagujarati'] = 0x0AA5;
  12164. t['thagurmukhi'] = 0x0A25;
  12165. t['thalarabic'] = 0x0630;
  12166. t['thalfinalarabic'] = 0xFEAC;
  12167. t['thanthakhatlowleftthai'] = 0xF898;
  12168. t['thanthakhatlowrightthai'] = 0xF897;
  12169. t['thanthakhatthai'] = 0x0E4C;
  12170. t['thanthakhatupperleftthai'] = 0xF896;
  12171. t['theharabic'] = 0x062B;
  12172. t['thehfinalarabic'] = 0xFE9A;
  12173. t['thehinitialarabic'] = 0xFE9B;
  12174. t['thehmedialarabic'] = 0xFE9C;
  12175. t['thereexists'] = 0x2203;
  12176. t['therefore'] = 0x2234;
  12177. t['theta'] = 0x03B8;
  12178. t['theta1'] = 0x03D1;
  12179. t['thetasymbolgreek'] = 0x03D1;
  12180. t['thieuthacirclekorean'] = 0x3279;
  12181. t['thieuthaparenkorean'] = 0x3219;
  12182. t['thieuthcirclekorean'] = 0x326B;
  12183. t['thieuthkorean'] = 0x314C;
  12184. t['thieuthparenkorean'] = 0x320B;
  12185. t['thirteencircle'] = 0x246C;
  12186. t['thirteenparen'] = 0x2480;
  12187. t['thirteenperiod'] = 0x2494;
  12188. t['thonangmonthothai'] = 0x0E11;
  12189. t['thook'] = 0x01AD;
  12190. t['thophuthaothai'] = 0x0E12;
  12191. t['thorn'] = 0x00FE;
  12192. t['thothahanthai'] = 0x0E17;
  12193. t['thothanthai'] = 0x0E10;
  12194. t['thothongthai'] = 0x0E18;
  12195. t['thothungthai'] = 0x0E16;
  12196. t['thousandcyrillic'] = 0x0482;
  12197. t['thousandsseparatorarabic'] = 0x066C;
  12198. t['thousandsseparatorpersian'] = 0x066C;
  12199. t['three'] = 0x0033;
  12200. t['threearabic'] = 0x0663;
  12201. t['threebengali'] = 0x09E9;
  12202. t['threecircle'] = 0x2462;
  12203. t['threecircleinversesansserif'] = 0x278C;
  12204. t['threedeva'] = 0x0969;
  12205. t['threeeighths'] = 0x215C;
  12206. t['threegujarati'] = 0x0AE9;
  12207. t['threegurmukhi'] = 0x0A69;
  12208. t['threehackarabic'] = 0x0663;
  12209. t['threehangzhou'] = 0x3023;
  12210. t['threeideographicparen'] = 0x3222;
  12211. t['threeinferior'] = 0x2083;
  12212. t['threemonospace'] = 0xFF13;
  12213. t['threenumeratorbengali'] = 0x09F6;
  12214. t['threeoldstyle'] = 0xF733;
  12215. t['threeparen'] = 0x2476;
  12216. t['threeperiod'] = 0x248A;
  12217. t['threepersian'] = 0x06F3;
  12218. t['threequarters'] = 0x00BE;
  12219. t['threequartersemdash'] = 0xF6DE;
  12220. t['threeroman'] = 0x2172;
  12221. t['threesuperior'] = 0x00B3;
  12222. t['threethai'] = 0x0E53;
  12223. t['thzsquare'] = 0x3394;
  12224. t['tihiragana'] = 0x3061;
  12225. t['tikatakana'] = 0x30C1;
  12226. t['tikatakanahalfwidth'] = 0xFF81;
  12227. t['tikeutacirclekorean'] = 0x3270;
  12228. t['tikeutaparenkorean'] = 0x3210;
  12229. t['tikeutcirclekorean'] = 0x3262;
  12230. t['tikeutkorean'] = 0x3137;
  12231. t['tikeutparenkorean'] = 0x3202;
  12232. t['tilde'] = 0x02DC;
  12233. t['tildebelowcmb'] = 0x0330;
  12234. t['tildecmb'] = 0x0303;
  12235. t['tildecomb'] = 0x0303;
  12236. t['tildedoublecmb'] = 0x0360;
  12237. t['tildeoperator'] = 0x223C;
  12238. t['tildeoverlaycmb'] = 0x0334;
  12239. t['tildeverticalcmb'] = 0x033E;
  12240. t['timescircle'] = 0x2297;
  12241. t['tipehahebrew'] = 0x0596;
  12242. t['tipehalefthebrew'] = 0x0596;
  12243. t['tippigurmukhi'] = 0x0A70;
  12244. t['titlocyrilliccmb'] = 0x0483;
  12245. t['tiwnarmenian'] = 0x057F;
  12246. t['tlinebelow'] = 0x1E6F;
  12247. t['tmonospace'] = 0xFF54;
  12248. t['toarmenian'] = 0x0569;
  12249. t['tohiragana'] = 0x3068;
  12250. t['tokatakana'] = 0x30C8;
  12251. t['tokatakanahalfwidth'] = 0xFF84;
  12252. t['tonebarextrahighmod'] = 0x02E5;
  12253. t['tonebarextralowmod'] = 0x02E9;
  12254. t['tonebarhighmod'] = 0x02E6;
  12255. t['tonebarlowmod'] = 0x02E8;
  12256. t['tonebarmidmod'] = 0x02E7;
  12257. t['tonefive'] = 0x01BD;
  12258. t['tonesix'] = 0x0185;
  12259. t['tonetwo'] = 0x01A8;
  12260. t['tonos'] = 0x0384;
  12261. t['tonsquare'] = 0x3327;
  12262. t['topatakthai'] = 0x0E0F;
  12263. t['tortoiseshellbracketleft'] = 0x3014;
  12264. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  12265. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  12266. t['tortoiseshellbracketright'] = 0x3015;
  12267. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  12268. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  12269. t['totaothai'] = 0x0E15;
  12270. t['tpalatalhook'] = 0x01AB;
  12271. t['tparen'] = 0x24AF;
  12272. t['trademark'] = 0x2122;
  12273. t['trademarksans'] = 0xF8EA;
  12274. t['trademarkserif'] = 0xF6DB;
  12275. t['tretroflexhook'] = 0x0288;
  12276. t['triagdn'] = 0x25BC;
  12277. t['triaglf'] = 0x25C4;
  12278. t['triagrt'] = 0x25BA;
  12279. t['triagup'] = 0x25B2;
  12280. t['ts'] = 0x02A6;
  12281. t['tsadi'] = 0x05E6;
  12282. t['tsadidagesh'] = 0xFB46;
  12283. t['tsadidageshhebrew'] = 0xFB46;
  12284. t['tsadihebrew'] = 0x05E6;
  12285. t['tsecyrillic'] = 0x0446;
  12286. t['tsere'] = 0x05B5;
  12287. t['tsere12'] = 0x05B5;
  12288. t['tsere1e'] = 0x05B5;
  12289. t['tsere2b'] = 0x05B5;
  12290. t['tserehebrew'] = 0x05B5;
  12291. t['tserenarrowhebrew'] = 0x05B5;
  12292. t['tserequarterhebrew'] = 0x05B5;
  12293. t['tserewidehebrew'] = 0x05B5;
  12294. t['tshecyrillic'] = 0x045B;
  12295. t['tsuperior'] = 0xF6F3;
  12296. t['ttabengali'] = 0x099F;
  12297. t['ttadeva'] = 0x091F;
  12298. t['ttagujarati'] = 0x0A9F;
  12299. t['ttagurmukhi'] = 0x0A1F;
  12300. t['tteharabic'] = 0x0679;
  12301. t['ttehfinalarabic'] = 0xFB67;
  12302. t['ttehinitialarabic'] = 0xFB68;
  12303. t['ttehmedialarabic'] = 0xFB69;
  12304. t['tthabengali'] = 0x09A0;
  12305. t['tthadeva'] = 0x0920;
  12306. t['tthagujarati'] = 0x0AA0;
  12307. t['tthagurmukhi'] = 0x0A20;
  12308. t['tturned'] = 0x0287;
  12309. t['tuhiragana'] = 0x3064;
  12310. t['tukatakana'] = 0x30C4;
  12311. t['tukatakanahalfwidth'] = 0xFF82;
  12312. t['tusmallhiragana'] = 0x3063;
  12313. t['tusmallkatakana'] = 0x30C3;
  12314. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  12315. t['twelvecircle'] = 0x246B;
  12316. t['twelveparen'] = 0x247F;
  12317. t['twelveperiod'] = 0x2493;
  12318. t['twelveroman'] = 0x217B;
  12319. t['twentycircle'] = 0x2473;
  12320. t['twentyhangzhou'] = 0x5344;
  12321. t['twentyparen'] = 0x2487;
  12322. t['twentyperiod'] = 0x249B;
  12323. t['two'] = 0x0032;
  12324. t['twoarabic'] = 0x0662;
  12325. t['twobengali'] = 0x09E8;
  12326. t['twocircle'] = 0x2461;
  12327. t['twocircleinversesansserif'] = 0x278B;
  12328. t['twodeva'] = 0x0968;
  12329. t['twodotenleader'] = 0x2025;
  12330. t['twodotleader'] = 0x2025;
  12331. t['twodotleadervertical'] = 0xFE30;
  12332. t['twogujarati'] = 0x0AE8;
  12333. t['twogurmukhi'] = 0x0A68;
  12334. t['twohackarabic'] = 0x0662;
  12335. t['twohangzhou'] = 0x3022;
  12336. t['twoideographicparen'] = 0x3221;
  12337. t['twoinferior'] = 0x2082;
  12338. t['twomonospace'] = 0xFF12;
  12339. t['twonumeratorbengali'] = 0x09F5;
  12340. t['twooldstyle'] = 0xF732;
  12341. t['twoparen'] = 0x2475;
  12342. t['twoperiod'] = 0x2489;
  12343. t['twopersian'] = 0x06F2;
  12344. t['tworoman'] = 0x2171;
  12345. t['twostroke'] = 0x01BB;
  12346. t['twosuperior'] = 0x00B2;
  12347. t['twothai'] = 0x0E52;
  12348. t['twothirds'] = 0x2154;
  12349. t['u'] = 0x0075;
  12350. t['uacute'] = 0x00FA;
  12351. t['ubar'] = 0x0289;
  12352. t['ubengali'] = 0x0989;
  12353. t['ubopomofo'] = 0x3128;
  12354. t['ubreve'] = 0x016D;
  12355. t['ucaron'] = 0x01D4;
  12356. t['ucircle'] = 0x24E4;
  12357. t['ucircumflex'] = 0x00FB;
  12358. t['ucircumflexbelow'] = 0x1E77;
  12359. t['ucyrillic'] = 0x0443;
  12360. t['udattadeva'] = 0x0951;
  12361. t['udblacute'] = 0x0171;
  12362. t['udblgrave'] = 0x0215;
  12363. t['udeva'] = 0x0909;
  12364. t['udieresis'] = 0x00FC;
  12365. t['udieresisacute'] = 0x01D8;
  12366. t['udieresisbelow'] = 0x1E73;
  12367. t['udieresiscaron'] = 0x01DA;
  12368. t['udieresiscyrillic'] = 0x04F1;
  12369. t['udieresisgrave'] = 0x01DC;
  12370. t['udieresismacron'] = 0x01D6;
  12371. t['udotbelow'] = 0x1EE5;
  12372. t['ugrave'] = 0x00F9;
  12373. t['ugujarati'] = 0x0A89;
  12374. t['ugurmukhi'] = 0x0A09;
  12375. t['uhiragana'] = 0x3046;
  12376. t['uhookabove'] = 0x1EE7;
  12377. t['uhorn'] = 0x01B0;
  12378. t['uhornacute'] = 0x1EE9;
  12379. t['uhorndotbelow'] = 0x1EF1;
  12380. t['uhorngrave'] = 0x1EEB;
  12381. t['uhornhookabove'] = 0x1EED;
  12382. t['uhorntilde'] = 0x1EEF;
  12383. t['uhungarumlaut'] = 0x0171;
  12384. t['uhungarumlautcyrillic'] = 0x04F3;
  12385. t['uinvertedbreve'] = 0x0217;
  12386. t['ukatakana'] = 0x30A6;
  12387. t['ukatakanahalfwidth'] = 0xFF73;
  12388. t['ukcyrillic'] = 0x0479;
  12389. t['ukorean'] = 0x315C;
  12390. t['umacron'] = 0x016B;
  12391. t['umacroncyrillic'] = 0x04EF;
  12392. t['umacrondieresis'] = 0x1E7B;
  12393. t['umatragurmukhi'] = 0x0A41;
  12394. t['umonospace'] = 0xFF55;
  12395. t['underscore'] = 0x005F;
  12396. t['underscoredbl'] = 0x2017;
  12397. t['underscoremonospace'] = 0xFF3F;
  12398. t['underscorevertical'] = 0xFE33;
  12399. t['underscorewavy'] = 0xFE4F;
  12400. t['union'] = 0x222A;
  12401. t['universal'] = 0x2200;
  12402. t['uogonek'] = 0x0173;
  12403. t['uparen'] = 0x24B0;
  12404. t['upblock'] = 0x2580;
  12405. t['upperdothebrew'] = 0x05C4;
  12406. t['upsilon'] = 0x03C5;
  12407. t['upsilondieresis'] = 0x03CB;
  12408. t['upsilondieresistonos'] = 0x03B0;
  12409. t['upsilonlatin'] = 0x028A;
  12410. t['upsilontonos'] = 0x03CD;
  12411. t['uptackbelowcmb'] = 0x031D;
  12412. t['uptackmod'] = 0x02D4;
  12413. t['uragurmukhi'] = 0x0A73;
  12414. t['uring'] = 0x016F;
  12415. t['ushortcyrillic'] = 0x045E;
  12416. t['usmallhiragana'] = 0x3045;
  12417. t['usmallkatakana'] = 0x30A5;
  12418. t['usmallkatakanahalfwidth'] = 0xFF69;
  12419. t['ustraightcyrillic'] = 0x04AF;
  12420. t['ustraightstrokecyrillic'] = 0x04B1;
  12421. t['utilde'] = 0x0169;
  12422. t['utildeacute'] = 0x1E79;
  12423. t['utildebelow'] = 0x1E75;
  12424. t['uubengali'] = 0x098A;
  12425. t['uudeva'] = 0x090A;
  12426. t['uugujarati'] = 0x0A8A;
  12427. t['uugurmukhi'] = 0x0A0A;
  12428. t['uumatragurmukhi'] = 0x0A42;
  12429. t['uuvowelsignbengali'] = 0x09C2;
  12430. t['uuvowelsigndeva'] = 0x0942;
  12431. t['uuvowelsigngujarati'] = 0x0AC2;
  12432. t['uvowelsignbengali'] = 0x09C1;
  12433. t['uvowelsigndeva'] = 0x0941;
  12434. t['uvowelsigngujarati'] = 0x0AC1;
  12435. t['v'] = 0x0076;
  12436. t['vadeva'] = 0x0935;
  12437. t['vagujarati'] = 0x0AB5;
  12438. t['vagurmukhi'] = 0x0A35;
  12439. t['vakatakana'] = 0x30F7;
  12440. t['vav'] = 0x05D5;
  12441. t['vavdagesh'] = 0xFB35;
  12442. t['vavdagesh65'] = 0xFB35;
  12443. t['vavdageshhebrew'] = 0xFB35;
  12444. t['vavhebrew'] = 0x05D5;
  12445. t['vavholam'] = 0xFB4B;
  12446. t['vavholamhebrew'] = 0xFB4B;
  12447. t['vavvavhebrew'] = 0x05F0;
  12448. t['vavyodhebrew'] = 0x05F1;
  12449. t['vcircle'] = 0x24E5;
  12450. t['vdotbelow'] = 0x1E7F;
  12451. t['vecyrillic'] = 0x0432;
  12452. t['veharabic'] = 0x06A4;
  12453. t['vehfinalarabic'] = 0xFB6B;
  12454. t['vehinitialarabic'] = 0xFB6C;
  12455. t['vehmedialarabic'] = 0xFB6D;
  12456. t['vekatakana'] = 0x30F9;
  12457. t['venus'] = 0x2640;
  12458. t['verticalbar'] = 0x007C;
  12459. t['verticallineabovecmb'] = 0x030D;
  12460. t['verticallinebelowcmb'] = 0x0329;
  12461. t['verticallinelowmod'] = 0x02CC;
  12462. t['verticallinemod'] = 0x02C8;
  12463. t['vewarmenian'] = 0x057E;
  12464. t['vhook'] = 0x028B;
  12465. t['vikatakana'] = 0x30F8;
  12466. t['viramabengali'] = 0x09CD;
  12467. t['viramadeva'] = 0x094D;
  12468. t['viramagujarati'] = 0x0ACD;
  12469. t['visargabengali'] = 0x0983;
  12470. t['visargadeva'] = 0x0903;
  12471. t['visargagujarati'] = 0x0A83;
  12472. t['vmonospace'] = 0xFF56;
  12473. t['voarmenian'] = 0x0578;
  12474. t['voicediterationhiragana'] = 0x309E;
  12475. t['voicediterationkatakana'] = 0x30FE;
  12476. t['voicedmarkkana'] = 0x309B;
  12477. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  12478. t['vokatakana'] = 0x30FA;
  12479. t['vparen'] = 0x24B1;
  12480. t['vtilde'] = 0x1E7D;
  12481. t['vturned'] = 0x028C;
  12482. t['vuhiragana'] = 0x3094;
  12483. t['vukatakana'] = 0x30F4;
  12484. t['w'] = 0x0077;
  12485. t['wacute'] = 0x1E83;
  12486. t['waekorean'] = 0x3159;
  12487. t['wahiragana'] = 0x308F;
  12488. t['wakatakana'] = 0x30EF;
  12489. t['wakatakanahalfwidth'] = 0xFF9C;
  12490. t['wakorean'] = 0x3158;
  12491. t['wasmallhiragana'] = 0x308E;
  12492. t['wasmallkatakana'] = 0x30EE;
  12493. t['wattosquare'] = 0x3357;
  12494. t['wavedash'] = 0x301C;
  12495. t['wavyunderscorevertical'] = 0xFE34;
  12496. t['wawarabic'] = 0x0648;
  12497. t['wawfinalarabic'] = 0xFEEE;
  12498. t['wawhamzaabovearabic'] = 0x0624;
  12499. t['wawhamzaabovefinalarabic'] = 0xFE86;
  12500. t['wbsquare'] = 0x33DD;
  12501. t['wcircle'] = 0x24E6;
  12502. t['wcircumflex'] = 0x0175;
  12503. t['wdieresis'] = 0x1E85;
  12504. t['wdotaccent'] = 0x1E87;
  12505. t['wdotbelow'] = 0x1E89;
  12506. t['wehiragana'] = 0x3091;
  12507. t['weierstrass'] = 0x2118;
  12508. t['wekatakana'] = 0x30F1;
  12509. t['wekorean'] = 0x315E;
  12510. t['weokorean'] = 0x315D;
  12511. t['wgrave'] = 0x1E81;
  12512. t['whitebullet'] = 0x25E6;
  12513. t['whitecircle'] = 0x25CB;
  12514. t['whitecircleinverse'] = 0x25D9;
  12515. t['whitecornerbracketleft'] = 0x300E;
  12516. t['whitecornerbracketleftvertical'] = 0xFE43;
  12517. t['whitecornerbracketright'] = 0x300F;
  12518. t['whitecornerbracketrightvertical'] = 0xFE44;
  12519. t['whitediamond'] = 0x25C7;
  12520. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  12521. t['whitedownpointingsmalltriangle'] = 0x25BF;
  12522. t['whitedownpointingtriangle'] = 0x25BD;
  12523. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  12524. t['whiteleftpointingtriangle'] = 0x25C1;
  12525. t['whitelenticularbracketleft'] = 0x3016;
  12526. t['whitelenticularbracketright'] = 0x3017;
  12527. t['whiterightpointingsmalltriangle'] = 0x25B9;
  12528. t['whiterightpointingtriangle'] = 0x25B7;
  12529. t['whitesmallsquare'] = 0x25AB;
  12530. t['whitesmilingface'] = 0x263A;
  12531. t['whitesquare'] = 0x25A1;
  12532. t['whitestar'] = 0x2606;
  12533. t['whitetelephone'] = 0x260F;
  12534. t['whitetortoiseshellbracketleft'] = 0x3018;
  12535. t['whitetortoiseshellbracketright'] = 0x3019;
  12536. t['whiteuppointingsmalltriangle'] = 0x25B5;
  12537. t['whiteuppointingtriangle'] = 0x25B3;
  12538. t['wihiragana'] = 0x3090;
  12539. t['wikatakana'] = 0x30F0;
  12540. t['wikorean'] = 0x315F;
  12541. t['wmonospace'] = 0xFF57;
  12542. t['wohiragana'] = 0x3092;
  12543. t['wokatakana'] = 0x30F2;
  12544. t['wokatakanahalfwidth'] = 0xFF66;
  12545. t['won'] = 0x20A9;
  12546. t['wonmonospace'] = 0xFFE6;
  12547. t['wowaenthai'] = 0x0E27;
  12548. t['wparen'] = 0x24B2;
  12549. t['wring'] = 0x1E98;
  12550. t['wsuperior'] = 0x02B7;
  12551. t['wturned'] = 0x028D;
  12552. t['wynn'] = 0x01BF;
  12553. t['x'] = 0x0078;
  12554. t['xabovecmb'] = 0x033D;
  12555. t['xbopomofo'] = 0x3112;
  12556. t['xcircle'] = 0x24E7;
  12557. t['xdieresis'] = 0x1E8D;
  12558. t['xdotaccent'] = 0x1E8B;
  12559. t['xeharmenian'] = 0x056D;
  12560. t['xi'] = 0x03BE;
  12561. t['xmonospace'] = 0xFF58;
  12562. t['xparen'] = 0x24B3;
  12563. t['xsuperior'] = 0x02E3;
  12564. t['y'] = 0x0079;
  12565. t['yaadosquare'] = 0x334E;
  12566. t['yabengali'] = 0x09AF;
  12567. t['yacute'] = 0x00FD;
  12568. t['yadeva'] = 0x092F;
  12569. t['yaekorean'] = 0x3152;
  12570. t['yagujarati'] = 0x0AAF;
  12571. t['yagurmukhi'] = 0x0A2F;
  12572. t['yahiragana'] = 0x3084;
  12573. t['yakatakana'] = 0x30E4;
  12574. t['yakatakanahalfwidth'] = 0xFF94;
  12575. t['yakorean'] = 0x3151;
  12576. t['yamakkanthai'] = 0x0E4E;
  12577. t['yasmallhiragana'] = 0x3083;
  12578. t['yasmallkatakana'] = 0x30E3;
  12579. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  12580. t['yatcyrillic'] = 0x0463;
  12581. t['ycircle'] = 0x24E8;
  12582. t['ycircumflex'] = 0x0177;
  12583. t['ydieresis'] = 0x00FF;
  12584. t['ydotaccent'] = 0x1E8F;
  12585. t['ydotbelow'] = 0x1EF5;
  12586. t['yeharabic'] = 0x064A;
  12587. t['yehbarreearabic'] = 0x06D2;
  12588. t['yehbarreefinalarabic'] = 0xFBAF;
  12589. t['yehfinalarabic'] = 0xFEF2;
  12590. t['yehhamzaabovearabic'] = 0x0626;
  12591. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  12592. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  12593. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  12594. t['yehinitialarabic'] = 0xFEF3;
  12595. t['yehmedialarabic'] = 0xFEF4;
  12596. t['yehmeeminitialarabic'] = 0xFCDD;
  12597. t['yehmeemisolatedarabic'] = 0xFC58;
  12598. t['yehnoonfinalarabic'] = 0xFC94;
  12599. t['yehthreedotsbelowarabic'] = 0x06D1;
  12600. t['yekorean'] = 0x3156;
  12601. t['yen'] = 0x00A5;
  12602. t['yenmonospace'] = 0xFFE5;
  12603. t['yeokorean'] = 0x3155;
  12604. t['yeorinhieuhkorean'] = 0x3186;
  12605. t['yerahbenyomohebrew'] = 0x05AA;
  12606. t['yerahbenyomolefthebrew'] = 0x05AA;
  12607. t['yericyrillic'] = 0x044B;
  12608. t['yerudieresiscyrillic'] = 0x04F9;
  12609. t['yesieungkorean'] = 0x3181;
  12610. t['yesieungpansioskorean'] = 0x3183;
  12611. t['yesieungsioskorean'] = 0x3182;
  12612. t['yetivhebrew'] = 0x059A;
  12613. t['ygrave'] = 0x1EF3;
  12614. t['yhook'] = 0x01B4;
  12615. t['yhookabove'] = 0x1EF7;
  12616. t['yiarmenian'] = 0x0575;
  12617. t['yicyrillic'] = 0x0457;
  12618. t['yikorean'] = 0x3162;
  12619. t['yinyang'] = 0x262F;
  12620. t['yiwnarmenian'] = 0x0582;
  12621. t['ymonospace'] = 0xFF59;
  12622. t['yod'] = 0x05D9;
  12623. t['yoddagesh'] = 0xFB39;
  12624. t['yoddageshhebrew'] = 0xFB39;
  12625. t['yodhebrew'] = 0x05D9;
  12626. t['yodyodhebrew'] = 0x05F2;
  12627. t['yodyodpatahhebrew'] = 0xFB1F;
  12628. t['yohiragana'] = 0x3088;
  12629. t['yoikorean'] = 0x3189;
  12630. t['yokatakana'] = 0x30E8;
  12631. t['yokatakanahalfwidth'] = 0xFF96;
  12632. t['yokorean'] = 0x315B;
  12633. t['yosmallhiragana'] = 0x3087;
  12634. t['yosmallkatakana'] = 0x30E7;
  12635. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  12636. t['yotgreek'] = 0x03F3;
  12637. t['yoyaekorean'] = 0x3188;
  12638. t['yoyakorean'] = 0x3187;
  12639. t['yoyakthai'] = 0x0E22;
  12640. t['yoyingthai'] = 0x0E0D;
  12641. t['yparen'] = 0x24B4;
  12642. t['ypogegrammeni'] = 0x037A;
  12643. t['ypogegrammenigreekcmb'] = 0x0345;
  12644. t['yr'] = 0x01A6;
  12645. t['yring'] = 0x1E99;
  12646. t['ysuperior'] = 0x02B8;
  12647. t['ytilde'] = 0x1EF9;
  12648. t['yturned'] = 0x028E;
  12649. t['yuhiragana'] = 0x3086;
  12650. t['yuikorean'] = 0x318C;
  12651. t['yukatakana'] = 0x30E6;
  12652. t['yukatakanahalfwidth'] = 0xFF95;
  12653. t['yukorean'] = 0x3160;
  12654. t['yusbigcyrillic'] = 0x046B;
  12655. t['yusbigiotifiedcyrillic'] = 0x046D;
  12656. t['yuslittlecyrillic'] = 0x0467;
  12657. t['yuslittleiotifiedcyrillic'] = 0x0469;
  12658. t['yusmallhiragana'] = 0x3085;
  12659. t['yusmallkatakana'] = 0x30E5;
  12660. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  12661. t['yuyekorean'] = 0x318B;
  12662. t['yuyeokorean'] = 0x318A;
  12663. t['yyabengali'] = 0x09DF;
  12664. t['yyadeva'] = 0x095F;
  12665. t['z'] = 0x007A;
  12666. t['zaarmenian'] = 0x0566;
  12667. t['zacute'] = 0x017A;
  12668. t['zadeva'] = 0x095B;
  12669. t['zagurmukhi'] = 0x0A5B;
  12670. t['zaharabic'] = 0x0638;
  12671. t['zahfinalarabic'] = 0xFEC6;
  12672. t['zahinitialarabic'] = 0xFEC7;
  12673. t['zahiragana'] = 0x3056;
  12674. t['zahmedialarabic'] = 0xFEC8;
  12675. t['zainarabic'] = 0x0632;
  12676. t['zainfinalarabic'] = 0xFEB0;
  12677. t['zakatakana'] = 0x30B6;
  12678. t['zaqefgadolhebrew'] = 0x0595;
  12679. t['zaqefqatanhebrew'] = 0x0594;
  12680. t['zarqahebrew'] = 0x0598;
  12681. t['zayin'] = 0x05D6;
  12682. t['zayindagesh'] = 0xFB36;
  12683. t['zayindageshhebrew'] = 0xFB36;
  12684. t['zayinhebrew'] = 0x05D6;
  12685. t['zbopomofo'] = 0x3117;
  12686. t['zcaron'] = 0x017E;
  12687. t['zcircle'] = 0x24E9;
  12688. t['zcircumflex'] = 0x1E91;
  12689. t['zcurl'] = 0x0291;
  12690. t['zdot'] = 0x017C;
  12691. t['zdotaccent'] = 0x017C;
  12692. t['zdotbelow'] = 0x1E93;
  12693. t['zecyrillic'] = 0x0437;
  12694. t['zedescendercyrillic'] = 0x0499;
  12695. t['zedieresiscyrillic'] = 0x04DF;
  12696. t['zehiragana'] = 0x305C;
  12697. t['zekatakana'] = 0x30BC;
  12698. t['zero'] = 0x0030;
  12699. t['zeroarabic'] = 0x0660;
  12700. t['zerobengali'] = 0x09E6;
  12701. t['zerodeva'] = 0x0966;
  12702. t['zerogujarati'] = 0x0AE6;
  12703. t['zerogurmukhi'] = 0x0A66;
  12704. t['zerohackarabic'] = 0x0660;
  12705. t['zeroinferior'] = 0x2080;
  12706. t['zeromonospace'] = 0xFF10;
  12707. t['zerooldstyle'] = 0xF730;
  12708. t['zeropersian'] = 0x06F0;
  12709. t['zerosuperior'] = 0x2070;
  12710. t['zerothai'] = 0x0E50;
  12711. t['zerowidthjoiner'] = 0xFEFF;
  12712. t['zerowidthnonjoiner'] = 0x200C;
  12713. t['zerowidthspace'] = 0x200B;
  12714. t['zeta'] = 0x03B6;
  12715. t['zhbopomofo'] = 0x3113;
  12716. t['zhearmenian'] = 0x056A;
  12717. t['zhebrevecyrillic'] = 0x04C2;
  12718. t['zhecyrillic'] = 0x0436;
  12719. t['zhedescendercyrillic'] = 0x0497;
  12720. t['zhedieresiscyrillic'] = 0x04DD;
  12721. t['zihiragana'] = 0x3058;
  12722. t['zikatakana'] = 0x30B8;
  12723. t['zinorhebrew'] = 0x05AE;
  12724. t['zlinebelow'] = 0x1E95;
  12725. t['zmonospace'] = 0xFF5A;
  12726. t['zohiragana'] = 0x305E;
  12727. t['zokatakana'] = 0x30BE;
  12728. t['zparen'] = 0x24B5;
  12729. t['zretroflexhook'] = 0x0290;
  12730. t['zstroke'] = 0x01B6;
  12731. t['zuhiragana'] = 0x305A;
  12732. t['zukatakana'] = 0x30BA;
  12733. t['.notdef'] = 0x0000;
  12734. t['angbracketleftbig'] = 0x2329;
  12735. t['angbracketleftBig'] = 0x2329;
  12736. t['angbracketleftbigg'] = 0x2329;
  12737. t['angbracketleftBigg'] = 0x2329;
  12738. t['angbracketrightBig'] = 0x232A;
  12739. t['angbracketrightbig'] = 0x232A;
  12740. t['angbracketrightBigg'] = 0x232A;
  12741. t['angbracketrightbigg'] = 0x232A;
  12742. t['arrowhookleft'] = 0x21AA;
  12743. t['arrowhookright'] = 0x21A9;
  12744. t['arrowlefttophalf'] = 0x21BC;
  12745. t['arrowleftbothalf'] = 0x21BD;
  12746. t['arrownortheast'] = 0x2197;
  12747. t['arrownorthwest'] = 0x2196;
  12748. t['arrowrighttophalf'] = 0x21C0;
  12749. t['arrowrightbothalf'] = 0x21C1;
  12750. t['arrowsoutheast'] = 0x2198;
  12751. t['arrowsouthwest'] = 0x2199;
  12752. t['backslashbig'] = 0x2216;
  12753. t['backslashBig'] = 0x2216;
  12754. t['backslashBigg'] = 0x2216;
  12755. t['backslashbigg'] = 0x2216;
  12756. t['bardbl'] = 0x2016;
  12757. t['bracehtipdownleft'] = 0xFE37;
  12758. t['bracehtipdownright'] = 0xFE37;
  12759. t['bracehtipupleft'] = 0xFE38;
  12760. t['bracehtipupright'] = 0xFE38;
  12761. t['braceleftBig'] = 0x007B;
  12762. t['braceleftbig'] = 0x007B;
  12763. t['braceleftbigg'] = 0x007B;
  12764. t['braceleftBigg'] = 0x007B;
  12765. t['bracerightBig'] = 0x007D;
  12766. t['bracerightbig'] = 0x007D;
  12767. t['bracerightbigg'] = 0x007D;
  12768. t['bracerightBigg'] = 0x007D;
  12769. t['bracketleftbig'] = 0x005B;
  12770. t['bracketleftBig'] = 0x005B;
  12771. t['bracketleftbigg'] = 0x005B;
  12772. t['bracketleftBigg'] = 0x005B;
  12773. t['bracketrightBig'] = 0x005D;
  12774. t['bracketrightbig'] = 0x005D;
  12775. t['bracketrightbigg'] = 0x005D;
  12776. t['bracketrightBigg'] = 0x005D;
  12777. t['ceilingleftbig'] = 0x2308;
  12778. t['ceilingleftBig'] = 0x2308;
  12779. t['ceilingleftBigg'] = 0x2308;
  12780. t['ceilingleftbigg'] = 0x2308;
  12781. t['ceilingrightbig'] = 0x2309;
  12782. t['ceilingrightBig'] = 0x2309;
  12783. t['ceilingrightbigg'] = 0x2309;
  12784. t['ceilingrightBigg'] = 0x2309;
  12785. t['circledotdisplay'] = 0x2299;
  12786. t['circledottext'] = 0x2299;
  12787. t['circlemultiplydisplay'] = 0x2297;
  12788. t['circlemultiplytext'] = 0x2297;
  12789. t['circleplusdisplay'] = 0x2295;
  12790. t['circleplustext'] = 0x2295;
  12791. t['contintegraldisplay'] = 0x222E;
  12792. t['contintegraltext'] = 0x222E;
  12793. t['coproductdisplay'] = 0x2210;
  12794. t['coproducttext'] = 0x2210;
  12795. t['floorleftBig'] = 0x230A;
  12796. t['floorleftbig'] = 0x230A;
  12797. t['floorleftbigg'] = 0x230A;
  12798. t['floorleftBigg'] = 0x230A;
  12799. t['floorrightbig'] = 0x230B;
  12800. t['floorrightBig'] = 0x230B;
  12801. t['floorrightBigg'] = 0x230B;
  12802. t['floorrightbigg'] = 0x230B;
  12803. t['hatwide'] = 0x0302;
  12804. t['hatwider'] = 0x0302;
  12805. t['hatwidest'] = 0x0302;
  12806. t['intercal'] = 0x1D40;
  12807. t['integraldisplay'] = 0x222B;
  12808. t['integraltext'] = 0x222B;
  12809. t['intersectiondisplay'] = 0x22C2;
  12810. t['intersectiontext'] = 0x22C2;
  12811. t['logicalanddisplay'] = 0x2227;
  12812. t['logicalandtext'] = 0x2227;
  12813. t['logicalordisplay'] = 0x2228;
  12814. t['logicalortext'] = 0x2228;
  12815. t['parenleftBig'] = 0x0028;
  12816. t['parenleftbig'] = 0x0028;
  12817. t['parenleftBigg'] = 0x0028;
  12818. t['parenleftbigg'] = 0x0028;
  12819. t['parenrightBig'] = 0x0029;
  12820. t['parenrightbig'] = 0x0029;
  12821. t['parenrightBigg'] = 0x0029;
  12822. t['parenrightbigg'] = 0x0029;
  12823. t['prime'] = 0x2032;
  12824. t['productdisplay'] = 0x220F;
  12825. t['producttext'] = 0x220F;
  12826. t['radicalbig'] = 0x221A;
  12827. t['radicalBig'] = 0x221A;
  12828. t['radicalBigg'] = 0x221A;
  12829. t['radicalbigg'] = 0x221A;
  12830. t['radicalbt'] = 0x221A;
  12831. t['radicaltp'] = 0x221A;
  12832. t['radicalvertex'] = 0x221A;
  12833. t['slashbig'] = 0x002F;
  12834. t['slashBig'] = 0x002F;
  12835. t['slashBigg'] = 0x002F;
  12836. t['slashbigg'] = 0x002F;
  12837. t['summationdisplay'] = 0x2211;
  12838. t['summationtext'] = 0x2211;
  12839. t['tildewide'] = 0x02DC;
  12840. t['tildewider'] = 0x02DC;
  12841. t['tildewidest'] = 0x02DC;
  12842. t['uniondisplay'] = 0x22C3;
  12843. t['unionmultidisplay'] = 0x228E;
  12844. t['unionmultitext'] = 0x228E;
  12845. t['unionsqdisplay'] = 0x2294;
  12846. t['unionsqtext'] = 0x2294;
  12847. t['uniontext'] = 0x22C3;
  12848. t['vextenddouble'] = 0x2225;
  12849. t['vextendsingle'] = 0x2223;
  12850. });
  12851. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  12852. t['space'] = 0x0020;
  12853. t['a1'] = 0x2701;
  12854. t['a2'] = 0x2702;
  12855. t['a202'] = 0x2703;
  12856. t['a3'] = 0x2704;
  12857. t['a4'] = 0x260E;
  12858. t['a5'] = 0x2706;
  12859. t['a119'] = 0x2707;
  12860. t['a118'] = 0x2708;
  12861. t['a117'] = 0x2709;
  12862. t['a11'] = 0x261B;
  12863. t['a12'] = 0x261E;
  12864. t['a13'] = 0x270C;
  12865. t['a14'] = 0x270D;
  12866. t['a15'] = 0x270E;
  12867. t['a16'] = 0x270F;
  12868. t['a105'] = 0x2710;
  12869. t['a17'] = 0x2711;
  12870. t['a18'] = 0x2712;
  12871. t['a19'] = 0x2713;
  12872. t['a20'] = 0x2714;
  12873. t['a21'] = 0x2715;
  12874. t['a22'] = 0x2716;
  12875. t['a23'] = 0x2717;
  12876. t['a24'] = 0x2718;
  12877. t['a25'] = 0x2719;
  12878. t['a26'] = 0x271A;
  12879. t['a27'] = 0x271B;
  12880. t['a28'] = 0x271C;
  12881. t['a6'] = 0x271D;
  12882. t['a7'] = 0x271E;
  12883. t['a8'] = 0x271F;
  12884. t['a9'] = 0x2720;
  12885. t['a10'] = 0x2721;
  12886. t['a29'] = 0x2722;
  12887. t['a30'] = 0x2723;
  12888. t['a31'] = 0x2724;
  12889. t['a32'] = 0x2725;
  12890. t['a33'] = 0x2726;
  12891. t['a34'] = 0x2727;
  12892. t['a35'] = 0x2605;
  12893. t['a36'] = 0x2729;
  12894. t['a37'] = 0x272A;
  12895. t['a38'] = 0x272B;
  12896. t['a39'] = 0x272C;
  12897. t['a40'] = 0x272D;
  12898. t['a41'] = 0x272E;
  12899. t['a42'] = 0x272F;
  12900. t['a43'] = 0x2730;
  12901. t['a44'] = 0x2731;
  12902. t['a45'] = 0x2732;
  12903. t['a46'] = 0x2733;
  12904. t['a47'] = 0x2734;
  12905. t['a48'] = 0x2735;
  12906. t['a49'] = 0x2736;
  12907. t['a50'] = 0x2737;
  12908. t['a51'] = 0x2738;
  12909. t['a52'] = 0x2739;
  12910. t['a53'] = 0x273A;
  12911. t['a54'] = 0x273B;
  12912. t['a55'] = 0x273C;
  12913. t['a56'] = 0x273D;
  12914. t['a57'] = 0x273E;
  12915. t['a58'] = 0x273F;
  12916. t['a59'] = 0x2740;
  12917. t['a60'] = 0x2741;
  12918. t['a61'] = 0x2742;
  12919. t['a62'] = 0x2743;
  12920. t['a63'] = 0x2744;
  12921. t['a64'] = 0x2745;
  12922. t['a65'] = 0x2746;
  12923. t['a66'] = 0x2747;
  12924. t['a67'] = 0x2748;
  12925. t['a68'] = 0x2749;
  12926. t['a69'] = 0x274A;
  12927. t['a70'] = 0x274B;
  12928. t['a71'] = 0x25CF;
  12929. t['a72'] = 0x274D;
  12930. t['a73'] = 0x25A0;
  12931. t['a74'] = 0x274F;
  12932. t['a203'] = 0x2750;
  12933. t['a75'] = 0x2751;
  12934. t['a204'] = 0x2752;
  12935. t['a76'] = 0x25B2;
  12936. t['a77'] = 0x25BC;
  12937. t['a78'] = 0x25C6;
  12938. t['a79'] = 0x2756;
  12939. t['a81'] = 0x25D7;
  12940. t['a82'] = 0x2758;
  12941. t['a83'] = 0x2759;
  12942. t['a84'] = 0x275A;
  12943. t['a97'] = 0x275B;
  12944. t['a98'] = 0x275C;
  12945. t['a99'] = 0x275D;
  12946. t['a100'] = 0x275E;
  12947. t['a101'] = 0x2761;
  12948. t['a102'] = 0x2762;
  12949. t['a103'] = 0x2763;
  12950. t['a104'] = 0x2764;
  12951. t['a106'] = 0x2765;
  12952. t['a107'] = 0x2766;
  12953. t['a108'] = 0x2767;
  12954. t['a112'] = 0x2663;
  12955. t['a111'] = 0x2666;
  12956. t['a110'] = 0x2665;
  12957. t['a109'] = 0x2660;
  12958. t['a120'] = 0x2460;
  12959. t['a121'] = 0x2461;
  12960. t['a122'] = 0x2462;
  12961. t['a123'] = 0x2463;
  12962. t['a124'] = 0x2464;
  12963. t['a125'] = 0x2465;
  12964. t['a126'] = 0x2466;
  12965. t['a127'] = 0x2467;
  12966. t['a128'] = 0x2468;
  12967. t['a129'] = 0x2469;
  12968. t['a130'] = 0x2776;
  12969. t['a131'] = 0x2777;
  12970. t['a132'] = 0x2778;
  12971. t['a133'] = 0x2779;
  12972. t['a134'] = 0x277A;
  12973. t['a135'] = 0x277B;
  12974. t['a136'] = 0x277C;
  12975. t['a137'] = 0x277D;
  12976. t['a138'] = 0x277E;
  12977. t['a139'] = 0x277F;
  12978. t['a140'] = 0x2780;
  12979. t['a141'] = 0x2781;
  12980. t['a142'] = 0x2782;
  12981. t['a143'] = 0x2783;
  12982. t['a144'] = 0x2784;
  12983. t['a145'] = 0x2785;
  12984. t['a146'] = 0x2786;
  12985. t['a147'] = 0x2787;
  12986. t['a148'] = 0x2788;
  12987. t['a149'] = 0x2789;
  12988. t['a150'] = 0x278A;
  12989. t['a151'] = 0x278B;
  12990. t['a152'] = 0x278C;
  12991. t['a153'] = 0x278D;
  12992. t['a154'] = 0x278E;
  12993. t['a155'] = 0x278F;
  12994. t['a156'] = 0x2790;
  12995. t['a157'] = 0x2791;
  12996. t['a158'] = 0x2792;
  12997. t['a159'] = 0x2793;
  12998. t['a160'] = 0x2794;
  12999. t['a161'] = 0x2192;
  13000. t['a163'] = 0x2194;
  13001. t['a164'] = 0x2195;
  13002. t['a196'] = 0x2798;
  13003. t['a165'] = 0x2799;
  13004. t['a192'] = 0x279A;
  13005. t['a166'] = 0x279B;
  13006. t['a167'] = 0x279C;
  13007. t['a168'] = 0x279D;
  13008. t['a169'] = 0x279E;
  13009. t['a170'] = 0x279F;
  13010. t['a171'] = 0x27A0;
  13011. t['a172'] = 0x27A1;
  13012. t['a173'] = 0x27A2;
  13013. t['a162'] = 0x27A3;
  13014. t['a174'] = 0x27A4;
  13015. t['a175'] = 0x27A5;
  13016. t['a176'] = 0x27A6;
  13017. t['a177'] = 0x27A7;
  13018. t['a178'] = 0x27A8;
  13019. t['a179'] = 0x27A9;
  13020. t['a193'] = 0x27AA;
  13021. t['a180'] = 0x27AB;
  13022. t['a199'] = 0x27AC;
  13023. t['a181'] = 0x27AD;
  13024. t['a200'] = 0x27AE;
  13025. t['a182'] = 0x27AF;
  13026. t['a201'] = 0x27B1;
  13027. t['a183'] = 0x27B2;
  13028. t['a184'] = 0x27B3;
  13029. t['a197'] = 0x27B4;
  13030. t['a185'] = 0x27B5;
  13031. t['a194'] = 0x27B6;
  13032. t['a198'] = 0x27B7;
  13033. t['a186'] = 0x27B8;
  13034. t['a195'] = 0x27B9;
  13035. t['a187'] = 0x27BA;
  13036. t['a188'] = 0x27BB;
  13037. t['a189'] = 0x27BC;
  13038. t['a190'] = 0x27BD;
  13039. t['a191'] = 0x27BE;
  13040. t['a89'] = 0x2768;
  13041. t['a90'] = 0x2769;
  13042. t['a93'] = 0x276A;
  13043. t['a94'] = 0x276B;
  13044. t['a91'] = 0x276C;
  13045. t['a92'] = 0x276D;
  13046. t['a205'] = 0x276E;
  13047. t['a85'] = 0x276F;
  13048. t['a206'] = 0x2770;
  13049. t['a86'] = 0x2771;
  13050. t['a87'] = 0x2772;
  13051. t['a88'] = 0x2773;
  13052. t['a95'] = 0x2774;
  13053. t['a96'] = 0x2775;
  13054. t['.notdef'] = 0x0000;
  13055. });
  13056. exports.getGlyphsUnicode = getGlyphsUnicode;
  13057. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  13058. }));
  13059. (function (root, factory) {
  13060. factory(root.pdfjsCoreJbig2 = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  13061. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  13062. var error = sharedUtil.error;
  13063. var log2 = sharedUtil.log2;
  13064. var readInt8 = sharedUtil.readInt8;
  13065. var readUint16 = sharedUtil.readUint16;
  13066. var readUint32 = sharedUtil.readUint32;
  13067. var shadow = sharedUtil.shadow;
  13068. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  13069. var Jbig2Image = function Jbig2ImageClosure() {
  13070. function ContextCache() {
  13071. }
  13072. ContextCache.prototype = {
  13073. getContexts: function (id) {
  13074. if (id in this) {
  13075. return this[id];
  13076. }
  13077. return this[id] = new Int8Array(1 << 16);
  13078. }
  13079. };
  13080. function DecodingContext(data, start, end) {
  13081. this.data = data;
  13082. this.start = start;
  13083. this.end = end;
  13084. }
  13085. DecodingContext.prototype = {
  13086. get decoder() {
  13087. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  13088. return shadow(this, 'decoder', decoder);
  13089. },
  13090. get contextCache() {
  13091. var cache = new ContextCache();
  13092. return shadow(this, 'contextCache', cache);
  13093. }
  13094. };
  13095. function decodeInteger(contextCache, procedure, decoder) {
  13096. var contexts = contextCache.getContexts(procedure);
  13097. var prev = 1;
  13098. function readBits(length) {
  13099. var v = 0;
  13100. for (var i = 0; i < length; i++) {
  13101. var bit = decoder.readBit(contexts, prev);
  13102. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  13103. v = v << 1 | bit;
  13104. }
  13105. return v >>> 0;
  13106. }
  13107. var sign = readBits(1);
  13108. 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);
  13109. return sign === 0 ? value : value > 0 ? -value : null;
  13110. }
  13111. function decodeIAID(contextCache, decoder, codeLength) {
  13112. var contexts = contextCache.getContexts('IAID');
  13113. var prev = 1;
  13114. for (var i = 0; i < codeLength; i++) {
  13115. var bit = decoder.readBit(contexts, prev);
  13116. prev = prev << 1 | bit;
  13117. }
  13118. if (codeLength < 31) {
  13119. return prev & (1 << codeLength) - 1;
  13120. }
  13121. return prev & 0x7FFFFFFF;
  13122. }
  13123. var SegmentTypes = [
  13124. 'SymbolDictionary',
  13125. null,
  13126. null,
  13127. null,
  13128. 'IntermediateTextRegion',
  13129. null,
  13130. 'ImmediateTextRegion',
  13131. 'ImmediateLosslessTextRegion',
  13132. null,
  13133. null,
  13134. null,
  13135. null,
  13136. null,
  13137. null,
  13138. null,
  13139. null,
  13140. 'patternDictionary',
  13141. null,
  13142. null,
  13143. null,
  13144. 'IntermediateHalftoneRegion',
  13145. null,
  13146. 'ImmediateHalftoneRegion',
  13147. 'ImmediateLosslessHalftoneRegion',
  13148. null,
  13149. null,
  13150. null,
  13151. null,
  13152. null,
  13153. null,
  13154. null,
  13155. null,
  13156. null,
  13157. null,
  13158. null,
  13159. null,
  13160. 'IntermediateGenericRegion',
  13161. null,
  13162. 'ImmediateGenericRegion',
  13163. 'ImmediateLosslessGenericRegion',
  13164. 'IntermediateGenericRefinementRegion',
  13165. null,
  13166. 'ImmediateGenericRefinementRegion',
  13167. 'ImmediateLosslessGenericRefinementRegion',
  13168. null,
  13169. null,
  13170. null,
  13171. null,
  13172. 'PageInformation',
  13173. 'EndOfPage',
  13174. 'EndOfStripe',
  13175. 'EndOfFile',
  13176. 'Profiles',
  13177. 'Tables',
  13178. null,
  13179. null,
  13180. null,
  13181. null,
  13182. null,
  13183. null,
  13184. null,
  13185. null,
  13186. 'Extension'
  13187. ];
  13188. var CodingTemplates = [
  13189. [
  13190. {
  13191. x: -1,
  13192. y: -2
  13193. },
  13194. {
  13195. x: 0,
  13196. y: -2
  13197. },
  13198. {
  13199. x: 1,
  13200. y: -2
  13201. },
  13202. {
  13203. x: -2,
  13204. y: -1
  13205. },
  13206. {
  13207. x: -1,
  13208. y: -1
  13209. },
  13210. {
  13211. x: 0,
  13212. y: -1
  13213. },
  13214. {
  13215. x: 1,
  13216. y: -1
  13217. },
  13218. {
  13219. x: 2,
  13220. y: -1
  13221. },
  13222. {
  13223. x: -4,
  13224. y: 0
  13225. },
  13226. {
  13227. x: -3,
  13228. y: 0
  13229. },
  13230. {
  13231. x: -2,
  13232. y: 0
  13233. },
  13234. {
  13235. x: -1,
  13236. y: 0
  13237. }
  13238. ],
  13239. [
  13240. {
  13241. x: -1,
  13242. y: -2
  13243. },
  13244. {
  13245. x: 0,
  13246. y: -2
  13247. },
  13248. {
  13249. x: 1,
  13250. y: -2
  13251. },
  13252. {
  13253. x: 2,
  13254. y: -2
  13255. },
  13256. {
  13257. x: -2,
  13258. y: -1
  13259. },
  13260. {
  13261. x: -1,
  13262. y: -1
  13263. },
  13264. {
  13265. x: 0,
  13266. y: -1
  13267. },
  13268. {
  13269. x: 1,
  13270. y: -1
  13271. },
  13272. {
  13273. x: 2,
  13274. y: -1
  13275. },
  13276. {
  13277. x: -3,
  13278. y: 0
  13279. },
  13280. {
  13281. x: -2,
  13282. y: 0
  13283. },
  13284. {
  13285. x: -1,
  13286. y: 0
  13287. }
  13288. ],
  13289. [
  13290. {
  13291. x: -1,
  13292. y: -2
  13293. },
  13294. {
  13295. x: 0,
  13296. y: -2
  13297. },
  13298. {
  13299. x: 1,
  13300. y: -2
  13301. },
  13302. {
  13303. x: -2,
  13304. y: -1
  13305. },
  13306. {
  13307. x: -1,
  13308. y: -1
  13309. },
  13310. {
  13311. x: 0,
  13312. y: -1
  13313. },
  13314. {
  13315. x: 1,
  13316. y: -1
  13317. },
  13318. {
  13319. x: -2,
  13320. y: 0
  13321. },
  13322. {
  13323. x: -1,
  13324. y: 0
  13325. }
  13326. ],
  13327. [
  13328. {
  13329. x: -3,
  13330. y: -1
  13331. },
  13332. {
  13333. x: -2,
  13334. y: -1
  13335. },
  13336. {
  13337. x: -1,
  13338. y: -1
  13339. },
  13340. {
  13341. x: 0,
  13342. y: -1
  13343. },
  13344. {
  13345. x: 1,
  13346. y: -1
  13347. },
  13348. {
  13349. x: -4,
  13350. y: 0
  13351. },
  13352. {
  13353. x: -3,
  13354. y: 0
  13355. },
  13356. {
  13357. x: -2,
  13358. y: 0
  13359. },
  13360. {
  13361. x: -1,
  13362. y: 0
  13363. }
  13364. ]
  13365. ];
  13366. var RefinementTemplates = [
  13367. {
  13368. coding: [
  13369. {
  13370. x: 0,
  13371. y: -1
  13372. },
  13373. {
  13374. x: 1,
  13375. y: -1
  13376. },
  13377. {
  13378. x: -1,
  13379. y: 0
  13380. }
  13381. ],
  13382. reference: [
  13383. {
  13384. x: 0,
  13385. y: -1
  13386. },
  13387. {
  13388. x: 1,
  13389. y: -1
  13390. },
  13391. {
  13392. x: -1,
  13393. y: 0
  13394. },
  13395. {
  13396. x: 0,
  13397. y: 0
  13398. },
  13399. {
  13400. x: 1,
  13401. y: 0
  13402. },
  13403. {
  13404. x: -1,
  13405. y: 1
  13406. },
  13407. {
  13408. x: 0,
  13409. y: 1
  13410. },
  13411. {
  13412. x: 1,
  13413. y: 1
  13414. }
  13415. ]
  13416. },
  13417. {
  13418. coding: [
  13419. {
  13420. x: -1,
  13421. y: -1
  13422. },
  13423. {
  13424. x: 0,
  13425. y: -1
  13426. },
  13427. {
  13428. x: 1,
  13429. y: -1
  13430. },
  13431. {
  13432. x: -1,
  13433. y: 0
  13434. }
  13435. ],
  13436. reference: [
  13437. {
  13438. x: 0,
  13439. y: -1
  13440. },
  13441. {
  13442. x: -1,
  13443. y: 0
  13444. },
  13445. {
  13446. x: 0,
  13447. y: 0
  13448. },
  13449. {
  13450. x: 1,
  13451. y: 0
  13452. },
  13453. {
  13454. x: 0,
  13455. y: 1
  13456. },
  13457. {
  13458. x: 1,
  13459. y: 1
  13460. }
  13461. ]
  13462. }
  13463. ];
  13464. var ReusedContexts = [
  13465. 0x9B25,
  13466. 0x0795,
  13467. 0x00E5,
  13468. 0x0195
  13469. ];
  13470. var RefinementReusedContexts = [
  13471. 0x0020,
  13472. 0x0008
  13473. ];
  13474. function decodeBitmapTemplate0(width, height, decodingContext) {
  13475. var decoder = decodingContext.decoder;
  13476. var contexts = decodingContext.contextCache.getContexts('GB');
  13477. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  13478. var OLD_PIXEL_MASK = 0x7BF7;
  13479. for (i = 0; i < height; i++) {
  13480. row = bitmap[i] = new Uint8Array(width);
  13481. row1 = i < 1 ? row : bitmap[i - 1];
  13482. row2 = i < 2 ? row : bitmap[i - 2];
  13483. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  13484. for (j = 0; j < width; j++) {
  13485. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  13486. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  13487. }
  13488. }
  13489. return bitmap;
  13490. }
  13491. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  13492. if (mmr) {
  13493. error('JBIG2 error: MMR encoding is not supported');
  13494. }
  13495. 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) {
  13496. return decodeBitmapTemplate0(width, height, decodingContext);
  13497. }
  13498. var useskip = !!skip;
  13499. var template = CodingTemplates[templateIndex].concat(at);
  13500. template.sort(function (a, b) {
  13501. return a.y - b.y || a.x - b.x;
  13502. });
  13503. var templateLength = template.length;
  13504. var templateX = new Int8Array(templateLength);
  13505. var templateY = new Int8Array(templateLength);
  13506. var changingTemplateEntries = [];
  13507. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  13508. var c, k;
  13509. for (k = 0; k < templateLength; k++) {
  13510. templateX[k] = template[k].x;
  13511. templateY[k] = template[k].y;
  13512. minX = Math.min(minX, template[k].x);
  13513. maxX = Math.max(maxX, template[k].x);
  13514. minY = Math.min(minY, template[k].y);
  13515. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  13516. reuseMask |= 1 << templateLength - 1 - k;
  13517. } else {
  13518. changingTemplateEntries.push(k);
  13519. }
  13520. }
  13521. var changingEntriesLength = changingTemplateEntries.length;
  13522. var changingTemplateX = new Int8Array(changingEntriesLength);
  13523. var changingTemplateY = new Int8Array(changingEntriesLength);
  13524. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  13525. for (c = 0; c < changingEntriesLength; c++) {
  13526. k = changingTemplateEntries[c];
  13527. changingTemplateX[c] = template[k].x;
  13528. changingTemplateY[c] = template[k].y;
  13529. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  13530. }
  13531. var sbb_left = -minX;
  13532. var sbb_top = -minY;
  13533. var sbb_right = width - maxX;
  13534. var pseudoPixelContext = ReusedContexts[templateIndex];
  13535. var row = new Uint8Array(width);
  13536. var bitmap = [];
  13537. var decoder = decodingContext.decoder;
  13538. var contexts = decodingContext.contextCache.getContexts('GB');
  13539. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  13540. for (var i = 0; i < height; i++) {
  13541. if (prediction) {
  13542. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13543. ltp ^= sltp;
  13544. if (ltp) {
  13545. bitmap.push(row);
  13546. continue;
  13547. }
  13548. }
  13549. row = new Uint8Array(row);
  13550. bitmap.push(row);
  13551. for (j = 0; j < width; j++) {
  13552. if (useskip && skip[i][j]) {
  13553. row[j] = 0;
  13554. continue;
  13555. }
  13556. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  13557. contextLabel = contextLabel << 1 & reuseMask;
  13558. for (k = 0; k < changingEntriesLength; k++) {
  13559. i0 = i + changingTemplateY[k];
  13560. j0 = j + changingTemplateX[k];
  13561. bit = bitmap[i0][j0];
  13562. if (bit) {
  13563. bit = changingTemplateBit[k];
  13564. contextLabel |= bit;
  13565. }
  13566. }
  13567. } else {
  13568. contextLabel = 0;
  13569. shift = templateLength - 1;
  13570. for (k = 0; k < templateLength; k++, shift--) {
  13571. j0 = j + templateX[k];
  13572. if (j0 >= 0 && j0 < width) {
  13573. i0 = i + templateY[k];
  13574. if (i0 >= 0) {
  13575. bit = bitmap[i0][j0];
  13576. if (bit) {
  13577. contextLabel |= bit << shift;
  13578. }
  13579. }
  13580. }
  13581. }
  13582. }
  13583. var pixel = decoder.readBit(contexts, contextLabel);
  13584. row[j] = pixel;
  13585. }
  13586. }
  13587. return bitmap;
  13588. }
  13589. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  13590. var codingTemplate = RefinementTemplates[templateIndex].coding;
  13591. if (templateIndex === 0) {
  13592. codingTemplate = codingTemplate.concat([at[0]]);
  13593. }
  13594. var codingTemplateLength = codingTemplate.length;
  13595. var codingTemplateX = new Int32Array(codingTemplateLength);
  13596. var codingTemplateY = new Int32Array(codingTemplateLength);
  13597. var k;
  13598. for (k = 0; k < codingTemplateLength; k++) {
  13599. codingTemplateX[k] = codingTemplate[k].x;
  13600. codingTemplateY[k] = codingTemplate[k].y;
  13601. }
  13602. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  13603. if (templateIndex === 0) {
  13604. referenceTemplate = referenceTemplate.concat([at[1]]);
  13605. }
  13606. var referenceTemplateLength = referenceTemplate.length;
  13607. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  13608. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  13609. for (k = 0; k < referenceTemplateLength; k++) {
  13610. referenceTemplateX[k] = referenceTemplate[k].x;
  13611. referenceTemplateY[k] = referenceTemplate[k].y;
  13612. }
  13613. var referenceWidth = referenceBitmap[0].length;
  13614. var referenceHeight = referenceBitmap.length;
  13615. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  13616. var bitmap = [];
  13617. var decoder = decodingContext.decoder;
  13618. var contexts = decodingContext.contextCache.getContexts('GR');
  13619. var ltp = 0;
  13620. for (var i = 0; i < height; i++) {
  13621. if (prediction) {
  13622. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13623. ltp ^= sltp;
  13624. if (ltp) {
  13625. error('JBIG2 error: prediction is not supported');
  13626. }
  13627. }
  13628. var row = new Uint8Array(width);
  13629. bitmap.push(row);
  13630. for (var j = 0; j < width; j++) {
  13631. var i0, j0;
  13632. var contextLabel = 0;
  13633. for (k = 0; k < codingTemplateLength; k++) {
  13634. i0 = i + codingTemplateY[k];
  13635. j0 = j + codingTemplateX[k];
  13636. if (i0 < 0 || j0 < 0 || j0 >= width) {
  13637. contextLabel <<= 1;
  13638. } else
  13639. {
  13640. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  13641. }
  13642. }
  13643. for (k = 0; k < referenceTemplateLength; k++) {
  13644. i0 = i + referenceTemplateY[k] + offsetY;
  13645. j0 = j + referenceTemplateX[k] + offsetX;
  13646. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  13647. contextLabel <<= 1;
  13648. } else
  13649. {
  13650. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  13651. }
  13652. }
  13653. var pixel = decoder.readBit(contexts, contextLabel);
  13654. row[j] = pixel;
  13655. }
  13656. }
  13657. return bitmap;
  13658. }
  13659. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  13660. if (huffman) {
  13661. error('JBIG2 error: huffman is not supported');
  13662. }
  13663. var newSymbols = [];
  13664. var currentHeight = 0;
  13665. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  13666. var decoder = decodingContext.decoder;
  13667. var contextCache = decodingContext.contextCache;
  13668. while (newSymbols.length < numberOfNewSymbols) {
  13669. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  13670. currentHeight += deltaHeight;
  13671. var currentWidth = 0;
  13672. var totalWidth = 0;
  13673. while (true) {
  13674. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  13675. if (deltaWidth === null) {
  13676. break;
  13677. }
  13678. currentWidth += deltaWidth;
  13679. totalWidth += currentWidth;
  13680. var bitmap;
  13681. if (refinement) {
  13682. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  13683. if (numberOfInstances > 1) {
  13684. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  13685. } else {
  13686. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13687. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13688. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13689. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  13690. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  13691. }
  13692. } else {
  13693. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  13694. }
  13695. newSymbols.push(bitmap);
  13696. }
  13697. }
  13698. var exportedSymbols = [];
  13699. var flags = [], currentFlag = false;
  13700. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  13701. while (flags.length < totalSymbolsLength) {
  13702. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  13703. while (runLength--) {
  13704. flags.push(currentFlag);
  13705. }
  13706. currentFlag = !currentFlag;
  13707. }
  13708. for (var i = 0, ii = symbols.length; i < ii; i++) {
  13709. if (flags[i]) {
  13710. exportedSymbols.push(symbols[i]);
  13711. }
  13712. }
  13713. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  13714. if (flags[i]) {
  13715. exportedSymbols.push(newSymbols[j]);
  13716. }
  13717. }
  13718. return exportedSymbols;
  13719. }
  13720. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  13721. if (huffman) {
  13722. error('JBIG2 error: huffman is not supported');
  13723. }
  13724. var bitmap = [];
  13725. var i, row;
  13726. for (i = 0; i < height; i++) {
  13727. row = new Uint8Array(width);
  13728. if (defaultPixelValue) {
  13729. for (var j = 0; j < width; j++) {
  13730. row[j] = defaultPixelValue;
  13731. }
  13732. }
  13733. bitmap.push(row);
  13734. }
  13735. var decoder = decodingContext.decoder;
  13736. var contextCache = decodingContext.contextCache;
  13737. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  13738. var firstS = 0;
  13739. i = 0;
  13740. while (i < numberOfSymbolInstances) {
  13741. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  13742. stripT += deltaT;
  13743. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  13744. firstS += deltaFirstS;
  13745. var currentS = firstS;
  13746. do {
  13747. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  13748. var t = stripSize * stripT + currentT;
  13749. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13750. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  13751. var symbolBitmap = inputSymbols[symbolId];
  13752. var symbolWidth = symbolBitmap[0].length;
  13753. var symbolHeight = symbolBitmap.length;
  13754. if (applyRefinement) {
  13755. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  13756. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  13757. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13758. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13759. symbolWidth += rdw;
  13760. symbolHeight += rdh;
  13761. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  13762. }
  13763. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  13764. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  13765. var s2, t2, symbolRow;
  13766. if (transposed) {
  13767. for (s2 = 0; s2 < symbolHeight; s2++) {
  13768. row = bitmap[offsetS + s2];
  13769. if (!row) {
  13770. continue;
  13771. }
  13772. symbolRow = symbolBitmap[s2];
  13773. var maxWidth = Math.min(width - offsetT, symbolWidth);
  13774. switch (combinationOperator) {
  13775. case 0:
  13776. for (t2 = 0; t2 < maxWidth; t2++) {
  13777. row[offsetT + t2] |= symbolRow[t2];
  13778. }
  13779. break;
  13780. case 2:
  13781. for (t2 = 0; t2 < maxWidth; t2++) {
  13782. row[offsetT + t2] ^= symbolRow[t2];
  13783. }
  13784. break;
  13785. default:
  13786. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13787. }
  13788. }
  13789. currentS += symbolHeight - 1;
  13790. } else {
  13791. for (t2 = 0; t2 < symbolHeight; t2++) {
  13792. row = bitmap[offsetT + t2];
  13793. if (!row) {
  13794. continue;
  13795. }
  13796. symbolRow = symbolBitmap[t2];
  13797. switch (combinationOperator) {
  13798. case 0:
  13799. for (s2 = 0; s2 < symbolWidth; s2++) {
  13800. row[offsetS + s2] |= symbolRow[s2];
  13801. }
  13802. break;
  13803. case 2:
  13804. for (s2 = 0; s2 < symbolWidth; s2++) {
  13805. row[offsetS + s2] ^= symbolRow[s2];
  13806. }
  13807. break;
  13808. default:
  13809. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13810. }
  13811. }
  13812. currentS += symbolWidth - 1;
  13813. }
  13814. i++;
  13815. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  13816. if (deltaS === null) {
  13817. break;
  13818. }
  13819. currentS += deltaS + dsOffset;
  13820. } while (true);
  13821. }
  13822. return bitmap;
  13823. }
  13824. function readSegmentHeader(data, start) {
  13825. var segmentHeader = {};
  13826. segmentHeader.number = readUint32(data, start);
  13827. var flags = data[start + 4];
  13828. var segmentType = flags & 0x3F;
  13829. if (!SegmentTypes[segmentType]) {
  13830. error('JBIG2 error: invalid segment type: ' + segmentType);
  13831. }
  13832. segmentHeader.type = segmentType;
  13833. segmentHeader.typeName = SegmentTypes[segmentType];
  13834. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  13835. var pageAssociationFieldSize = !!(flags & 0x40);
  13836. var referredFlags = data[start + 5];
  13837. var referredToCount = referredFlags >> 5 & 7;
  13838. var retainBits = [referredFlags & 31];
  13839. var position = start + 6;
  13840. if (referredFlags === 7) {
  13841. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  13842. position += 3;
  13843. var bytes = referredToCount + 7 >> 3;
  13844. retainBits[0] = data[position++];
  13845. while (--bytes > 0) {
  13846. retainBits.push(data[position++]);
  13847. }
  13848. } else if (referredFlags === 5 || referredFlags === 6) {
  13849. error('JBIG2 error: invalid referred-to flags');
  13850. }
  13851. segmentHeader.retainBits = retainBits;
  13852. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  13853. var referredTo = [];
  13854. var i, ii;
  13855. for (i = 0; i < referredToCount; i++) {
  13856. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  13857. referredTo.push(number);
  13858. position += referredToSegmentNumberSize;
  13859. }
  13860. segmentHeader.referredTo = referredTo;
  13861. if (!pageAssociationFieldSize) {
  13862. segmentHeader.pageAssociation = data[position++];
  13863. } else {
  13864. segmentHeader.pageAssociation = readUint32(data, position);
  13865. position += 4;
  13866. }
  13867. segmentHeader.length = readUint32(data, position);
  13868. position += 4;
  13869. if (segmentHeader.length === 0xFFFFFFFF) {
  13870. if (segmentType === 38) {
  13871. var genericRegionInfo = readRegionSegmentInformation(data, position);
  13872. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  13873. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  13874. var searchPatternLength = 6;
  13875. var searchPattern = new Uint8Array(searchPatternLength);
  13876. if (!genericRegionMmr) {
  13877. searchPattern[0] = 0xFF;
  13878. searchPattern[1] = 0xAC;
  13879. }
  13880. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  13881. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  13882. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  13883. searchPattern[5] = genericRegionInfo.height & 0xFF;
  13884. for (i = position, ii = data.length; i < ii; i++) {
  13885. var j = 0;
  13886. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  13887. j++;
  13888. }
  13889. if (j === searchPatternLength) {
  13890. segmentHeader.length = i + searchPatternLength;
  13891. break;
  13892. }
  13893. }
  13894. if (segmentHeader.length === 0xFFFFFFFF) {
  13895. error('JBIG2 error: segment end was not found');
  13896. }
  13897. } else {
  13898. error('JBIG2 error: invalid unknown segment length');
  13899. }
  13900. }
  13901. segmentHeader.headerEnd = position;
  13902. return segmentHeader;
  13903. }
  13904. function readSegments(header, data, start, end) {
  13905. var segments = [];
  13906. var position = start;
  13907. while (position < end) {
  13908. var segmentHeader = readSegmentHeader(data, position);
  13909. position = segmentHeader.headerEnd;
  13910. var segment = {
  13911. header: segmentHeader,
  13912. data: data
  13913. };
  13914. if (!header.randomAccess) {
  13915. segment.start = position;
  13916. position += segmentHeader.length;
  13917. segment.end = position;
  13918. }
  13919. segments.push(segment);
  13920. if (segmentHeader.type === 51) {
  13921. break;
  13922. }
  13923. }
  13924. if (header.randomAccess) {
  13925. for (var i = 0, ii = segments.length; i < ii; i++) {
  13926. segments[i].start = position;
  13927. position += segments[i].header.length;
  13928. segments[i].end = position;
  13929. }
  13930. }
  13931. return segments;
  13932. }
  13933. function readRegionSegmentInformation(data, start) {
  13934. return {
  13935. width: readUint32(data, start),
  13936. height: readUint32(data, start + 4),
  13937. x: readUint32(data, start + 8),
  13938. y: readUint32(data, start + 12),
  13939. combinationOperator: data[start + 16] & 7
  13940. };
  13941. }
  13942. var RegionSegmentInformationFieldLength = 17;
  13943. function processSegment(segment, visitor) {
  13944. var header = segment.header;
  13945. var data = segment.data, position = segment.start, end = segment.end;
  13946. var args, at, i, atLength;
  13947. switch (header.type) {
  13948. case 0:
  13949. var dictionary = {};
  13950. var dictionaryFlags = readUint16(data, position);
  13951. dictionary.huffman = !!(dictionaryFlags & 1);
  13952. dictionary.refinement = !!(dictionaryFlags & 2);
  13953. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  13954. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  13955. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  13956. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  13957. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  13958. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  13959. dictionary.template = dictionaryFlags >> 10 & 3;
  13960. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  13961. position += 2;
  13962. if (!dictionary.huffman) {
  13963. atLength = dictionary.template === 0 ? 4 : 1;
  13964. at = [];
  13965. for (i = 0; i < atLength; i++) {
  13966. at.push({
  13967. x: readInt8(data, position),
  13968. y: readInt8(data, position + 1)
  13969. });
  13970. position += 2;
  13971. }
  13972. dictionary.at = at;
  13973. }
  13974. if (dictionary.refinement && !dictionary.refinementTemplate) {
  13975. at = [];
  13976. for (i = 0; i < 2; i++) {
  13977. at.push({
  13978. x: readInt8(data, position),
  13979. y: readInt8(data, position + 1)
  13980. });
  13981. position += 2;
  13982. }
  13983. dictionary.refinementAt = at;
  13984. }
  13985. dictionary.numberOfExportedSymbols = readUint32(data, position);
  13986. position += 4;
  13987. dictionary.numberOfNewSymbols = readUint32(data, position);
  13988. position += 4;
  13989. args = [
  13990. dictionary,
  13991. header.number,
  13992. header.referredTo,
  13993. data,
  13994. position,
  13995. end
  13996. ];
  13997. break;
  13998. case 6:
  13999. case 7:
  14000. var textRegion = {};
  14001. textRegion.info = readRegionSegmentInformation(data, position);
  14002. position += RegionSegmentInformationFieldLength;
  14003. var textRegionSegmentFlags = readUint16(data, position);
  14004. position += 2;
  14005. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  14006. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  14007. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  14008. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  14009. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  14010. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  14011. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  14012. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  14013. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  14014. if (textRegion.huffman) {
  14015. var textRegionHuffmanFlags = readUint16(data, position);
  14016. position += 2;
  14017. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  14018. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  14019. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  14020. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  14021. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  14022. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  14023. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  14024. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  14025. }
  14026. if (textRegion.refinement && !textRegion.refinementTemplate) {
  14027. at = [];
  14028. for (i = 0; i < 2; i++) {
  14029. at.push({
  14030. x: readInt8(data, position),
  14031. y: readInt8(data, position + 1)
  14032. });
  14033. position += 2;
  14034. }
  14035. textRegion.refinementAt = at;
  14036. }
  14037. textRegion.numberOfSymbolInstances = readUint32(data, position);
  14038. position += 4;
  14039. if (textRegion.huffman) {
  14040. error('JBIG2 error: huffman is not supported');
  14041. }
  14042. args = [
  14043. textRegion,
  14044. header.referredTo,
  14045. data,
  14046. position,
  14047. end
  14048. ];
  14049. break;
  14050. case 38:
  14051. case 39:
  14052. var genericRegion = {};
  14053. genericRegion.info = readRegionSegmentInformation(data, position);
  14054. position += RegionSegmentInformationFieldLength;
  14055. var genericRegionSegmentFlags = data[position++];
  14056. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  14057. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  14058. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  14059. if (!genericRegion.mmr) {
  14060. atLength = genericRegion.template === 0 ? 4 : 1;
  14061. at = [];
  14062. for (i = 0; i < atLength; i++) {
  14063. at.push({
  14064. x: readInt8(data, position),
  14065. y: readInt8(data, position + 1)
  14066. });
  14067. position += 2;
  14068. }
  14069. genericRegion.at = at;
  14070. }
  14071. args = [
  14072. genericRegion,
  14073. data,
  14074. position,
  14075. end
  14076. ];
  14077. break;
  14078. case 48:
  14079. var pageInfo = {
  14080. width: readUint32(data, position),
  14081. height: readUint32(data, position + 4),
  14082. resolutionX: readUint32(data, position + 8),
  14083. resolutionY: readUint32(data, position + 12)
  14084. };
  14085. if (pageInfo.height === 0xFFFFFFFF) {
  14086. delete pageInfo.height;
  14087. }
  14088. var pageSegmentFlags = data[position + 16];
  14089. var pageStripingInformation = readUint16(data, position + 17);
  14090. pageInfo.lossless = !!(pageSegmentFlags & 1);
  14091. pageInfo.refinement = !!(pageSegmentFlags & 2);
  14092. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  14093. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  14094. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  14095. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  14096. args = [pageInfo];
  14097. break;
  14098. case 49:
  14099. break;
  14100. case 50:
  14101. break;
  14102. case 51:
  14103. break;
  14104. case 62:
  14105. break;
  14106. default:
  14107. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  14108. }
  14109. var callbackName = 'on' + header.typeName;
  14110. if (callbackName in visitor) {
  14111. visitor[callbackName].apply(visitor, args);
  14112. }
  14113. }
  14114. function processSegments(segments, visitor) {
  14115. for (var i = 0, ii = segments.length; i < ii; i++) {
  14116. processSegment(segments[i], visitor);
  14117. }
  14118. }
  14119. function parseJbig2(data, start, end) {
  14120. var position = start;
  14121. 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) {
  14122. error('JBIG2 error: invalid header');
  14123. }
  14124. var header = {};
  14125. position += 8;
  14126. var flags = data[position++];
  14127. header.randomAccess = !(flags & 1);
  14128. if (!(flags & 2)) {
  14129. header.numberOfPages = readUint32(data, position);
  14130. position += 4;
  14131. }
  14132. var segments = readSegments(header, data, position, end);
  14133. error('Not implemented');
  14134. }
  14135. function parseJbig2Chunks(chunks) {
  14136. var visitor = new SimpleSegmentVisitor();
  14137. for (var i = 0, ii = chunks.length; i < ii; i++) {
  14138. var chunk = chunks[i];
  14139. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  14140. processSegments(segments, visitor);
  14141. }
  14142. return visitor.buffer;
  14143. }
  14144. function SimpleSegmentVisitor() {
  14145. }
  14146. SimpleSegmentVisitor.prototype = {
  14147. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  14148. this.currentPageInfo = info;
  14149. var rowSize = info.width + 7 >> 3;
  14150. var buffer = new Uint8Array(rowSize * info.height);
  14151. if (info.defaultPixelValue) {
  14152. for (var i = 0, ii = buffer.length; i < ii; i++) {
  14153. buffer[i] = 0xFF;
  14154. }
  14155. }
  14156. this.buffer = buffer;
  14157. },
  14158. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  14159. var pageInfo = this.currentPageInfo;
  14160. var width = regionInfo.width, height = regionInfo.height;
  14161. var rowSize = pageInfo.width + 7 >> 3;
  14162. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  14163. var buffer = this.buffer;
  14164. var mask0 = 128 >> (regionInfo.x & 7);
  14165. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  14166. var i, j, mask, offset;
  14167. switch (combinationOperator) {
  14168. case 0:
  14169. for (i = 0; i < height; i++) {
  14170. mask = mask0;
  14171. offset = offset0;
  14172. for (j = 0; j < width; j++) {
  14173. if (bitmap[i][j]) {
  14174. buffer[offset] |= mask;
  14175. }
  14176. mask >>= 1;
  14177. if (!mask) {
  14178. mask = 128;
  14179. offset++;
  14180. }
  14181. }
  14182. offset0 += rowSize;
  14183. }
  14184. break;
  14185. case 2:
  14186. for (i = 0; i < height; i++) {
  14187. mask = mask0;
  14188. offset = offset0;
  14189. for (j = 0; j < width; j++) {
  14190. if (bitmap[i][j]) {
  14191. buffer[offset] ^= mask;
  14192. }
  14193. mask >>= 1;
  14194. if (!mask) {
  14195. mask = 128;
  14196. offset++;
  14197. }
  14198. }
  14199. offset0 += rowSize;
  14200. }
  14201. break;
  14202. default:
  14203. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  14204. }
  14205. },
  14206. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  14207. var regionInfo = region.info;
  14208. var decodingContext = new DecodingContext(data, start, end);
  14209. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  14210. this.drawBitmap(regionInfo, bitmap);
  14211. },
  14212. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  14213. this.onImmediateGenericRegion.apply(this, arguments);
  14214. },
  14215. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  14216. var huffmanTables;
  14217. if (dictionary.huffman) {
  14218. error('JBIG2 error: huffman is not supported');
  14219. }
  14220. var symbols = this.symbols;
  14221. if (!symbols) {
  14222. this.symbols = symbols = {};
  14223. }
  14224. var inputSymbols = [];
  14225. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14226. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14227. }
  14228. var decodingContext = new DecodingContext(data, start, end);
  14229. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  14230. },
  14231. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  14232. var regionInfo = region.info;
  14233. var huffmanTables;
  14234. var symbols = this.symbols;
  14235. var inputSymbols = [];
  14236. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14237. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14238. }
  14239. var symbolCodeLength = log2(inputSymbols.length);
  14240. var decodingContext = new DecodingContext(data, start, end);
  14241. 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);
  14242. this.drawBitmap(regionInfo, bitmap);
  14243. },
  14244. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  14245. this.onImmediateTextRegion.apply(this, arguments);
  14246. }
  14247. };
  14248. function Jbig2Image() {
  14249. }
  14250. Jbig2Image.prototype = {
  14251. parseChunks: function Jbig2Image_parseChunks(chunks) {
  14252. return parseJbig2Chunks(chunks);
  14253. }
  14254. };
  14255. return Jbig2Image;
  14256. }();
  14257. exports.Jbig2Image = Jbig2Image;
  14258. }));
  14259. (function (root, factory) {
  14260. factory(root.pdfjsCoreJpg = {}, root.pdfjsSharedUtil);
  14261. }(this, function (exports, sharedUtil) {
  14262. var error = sharedUtil.error;
  14263. var JpegImage = function JpegImageClosure() {
  14264. var dctZigZag = new Uint8Array([
  14265. 0,
  14266. 1,
  14267. 8,
  14268. 16,
  14269. 9,
  14270. 2,
  14271. 3,
  14272. 10,
  14273. 17,
  14274. 24,
  14275. 32,
  14276. 25,
  14277. 18,
  14278. 11,
  14279. 4,
  14280. 5,
  14281. 12,
  14282. 19,
  14283. 26,
  14284. 33,
  14285. 40,
  14286. 48,
  14287. 41,
  14288. 34,
  14289. 27,
  14290. 20,
  14291. 13,
  14292. 6,
  14293. 7,
  14294. 14,
  14295. 21,
  14296. 28,
  14297. 35,
  14298. 42,
  14299. 49,
  14300. 56,
  14301. 57,
  14302. 50,
  14303. 43,
  14304. 36,
  14305. 29,
  14306. 22,
  14307. 15,
  14308. 23,
  14309. 30,
  14310. 37,
  14311. 44,
  14312. 51,
  14313. 58,
  14314. 59,
  14315. 52,
  14316. 45,
  14317. 38,
  14318. 31,
  14319. 39,
  14320. 46,
  14321. 53,
  14322. 60,
  14323. 61,
  14324. 54,
  14325. 47,
  14326. 55,
  14327. 62,
  14328. 63
  14329. ]);
  14330. var dctCos1 = 4017;
  14331. var dctSin1 = 799;
  14332. var dctCos3 = 3406;
  14333. var dctSin3 = 2276;
  14334. var dctCos6 = 1567;
  14335. var dctSin6 = 3784;
  14336. var dctSqrt2 = 5793;
  14337. var dctSqrt1d2 = 2896;
  14338. function JpegImage() {
  14339. this.decodeTransform = null;
  14340. this.colorTransform = -1;
  14341. }
  14342. function buildHuffmanTable(codeLengths, values) {
  14343. var k = 0, code = [], i, j, length = 16;
  14344. while (length > 0 && !codeLengths[length - 1]) {
  14345. length--;
  14346. }
  14347. code.push({
  14348. children: [],
  14349. index: 0
  14350. });
  14351. var p = code[0], q;
  14352. for (i = 0; i < length; i++) {
  14353. for (j = 0; j < codeLengths[i]; j++) {
  14354. p = code.pop();
  14355. p.children[p.index] = values[k];
  14356. while (p.index > 0) {
  14357. p = code.pop();
  14358. }
  14359. p.index++;
  14360. code.push(p);
  14361. while (code.length <= i) {
  14362. code.push(q = {
  14363. children: [],
  14364. index: 0
  14365. });
  14366. p.children[p.index] = q.children;
  14367. p = q;
  14368. }
  14369. k++;
  14370. }
  14371. if (i + 1 < length) {
  14372. code.push(q = {
  14373. children: [],
  14374. index: 0
  14375. });
  14376. p.children[p.index] = q.children;
  14377. p = q;
  14378. }
  14379. }
  14380. return code[0].children;
  14381. }
  14382. function getBlockBufferOffset(component, row, col) {
  14383. return 64 * ((component.blocksPerLine + 1) * row + col);
  14384. }
  14385. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  14386. var mcusPerLine = frame.mcusPerLine;
  14387. var progressive = frame.progressive;
  14388. var startOffset = offset, bitsData = 0, bitsCount = 0;
  14389. function readBit() {
  14390. if (bitsCount > 0) {
  14391. bitsCount--;
  14392. return bitsData >> bitsCount & 1;
  14393. }
  14394. bitsData = data[offset++];
  14395. if (bitsData === 0xFF) {
  14396. var nextByte = data[offset++];
  14397. if (nextByte) {
  14398. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  14399. }
  14400. }
  14401. bitsCount = 7;
  14402. return bitsData >>> 7;
  14403. }
  14404. function decodeHuffman(tree) {
  14405. var node = tree;
  14406. while (true) {
  14407. node = node[readBit()];
  14408. if (typeof node === 'number') {
  14409. return node;
  14410. }
  14411. if (typeof node !== 'object') {
  14412. error('JPEG error: invalid huffman sequence');
  14413. }
  14414. }
  14415. }
  14416. function receive(length) {
  14417. var n = 0;
  14418. while (length > 0) {
  14419. n = n << 1 | readBit();
  14420. length--;
  14421. }
  14422. return n;
  14423. }
  14424. function receiveAndExtend(length) {
  14425. if (length === 1) {
  14426. return readBit() === 1 ? 1 : -1;
  14427. }
  14428. var n = receive(length);
  14429. if (n >= 1 << length - 1) {
  14430. return n;
  14431. }
  14432. return n + (-1 << length) + 1;
  14433. }
  14434. function decodeBaseline(component, offset) {
  14435. var t = decodeHuffman(component.huffmanTableDC);
  14436. var diff = t === 0 ? 0 : receiveAndExtend(t);
  14437. component.blockData[offset] = component.pred += diff;
  14438. var k = 1;
  14439. while (k < 64) {
  14440. var rs = decodeHuffman(component.huffmanTableAC);
  14441. var s = rs & 15, r = rs >> 4;
  14442. if (s === 0) {
  14443. if (r < 15) {
  14444. break;
  14445. }
  14446. k += 16;
  14447. continue;
  14448. }
  14449. k += r;
  14450. var z = dctZigZag[k];
  14451. component.blockData[offset + z] = receiveAndExtend(s);
  14452. k++;
  14453. }
  14454. }
  14455. function decodeDCFirst(component, offset) {
  14456. var t = decodeHuffman(component.huffmanTableDC);
  14457. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  14458. component.blockData[offset] = component.pred += diff;
  14459. }
  14460. function decodeDCSuccessive(component, offset) {
  14461. component.blockData[offset] |= readBit() << successive;
  14462. }
  14463. var eobrun = 0;
  14464. function decodeACFirst(component, offset) {
  14465. if (eobrun > 0) {
  14466. eobrun--;
  14467. return;
  14468. }
  14469. var k = spectralStart, e = spectralEnd;
  14470. while (k <= e) {
  14471. var rs = decodeHuffman(component.huffmanTableAC);
  14472. var s = rs & 15, r = rs >> 4;
  14473. if (s === 0) {
  14474. if (r < 15) {
  14475. eobrun = receive(r) + (1 << r) - 1;
  14476. break;
  14477. }
  14478. k += 16;
  14479. continue;
  14480. }
  14481. k += r;
  14482. var z = dctZigZag[k];
  14483. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  14484. k++;
  14485. }
  14486. }
  14487. var successiveACState = 0, successiveACNextValue;
  14488. function decodeACSuccessive(component, offset) {
  14489. var k = spectralStart;
  14490. var e = spectralEnd;
  14491. var r = 0;
  14492. var s;
  14493. var rs;
  14494. while (k <= e) {
  14495. var z = dctZigZag[k];
  14496. switch (successiveACState) {
  14497. case 0:
  14498. rs = decodeHuffman(component.huffmanTableAC);
  14499. s = rs & 15;
  14500. r = rs >> 4;
  14501. if (s === 0) {
  14502. if (r < 15) {
  14503. eobrun = receive(r) + (1 << r);
  14504. successiveACState = 4;
  14505. } else {
  14506. r = 16;
  14507. successiveACState = 1;
  14508. }
  14509. } else {
  14510. if (s !== 1) {
  14511. error('JPEG error: invalid ACn encoding');
  14512. }
  14513. successiveACNextValue = receiveAndExtend(s);
  14514. successiveACState = r ? 2 : 3;
  14515. }
  14516. continue;
  14517. case 1:
  14518. case 2:
  14519. if (component.blockData[offset + z]) {
  14520. component.blockData[offset + z] += readBit() << successive;
  14521. } else {
  14522. r--;
  14523. if (r === 0) {
  14524. successiveACState = successiveACState === 2 ? 3 : 0;
  14525. }
  14526. }
  14527. break;
  14528. case 3:
  14529. if (component.blockData[offset + z]) {
  14530. component.blockData[offset + z] += readBit() << successive;
  14531. } else {
  14532. component.blockData[offset + z] = successiveACNextValue << successive;
  14533. successiveACState = 0;
  14534. }
  14535. break;
  14536. case 4:
  14537. if (component.blockData[offset + z]) {
  14538. component.blockData[offset + z] += readBit() << successive;
  14539. }
  14540. break;
  14541. }
  14542. k++;
  14543. }
  14544. if (successiveACState === 4) {
  14545. eobrun--;
  14546. if (eobrun === 0) {
  14547. successiveACState = 0;
  14548. }
  14549. }
  14550. }
  14551. function decodeMcu(component, decode, mcu, row, col) {
  14552. var mcuRow = mcu / mcusPerLine | 0;
  14553. var mcuCol = mcu % mcusPerLine;
  14554. var blockRow = mcuRow * component.v + row;
  14555. var blockCol = mcuCol * component.h + col;
  14556. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14557. decode(component, offset);
  14558. }
  14559. function decodeBlock(component, decode, mcu) {
  14560. var blockRow = mcu / component.blocksPerLine | 0;
  14561. var blockCol = mcu % component.blocksPerLine;
  14562. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14563. decode(component, offset);
  14564. }
  14565. var componentsLength = components.length;
  14566. var component, i, j, k, n;
  14567. var decodeFn;
  14568. if (progressive) {
  14569. if (spectralStart === 0) {
  14570. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  14571. } else {
  14572. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  14573. }
  14574. } else {
  14575. decodeFn = decodeBaseline;
  14576. }
  14577. var mcu = 0, marker;
  14578. var mcuExpected;
  14579. if (componentsLength === 1) {
  14580. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  14581. } else {
  14582. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  14583. }
  14584. if (!resetInterval) {
  14585. resetInterval = mcuExpected;
  14586. }
  14587. var h, v;
  14588. while (mcu < mcuExpected) {
  14589. for (i = 0; i < componentsLength; i++) {
  14590. components[i].pred = 0;
  14591. }
  14592. eobrun = 0;
  14593. if (componentsLength === 1) {
  14594. component = components[0];
  14595. for (n = 0; n < resetInterval; n++) {
  14596. decodeBlock(component, decodeFn, mcu);
  14597. mcu++;
  14598. }
  14599. } else {
  14600. for (n = 0; n < resetInterval; n++) {
  14601. for (i = 0; i < componentsLength; i++) {
  14602. component = components[i];
  14603. h = component.h;
  14604. v = component.v;
  14605. for (j = 0; j < v; j++) {
  14606. for (k = 0; k < h; k++) {
  14607. decodeMcu(component, decodeFn, mcu, j, k);
  14608. }
  14609. }
  14610. }
  14611. mcu++;
  14612. }
  14613. }
  14614. bitsCount = 0;
  14615. marker = data[offset] << 8 | data[offset + 1];
  14616. while (data[offset] === 0x00 && offset < data.length - 1) {
  14617. offset++;
  14618. marker = data[offset] << 8 | data[offset + 1];
  14619. }
  14620. if (marker <= 0xFF00) {
  14621. error('JPEG error: marker was not found');
  14622. }
  14623. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  14624. offset += 2;
  14625. } else {
  14626. break;
  14627. }
  14628. }
  14629. return offset - startOffset;
  14630. }
  14631. function quantizeAndInverse(component, blockBufferOffset, p) {
  14632. var qt = component.quantizationTable, blockData = component.blockData;
  14633. var v0, v1, v2, v3, v4, v5, v6, v7;
  14634. var p0, p1, p2, p3, p4, p5, p6, p7;
  14635. var t;
  14636. if (!qt) {
  14637. error('JPEG error: missing required Quantization Table.');
  14638. }
  14639. for (var row = 0; row < 64; row += 8) {
  14640. p0 = blockData[blockBufferOffset + row];
  14641. p1 = blockData[blockBufferOffset + row + 1];
  14642. p2 = blockData[blockBufferOffset + row + 2];
  14643. p3 = blockData[blockBufferOffset + row + 3];
  14644. p4 = blockData[blockBufferOffset + row + 4];
  14645. p5 = blockData[blockBufferOffset + row + 5];
  14646. p6 = blockData[blockBufferOffset + row + 6];
  14647. p7 = blockData[blockBufferOffset + row + 7];
  14648. p0 *= qt[row];
  14649. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14650. t = dctSqrt2 * p0 + 512 >> 10;
  14651. p[row] = t;
  14652. p[row + 1] = t;
  14653. p[row + 2] = t;
  14654. p[row + 3] = t;
  14655. p[row + 4] = t;
  14656. p[row + 5] = t;
  14657. p[row + 6] = t;
  14658. p[row + 7] = t;
  14659. continue;
  14660. }
  14661. p1 *= qt[row + 1];
  14662. p2 *= qt[row + 2];
  14663. p3 *= qt[row + 3];
  14664. p4 *= qt[row + 4];
  14665. p5 *= qt[row + 5];
  14666. p6 *= qt[row + 6];
  14667. p7 *= qt[row + 7];
  14668. v0 = dctSqrt2 * p0 + 128 >> 8;
  14669. v1 = dctSqrt2 * p4 + 128 >> 8;
  14670. v2 = p2;
  14671. v3 = p6;
  14672. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  14673. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  14674. v5 = p3 << 4;
  14675. v6 = p5 << 4;
  14676. v0 = v0 + v1 + 1 >> 1;
  14677. v1 = v0 - v1;
  14678. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  14679. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  14680. v3 = t;
  14681. v4 = v4 + v6 + 1 >> 1;
  14682. v6 = v4 - v6;
  14683. v7 = v7 + v5 + 1 >> 1;
  14684. v5 = v7 - v5;
  14685. v0 = v0 + v3 + 1 >> 1;
  14686. v3 = v0 - v3;
  14687. v1 = v1 + v2 + 1 >> 1;
  14688. v2 = v1 - v2;
  14689. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14690. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14691. v7 = t;
  14692. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14693. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14694. v6 = t;
  14695. p[row] = v0 + v7;
  14696. p[row + 7] = v0 - v7;
  14697. p[row + 1] = v1 + v6;
  14698. p[row + 6] = v1 - v6;
  14699. p[row + 2] = v2 + v5;
  14700. p[row + 5] = v2 - v5;
  14701. p[row + 3] = v3 + v4;
  14702. p[row + 4] = v3 - v4;
  14703. }
  14704. for (var col = 0; col < 8; ++col) {
  14705. p0 = p[col];
  14706. p1 = p[col + 8];
  14707. p2 = p[col + 16];
  14708. p3 = p[col + 24];
  14709. p4 = p[col + 32];
  14710. p5 = p[col + 40];
  14711. p6 = p[col + 48];
  14712. p7 = p[col + 56];
  14713. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14714. t = dctSqrt2 * p0 + 8192 >> 14;
  14715. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  14716. blockData[blockBufferOffset + col] = t;
  14717. blockData[blockBufferOffset + col + 8] = t;
  14718. blockData[blockBufferOffset + col + 16] = t;
  14719. blockData[blockBufferOffset + col + 24] = t;
  14720. blockData[blockBufferOffset + col + 32] = t;
  14721. blockData[blockBufferOffset + col + 40] = t;
  14722. blockData[blockBufferOffset + col + 48] = t;
  14723. blockData[blockBufferOffset + col + 56] = t;
  14724. continue;
  14725. }
  14726. v0 = dctSqrt2 * p0 + 2048 >> 12;
  14727. v1 = dctSqrt2 * p4 + 2048 >> 12;
  14728. v2 = p2;
  14729. v3 = p6;
  14730. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  14731. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  14732. v5 = p3;
  14733. v6 = p5;
  14734. v0 = (v0 + v1 + 1 >> 1) + 4112;
  14735. v1 = v0 - v1;
  14736. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  14737. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  14738. v3 = t;
  14739. v4 = v4 + v6 + 1 >> 1;
  14740. v6 = v4 - v6;
  14741. v7 = v7 + v5 + 1 >> 1;
  14742. v5 = v7 - v5;
  14743. v0 = v0 + v3 + 1 >> 1;
  14744. v3 = v0 - v3;
  14745. v1 = v1 + v2 + 1 >> 1;
  14746. v2 = v1 - v2;
  14747. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14748. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14749. v7 = t;
  14750. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14751. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14752. v6 = t;
  14753. p0 = v0 + v7;
  14754. p7 = v0 - v7;
  14755. p1 = v1 + v6;
  14756. p6 = v1 - v6;
  14757. p2 = v2 + v5;
  14758. p5 = v2 - v5;
  14759. p3 = v3 + v4;
  14760. p4 = v3 - v4;
  14761. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  14762. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  14763. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  14764. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  14765. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  14766. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  14767. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  14768. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  14769. blockData[blockBufferOffset + col] = p0;
  14770. blockData[blockBufferOffset + col + 8] = p1;
  14771. blockData[blockBufferOffset + col + 16] = p2;
  14772. blockData[blockBufferOffset + col + 24] = p3;
  14773. blockData[blockBufferOffset + col + 32] = p4;
  14774. blockData[blockBufferOffset + col + 40] = p5;
  14775. blockData[blockBufferOffset + col + 48] = p6;
  14776. blockData[blockBufferOffset + col + 56] = p7;
  14777. }
  14778. }
  14779. function buildComponentData(frame, component) {
  14780. var blocksPerLine = component.blocksPerLine;
  14781. var blocksPerColumn = component.blocksPerColumn;
  14782. var computationBuffer = new Int16Array(64);
  14783. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  14784. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  14785. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14786. quantizeAndInverse(component, offset, computationBuffer);
  14787. }
  14788. }
  14789. return component.blockData;
  14790. }
  14791. function clamp0to255(a) {
  14792. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  14793. }
  14794. JpegImage.prototype = {
  14795. parse: function parse(data) {
  14796. function readUint16() {
  14797. var value = data[offset] << 8 | data[offset + 1];
  14798. offset += 2;
  14799. return value;
  14800. }
  14801. function readDataBlock() {
  14802. var length = readUint16();
  14803. var array = data.subarray(offset, offset + length - 2);
  14804. offset += array.length;
  14805. return array;
  14806. }
  14807. function prepareComponents(frame) {
  14808. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  14809. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  14810. for (var i = 0; i < frame.components.length; i++) {
  14811. component = frame.components[i];
  14812. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  14813. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  14814. var blocksPerLineForMcu = mcusPerLine * component.h;
  14815. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  14816. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  14817. component.blockData = new Int16Array(blocksBufferSize);
  14818. component.blocksPerLine = blocksPerLine;
  14819. component.blocksPerColumn = blocksPerColumn;
  14820. }
  14821. frame.mcusPerLine = mcusPerLine;
  14822. frame.mcusPerColumn = mcusPerColumn;
  14823. }
  14824. var offset = 0;
  14825. var jfif = null;
  14826. var adobe = null;
  14827. var frame, resetInterval;
  14828. var quantizationTables = [];
  14829. var huffmanTablesAC = [], huffmanTablesDC = [];
  14830. var fileMarker = readUint16();
  14831. if (fileMarker !== 0xFFD8) {
  14832. error('JPEG error: SOI not found');
  14833. }
  14834. fileMarker = readUint16();
  14835. while (fileMarker !== 0xFFD9) {
  14836. var i, j, l;
  14837. switch (fileMarker) {
  14838. case 0xFFE0:
  14839. case 0xFFE1:
  14840. case 0xFFE2:
  14841. case 0xFFE3:
  14842. case 0xFFE4:
  14843. case 0xFFE5:
  14844. case 0xFFE6:
  14845. case 0xFFE7:
  14846. case 0xFFE8:
  14847. case 0xFFE9:
  14848. case 0xFFEA:
  14849. case 0xFFEB:
  14850. case 0xFFEC:
  14851. case 0xFFED:
  14852. case 0xFFEE:
  14853. case 0xFFEF:
  14854. case 0xFFFE:
  14855. var appData = readDataBlock();
  14856. if (fileMarker === 0xFFE0) {
  14857. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  14858. jfif = {
  14859. version: {
  14860. major: appData[5],
  14861. minor: appData[6]
  14862. },
  14863. densityUnits: appData[7],
  14864. xDensity: appData[8] << 8 | appData[9],
  14865. yDensity: appData[10] << 8 | appData[11],
  14866. thumbWidth: appData[12],
  14867. thumbHeight: appData[13],
  14868. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  14869. };
  14870. }
  14871. }
  14872. if (fileMarker === 0xFFEE) {
  14873. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  14874. adobe = {
  14875. version: appData[5] << 8 | appData[6],
  14876. flags0: appData[7] << 8 | appData[8],
  14877. flags1: appData[9] << 8 | appData[10],
  14878. transformCode: appData[11]
  14879. };
  14880. }
  14881. }
  14882. break;
  14883. case 0xFFDB:
  14884. var quantizationTablesLength = readUint16();
  14885. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  14886. var z;
  14887. while (offset < quantizationTablesEnd) {
  14888. var quantizationTableSpec = data[offset++];
  14889. var tableData = new Uint16Array(64);
  14890. if (quantizationTableSpec >> 4 === 0) {
  14891. for (j = 0; j < 64; j++) {
  14892. z = dctZigZag[j];
  14893. tableData[z] = data[offset++];
  14894. }
  14895. } else if (quantizationTableSpec >> 4 === 1) {
  14896. for (j = 0; j < 64; j++) {
  14897. z = dctZigZag[j];
  14898. tableData[z] = readUint16();
  14899. }
  14900. } else {
  14901. error('JPEG error: DQT - invalid table spec');
  14902. }
  14903. quantizationTables[quantizationTableSpec & 15] = tableData;
  14904. }
  14905. break;
  14906. case 0xFFC0:
  14907. case 0xFFC1:
  14908. case 0xFFC2:
  14909. if (frame) {
  14910. error('JPEG error: Only single frame JPEGs supported');
  14911. }
  14912. readUint16();
  14913. frame = {};
  14914. frame.extended = fileMarker === 0xFFC1;
  14915. frame.progressive = fileMarker === 0xFFC2;
  14916. frame.precision = data[offset++];
  14917. frame.scanLines = readUint16();
  14918. frame.samplesPerLine = readUint16();
  14919. frame.components = [];
  14920. frame.componentIds = {};
  14921. var componentsCount = data[offset++], componentId;
  14922. var maxH = 0, maxV = 0;
  14923. for (i = 0; i < componentsCount; i++) {
  14924. componentId = data[offset];
  14925. var h = data[offset + 1] >> 4;
  14926. var v = data[offset + 1] & 15;
  14927. if (maxH < h) {
  14928. maxH = h;
  14929. }
  14930. if (maxV < v) {
  14931. maxV = v;
  14932. }
  14933. var qId = data[offset + 2];
  14934. l = frame.components.push({
  14935. h: h,
  14936. v: v,
  14937. quantizationId: qId,
  14938. quantizationTable: null
  14939. });
  14940. frame.componentIds[componentId] = l - 1;
  14941. offset += 3;
  14942. }
  14943. frame.maxH = maxH;
  14944. frame.maxV = maxV;
  14945. prepareComponents(frame);
  14946. break;
  14947. case 0xFFC4:
  14948. var huffmanLength = readUint16();
  14949. for (i = 2; i < huffmanLength;) {
  14950. var huffmanTableSpec = data[offset++];
  14951. var codeLengths = new Uint8Array(16);
  14952. var codeLengthSum = 0;
  14953. for (j = 0; j < 16; j++, offset++) {
  14954. codeLengthSum += codeLengths[j] = data[offset];
  14955. }
  14956. var huffmanValues = new Uint8Array(codeLengthSum);
  14957. for (j = 0; j < codeLengthSum; j++, offset++) {
  14958. huffmanValues[j] = data[offset];
  14959. }
  14960. i += 17 + codeLengthSum;
  14961. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  14962. }
  14963. break;
  14964. case 0xFFDD:
  14965. readUint16();
  14966. resetInterval = readUint16();
  14967. break;
  14968. case 0xFFDA:
  14969. var scanLength = readUint16();
  14970. var selectorsCount = data[offset++];
  14971. var components = [], component;
  14972. for (i = 0; i < selectorsCount; i++) {
  14973. var componentIndex = frame.componentIds[data[offset++]];
  14974. component = frame.components[componentIndex];
  14975. var tableSpec = data[offset++];
  14976. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  14977. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  14978. components.push(component);
  14979. }
  14980. var spectralStart = data[offset++];
  14981. var spectralEnd = data[offset++];
  14982. var successiveApproximation = data[offset++];
  14983. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  14984. offset += processed;
  14985. break;
  14986. case 0xFFFF:
  14987. if (data[offset] !== 0xFF) {
  14988. offset--;
  14989. }
  14990. break;
  14991. default:
  14992. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  14993. offset -= 3;
  14994. break;
  14995. }
  14996. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  14997. }
  14998. fileMarker = readUint16();
  14999. }
  15000. this.width = frame.samplesPerLine;
  15001. this.height = frame.scanLines;
  15002. this.jfif = jfif;
  15003. this.adobe = adobe;
  15004. this.components = [];
  15005. for (i = 0; i < frame.components.length; i++) {
  15006. component = frame.components[i];
  15007. var quantizationTable = quantizationTables[component.quantizationId];
  15008. if (quantizationTable) {
  15009. component.quantizationTable = quantizationTable;
  15010. }
  15011. this.components.push({
  15012. output: buildComponentData(frame, component),
  15013. scaleX: component.h / frame.maxH,
  15014. scaleY: component.v / frame.maxV,
  15015. blocksPerLine: component.blocksPerLine,
  15016. blocksPerColumn: component.blocksPerColumn
  15017. });
  15018. }
  15019. this.numComponents = this.components.length;
  15020. },
  15021. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  15022. var scaleX = this.width / width, scaleY = this.height / height;
  15023. var component, componentScaleX, componentScaleY, blocksPerScanline;
  15024. var x, y, i, j, k;
  15025. var index;
  15026. var offset = 0;
  15027. var output;
  15028. var numComponents = this.components.length;
  15029. var dataLength = width * height * numComponents;
  15030. var data = new Uint8Array(dataLength);
  15031. var xScaleBlockOffset = new Uint32Array(width);
  15032. var mask3LSB = 0xfffffff8;
  15033. for (i = 0; i < numComponents; i++) {
  15034. component = this.components[i];
  15035. componentScaleX = component.scaleX * scaleX;
  15036. componentScaleY = component.scaleY * scaleY;
  15037. offset = i;
  15038. output = component.output;
  15039. blocksPerScanline = component.blocksPerLine + 1 << 3;
  15040. for (x = 0; x < width; x++) {
  15041. j = 0 | x * componentScaleX;
  15042. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  15043. }
  15044. for (y = 0; y < height; y++) {
  15045. j = 0 | y * componentScaleY;
  15046. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  15047. for (x = 0; x < width; x++) {
  15048. data[offset] = output[index + xScaleBlockOffset[x]];
  15049. offset += numComponents;
  15050. }
  15051. }
  15052. }
  15053. var transform = this.decodeTransform;
  15054. if (transform) {
  15055. for (i = 0; i < dataLength;) {
  15056. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  15057. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  15058. }
  15059. }
  15060. }
  15061. return data;
  15062. },
  15063. _isColorConversionNeeded: function isColorConversionNeeded() {
  15064. if (this.adobe && this.adobe.transformCode) {
  15065. return true;
  15066. } else if (this.numComponents === 3) {
  15067. if (!this.adobe && this.colorTransform === 0) {
  15068. return false;
  15069. }
  15070. return true;
  15071. }
  15072. if (!this.adobe && this.colorTransform === 1) {
  15073. return true;
  15074. }
  15075. return false;
  15076. },
  15077. _convertYccToRgb: function convertYccToRgb(data) {
  15078. var Y, Cb, Cr;
  15079. for (var i = 0, length = data.length; i < length; i += 3) {
  15080. Y = data[i];
  15081. Cb = data[i + 1];
  15082. Cr = data[i + 2];
  15083. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  15084. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  15085. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  15086. }
  15087. return data;
  15088. },
  15089. _convertYcckToRgb: function convertYcckToRgb(data) {
  15090. var Y, Cb, Cr, k;
  15091. var offset = 0;
  15092. for (var i = 0, length = data.length; i < length; i += 4) {
  15093. Y = data[i];
  15094. Cb = data[i + 1];
  15095. Cr = data[i + 2];
  15096. k = data[i + 3];
  15097. 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);
  15098. 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);
  15099. 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);
  15100. data[offset++] = clamp0to255(r);
  15101. data[offset++] = clamp0to255(g);
  15102. data[offset++] = clamp0to255(b);
  15103. }
  15104. return data;
  15105. },
  15106. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  15107. var Y, Cb, Cr;
  15108. for (var i = 0, length = data.length; i < length; i += 4) {
  15109. Y = data[i];
  15110. Cb = data[i + 1];
  15111. Cr = data[i + 2];
  15112. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  15113. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  15114. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  15115. }
  15116. return data;
  15117. },
  15118. _convertCmykToRgb: function convertCmykToRgb(data) {
  15119. var c, m, y, k;
  15120. var offset = 0;
  15121. var min = -255 * 255 * 255;
  15122. var scale = 1 / 255 / 255;
  15123. for (var i = 0, length = data.length; i < length; i += 4) {
  15124. c = data[i];
  15125. m = data[i + 1];
  15126. y = data[i + 2];
  15127. k = data[i + 3];
  15128. 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);
  15129. 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);
  15130. 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);
  15131. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  15132. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  15133. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  15134. }
  15135. return data;
  15136. },
  15137. getData: function getData(width, height, forceRGBoutput) {
  15138. if (this.numComponents > 4) {
  15139. error('JPEG error: Unsupported color mode');
  15140. }
  15141. var data = this._getLinearizedBlockData(width, height);
  15142. if (this.numComponents === 1 && forceRGBoutput) {
  15143. var dataLength = data.length;
  15144. var rgbData = new Uint8Array(dataLength * 3);
  15145. var offset = 0;
  15146. for (var i = 0; i < dataLength; i++) {
  15147. var grayColor = data[i];
  15148. rgbData[offset++] = grayColor;
  15149. rgbData[offset++] = grayColor;
  15150. rgbData[offset++] = grayColor;
  15151. }
  15152. return rgbData;
  15153. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  15154. return this._convertYccToRgb(data);
  15155. } else if (this.numComponents === 4) {
  15156. if (this._isColorConversionNeeded()) {
  15157. if (forceRGBoutput) {
  15158. return this._convertYcckToRgb(data);
  15159. }
  15160. return this._convertYcckToCmyk(data);
  15161. } else if (forceRGBoutput) {
  15162. return this._convertCmykToRgb(data);
  15163. }
  15164. }
  15165. return data;
  15166. }
  15167. };
  15168. return JpegImage;
  15169. }();
  15170. exports.JpegImage = JpegImage;
  15171. }));
  15172. (function (root, factory) {
  15173. factory(root.pdfjsCoreJpx = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  15174. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  15175. var info = sharedUtil.info;
  15176. var warn = sharedUtil.warn;
  15177. var error = sharedUtil.error;
  15178. var log2 = sharedUtil.log2;
  15179. var readUint16 = sharedUtil.readUint16;
  15180. var readUint32 = sharedUtil.readUint32;
  15181. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  15182. var JpxImage = function JpxImageClosure() {
  15183. var SubbandsGainLog2 = {
  15184. 'LL': 0,
  15185. 'LH': 1,
  15186. 'HL': 1,
  15187. 'HH': 2
  15188. };
  15189. function JpxImage() {
  15190. this.failOnCorruptedImage = false;
  15191. }
  15192. JpxImage.prototype = {
  15193. parse: function JpxImage_parse(data) {
  15194. var head = readUint16(data, 0);
  15195. if (head === 0xFF4F) {
  15196. this.parseCodestream(data, 0, data.length);
  15197. return;
  15198. }
  15199. var position = 0, length = data.length;
  15200. while (position < length) {
  15201. var headerSize = 8;
  15202. var lbox = readUint32(data, position);
  15203. var tbox = readUint32(data, position + 4);
  15204. position += headerSize;
  15205. if (lbox === 1) {
  15206. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  15207. position += 8;
  15208. headerSize += 8;
  15209. }
  15210. if (lbox === 0) {
  15211. lbox = length - position + headerSize;
  15212. }
  15213. if (lbox < headerSize) {
  15214. error('JPX Error: Invalid box field size');
  15215. }
  15216. var dataLength = lbox - headerSize;
  15217. var jumpDataLength = true;
  15218. switch (tbox) {
  15219. case 0x6A703268:
  15220. jumpDataLength = false;
  15221. break;
  15222. case 0x636F6C72:
  15223. var method = data[position];
  15224. if (method === 1) {
  15225. var colorspace = readUint32(data, position + 3);
  15226. switch (colorspace) {
  15227. case 16:
  15228. case 17:
  15229. case 18:
  15230. break;
  15231. default:
  15232. warn('Unknown colorspace ' + colorspace);
  15233. break;
  15234. }
  15235. } else if (method === 2) {
  15236. info('ICC profile not supported');
  15237. }
  15238. break;
  15239. case 0x6A703263:
  15240. this.parseCodestream(data, position, position + dataLength);
  15241. break;
  15242. case 0x6A502020:
  15243. if (0x0d0a870a !== readUint32(data, position)) {
  15244. warn('Invalid JP2 signature');
  15245. }
  15246. break;
  15247. case 0x6A501A1A:
  15248. case 0x66747970:
  15249. case 0x72726571:
  15250. case 0x72657320:
  15251. case 0x69686472:
  15252. break;
  15253. default:
  15254. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  15255. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  15256. break;
  15257. }
  15258. if (jumpDataLength) {
  15259. position += dataLength;
  15260. }
  15261. }
  15262. },
  15263. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  15264. var newByte = stream.getByte();
  15265. while (newByte >= 0) {
  15266. var oldByte = newByte;
  15267. newByte = stream.getByte();
  15268. var code = oldByte << 8 | newByte;
  15269. if (code === 0xFF51) {
  15270. stream.skip(4);
  15271. var Xsiz = stream.getInt32() >>> 0;
  15272. var Ysiz = stream.getInt32() >>> 0;
  15273. var XOsiz = stream.getInt32() >>> 0;
  15274. var YOsiz = stream.getInt32() >>> 0;
  15275. stream.skip(16);
  15276. var Csiz = stream.getUint16();
  15277. this.width = Xsiz - XOsiz;
  15278. this.height = Ysiz - YOsiz;
  15279. this.componentsCount = Csiz;
  15280. this.bitsPerComponent = 8;
  15281. return;
  15282. }
  15283. }
  15284. error('JPX Error: No size marker found in JPX stream');
  15285. },
  15286. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  15287. var context = {};
  15288. var doNotRecover = false;
  15289. try {
  15290. var position = start;
  15291. while (position + 1 < end) {
  15292. var code = readUint16(data, position);
  15293. position += 2;
  15294. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  15295. switch (code) {
  15296. case 0xFF4F:
  15297. context.mainHeader = true;
  15298. break;
  15299. case 0xFFD9:
  15300. break;
  15301. case 0xFF51:
  15302. length = readUint16(data, position);
  15303. var siz = {};
  15304. siz.Xsiz = readUint32(data, position + 4);
  15305. siz.Ysiz = readUint32(data, position + 8);
  15306. siz.XOsiz = readUint32(data, position + 12);
  15307. siz.YOsiz = readUint32(data, position + 16);
  15308. siz.XTsiz = readUint32(data, position + 20);
  15309. siz.YTsiz = readUint32(data, position + 24);
  15310. siz.XTOsiz = readUint32(data, position + 28);
  15311. siz.YTOsiz = readUint32(data, position + 32);
  15312. var componentsCount = readUint16(data, position + 36);
  15313. siz.Csiz = componentsCount;
  15314. var components = [];
  15315. j = position + 38;
  15316. for (var i = 0; i < componentsCount; i++) {
  15317. var component = {
  15318. precision: (data[j] & 0x7F) + 1,
  15319. isSigned: !!(data[j] & 0x80),
  15320. XRsiz: data[j + 1],
  15321. YRsiz: data[j + 1]
  15322. };
  15323. calculateComponentDimensions(component, siz);
  15324. components.push(component);
  15325. }
  15326. context.SIZ = siz;
  15327. context.components = components;
  15328. calculateTileGrids(context, components);
  15329. context.QCC = [];
  15330. context.COC = [];
  15331. break;
  15332. case 0xFF5C:
  15333. length = readUint16(data, position);
  15334. var qcd = {};
  15335. j = position + 2;
  15336. sqcd = data[j++];
  15337. switch (sqcd & 0x1F) {
  15338. case 0:
  15339. spqcdSize = 8;
  15340. scalarExpounded = true;
  15341. break;
  15342. case 1:
  15343. spqcdSize = 16;
  15344. scalarExpounded = false;
  15345. break;
  15346. case 2:
  15347. spqcdSize = 16;
  15348. scalarExpounded = true;
  15349. break;
  15350. default:
  15351. throw new Error('Invalid SQcd value ' + sqcd);
  15352. }
  15353. qcd.noQuantization = spqcdSize === 8;
  15354. qcd.scalarExpounded = scalarExpounded;
  15355. qcd.guardBits = sqcd >> 5;
  15356. spqcds = [];
  15357. while (j < length + position) {
  15358. var spqcd = {};
  15359. if (spqcdSize === 8) {
  15360. spqcd.epsilon = data[j++] >> 3;
  15361. spqcd.mu = 0;
  15362. } else {
  15363. spqcd.epsilon = data[j] >> 3;
  15364. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15365. j += 2;
  15366. }
  15367. spqcds.push(spqcd);
  15368. }
  15369. qcd.SPqcds = spqcds;
  15370. if (context.mainHeader) {
  15371. context.QCD = qcd;
  15372. } else {
  15373. context.currentTile.QCD = qcd;
  15374. context.currentTile.QCC = [];
  15375. }
  15376. break;
  15377. case 0xFF5D:
  15378. length = readUint16(data, position);
  15379. var qcc = {};
  15380. j = position + 2;
  15381. var cqcc;
  15382. if (context.SIZ.Csiz < 257) {
  15383. cqcc = data[j++];
  15384. } else {
  15385. cqcc = readUint16(data, j);
  15386. j += 2;
  15387. }
  15388. sqcd = data[j++];
  15389. switch (sqcd & 0x1F) {
  15390. case 0:
  15391. spqcdSize = 8;
  15392. scalarExpounded = true;
  15393. break;
  15394. case 1:
  15395. spqcdSize = 16;
  15396. scalarExpounded = false;
  15397. break;
  15398. case 2:
  15399. spqcdSize = 16;
  15400. scalarExpounded = true;
  15401. break;
  15402. default:
  15403. throw new Error('Invalid SQcd value ' + sqcd);
  15404. }
  15405. qcc.noQuantization = spqcdSize === 8;
  15406. qcc.scalarExpounded = scalarExpounded;
  15407. qcc.guardBits = sqcd >> 5;
  15408. spqcds = [];
  15409. while (j < length + position) {
  15410. spqcd = {};
  15411. if (spqcdSize === 8) {
  15412. spqcd.epsilon = data[j++] >> 3;
  15413. spqcd.mu = 0;
  15414. } else {
  15415. spqcd.epsilon = data[j] >> 3;
  15416. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15417. j += 2;
  15418. }
  15419. spqcds.push(spqcd);
  15420. }
  15421. qcc.SPqcds = spqcds;
  15422. if (context.mainHeader) {
  15423. context.QCC[cqcc] = qcc;
  15424. } else {
  15425. context.currentTile.QCC[cqcc] = qcc;
  15426. }
  15427. break;
  15428. case 0xFF52:
  15429. length = readUint16(data, position);
  15430. var cod = {};
  15431. j = position + 2;
  15432. var scod = data[j++];
  15433. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  15434. cod.sopMarkerUsed = !!(scod & 2);
  15435. cod.ephMarkerUsed = !!(scod & 4);
  15436. cod.progressionOrder = data[j++];
  15437. cod.layersCount = readUint16(data, j);
  15438. j += 2;
  15439. cod.multipleComponentTransform = data[j++];
  15440. cod.decompositionLevelsCount = data[j++];
  15441. cod.xcb = (data[j++] & 0xF) + 2;
  15442. cod.ycb = (data[j++] & 0xF) + 2;
  15443. var blockStyle = data[j++];
  15444. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  15445. cod.resetContextProbabilities = !!(blockStyle & 2);
  15446. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  15447. cod.verticalyStripe = !!(blockStyle & 8);
  15448. cod.predictableTermination = !!(blockStyle & 16);
  15449. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  15450. cod.reversibleTransformation = data[j++];
  15451. if (cod.entropyCoderWithCustomPrecincts) {
  15452. var precinctsSizes = [];
  15453. while (j < length + position) {
  15454. var precinctsSize = data[j++];
  15455. precinctsSizes.push({
  15456. PPx: precinctsSize & 0xF,
  15457. PPy: precinctsSize >> 4
  15458. });
  15459. }
  15460. cod.precinctsSizes = precinctsSizes;
  15461. }
  15462. var unsupported = [];
  15463. if (cod.selectiveArithmeticCodingBypass) {
  15464. unsupported.push('selectiveArithmeticCodingBypass');
  15465. }
  15466. if (cod.resetContextProbabilities) {
  15467. unsupported.push('resetContextProbabilities');
  15468. }
  15469. if (cod.terminationOnEachCodingPass) {
  15470. unsupported.push('terminationOnEachCodingPass');
  15471. }
  15472. if (cod.verticalyStripe) {
  15473. unsupported.push('verticalyStripe');
  15474. }
  15475. if (cod.predictableTermination) {
  15476. unsupported.push('predictableTermination');
  15477. }
  15478. if (unsupported.length > 0) {
  15479. doNotRecover = true;
  15480. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  15481. }
  15482. if (context.mainHeader) {
  15483. context.COD = cod;
  15484. } else {
  15485. context.currentTile.COD = cod;
  15486. context.currentTile.COC = [];
  15487. }
  15488. break;
  15489. case 0xFF90:
  15490. length = readUint16(data, position);
  15491. tile = {};
  15492. tile.index = readUint16(data, position + 2);
  15493. tile.length = readUint32(data, position + 4);
  15494. tile.dataEnd = tile.length + position - 2;
  15495. tile.partIndex = data[position + 8];
  15496. tile.partsCount = data[position + 9];
  15497. context.mainHeader = false;
  15498. if (tile.partIndex === 0) {
  15499. tile.COD = context.COD;
  15500. tile.COC = context.COC.slice(0);
  15501. tile.QCD = context.QCD;
  15502. tile.QCC = context.QCC.slice(0);
  15503. }
  15504. context.currentTile = tile;
  15505. break;
  15506. case 0xFF93:
  15507. tile = context.currentTile;
  15508. if (tile.partIndex === 0) {
  15509. initializeTile(context, tile.index);
  15510. buildPackets(context);
  15511. }
  15512. length = tile.dataEnd - position;
  15513. parseTilePackets(context, data, position, length);
  15514. break;
  15515. case 0xFF55:
  15516. case 0xFF57:
  15517. case 0xFF58:
  15518. case 0xFF64:
  15519. length = readUint16(data, position);
  15520. break;
  15521. case 0xFF53:
  15522. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  15523. default:
  15524. throw new Error('Unknown codestream code: ' + code.toString(16));
  15525. }
  15526. position += length;
  15527. }
  15528. } catch (e) {
  15529. if (doNotRecover || this.failOnCorruptedImage) {
  15530. error('JPX Error: ' + e.message);
  15531. } else {
  15532. warn('JPX: Trying to recover from: ' + e.message);
  15533. }
  15534. }
  15535. this.tiles = transformComponents(context);
  15536. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  15537. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  15538. this.componentsCount = context.SIZ.Csiz;
  15539. }
  15540. };
  15541. function calculateComponentDimensions(component, siz) {
  15542. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  15543. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  15544. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  15545. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  15546. component.width = component.x1 - component.x0;
  15547. component.height = component.y1 - component.y0;
  15548. }
  15549. function calculateTileGrids(context, components) {
  15550. var siz = context.SIZ;
  15551. var tile, tiles = [];
  15552. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  15553. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  15554. for (var q = 0; q < numYtiles; q++) {
  15555. for (var p = 0; p < numXtiles; p++) {
  15556. tile = {};
  15557. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  15558. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  15559. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  15560. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  15561. tile.width = tile.tx1 - tile.tx0;
  15562. tile.height = tile.ty1 - tile.ty0;
  15563. tile.components = [];
  15564. tiles.push(tile);
  15565. }
  15566. }
  15567. context.tiles = tiles;
  15568. var componentsCount = siz.Csiz;
  15569. for (var i = 0, ii = componentsCount; i < ii; i++) {
  15570. var component = components[i];
  15571. for (var j = 0, jj = tiles.length; j < jj; j++) {
  15572. var tileComponent = {};
  15573. tile = tiles[j];
  15574. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  15575. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  15576. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  15577. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  15578. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  15579. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  15580. tile.components[i] = tileComponent;
  15581. }
  15582. }
  15583. }
  15584. function getBlocksDimensions(context, component, r) {
  15585. var codOrCoc = component.codingStyleParameters;
  15586. var result = {};
  15587. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  15588. result.PPx = 15;
  15589. result.PPy = 15;
  15590. } else {
  15591. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  15592. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  15593. }
  15594. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  15595. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  15596. return result;
  15597. }
  15598. function buildPrecincts(context, resolution, dimensions) {
  15599. var precinctWidth = 1 << dimensions.PPx;
  15600. var precinctHeight = 1 << dimensions.PPy;
  15601. var isZeroRes = resolution.resLevel === 0;
  15602. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  15603. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  15604. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  15605. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  15606. var numprecincts = numprecinctswide * numprecinctshigh;
  15607. resolution.precinctParameters = {
  15608. precinctWidth: precinctWidth,
  15609. precinctHeight: precinctHeight,
  15610. numprecinctswide: numprecinctswide,
  15611. numprecinctshigh: numprecinctshigh,
  15612. numprecincts: numprecincts,
  15613. precinctWidthInSubband: precinctWidthInSubband,
  15614. precinctHeightInSubband: precinctHeightInSubband
  15615. };
  15616. }
  15617. function buildCodeblocks(context, subband, dimensions) {
  15618. var xcb_ = dimensions.xcb_;
  15619. var ycb_ = dimensions.ycb_;
  15620. var codeblockWidth = 1 << xcb_;
  15621. var codeblockHeight = 1 << ycb_;
  15622. var cbx0 = subband.tbx0 >> xcb_;
  15623. var cby0 = subband.tby0 >> ycb_;
  15624. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  15625. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  15626. var precinctParameters = subband.resolution.precinctParameters;
  15627. var codeblocks = [];
  15628. var precincts = [];
  15629. var i, j, codeblock, precinctNumber;
  15630. for (j = cby0; j < cby1; j++) {
  15631. for (i = cbx0; i < cbx1; i++) {
  15632. codeblock = {
  15633. cbx: i,
  15634. cby: j,
  15635. tbx0: codeblockWidth * i,
  15636. tby0: codeblockHeight * j,
  15637. tbx1: codeblockWidth * (i + 1),
  15638. tby1: codeblockHeight * (j + 1)
  15639. };
  15640. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  15641. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  15642. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  15643. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  15644. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  15645. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  15646. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  15647. codeblock.precinctNumber = precinctNumber;
  15648. codeblock.subbandType = subband.type;
  15649. codeblock.Lblock = 3;
  15650. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  15651. continue;
  15652. }
  15653. codeblocks.push(codeblock);
  15654. var precinct = precincts[precinctNumber];
  15655. if (precinct !== undefined) {
  15656. if (i < precinct.cbxMin) {
  15657. precinct.cbxMin = i;
  15658. } else if (i > precinct.cbxMax) {
  15659. precinct.cbxMax = i;
  15660. }
  15661. if (j < precinct.cbyMin) {
  15662. precinct.cbxMin = j;
  15663. } else if (j > precinct.cbyMax) {
  15664. precinct.cbyMax = j;
  15665. }
  15666. } else {
  15667. precincts[precinctNumber] = precinct = {
  15668. cbxMin: i,
  15669. cbyMin: j,
  15670. cbxMax: i,
  15671. cbyMax: j
  15672. };
  15673. }
  15674. codeblock.precinct = precinct;
  15675. }
  15676. }
  15677. subband.codeblockParameters = {
  15678. codeblockWidth: xcb_,
  15679. codeblockHeight: ycb_,
  15680. numcodeblockwide: cbx1 - cbx0 + 1,
  15681. numcodeblockhigh: cby1 - cby0 + 1
  15682. };
  15683. subband.codeblocks = codeblocks;
  15684. subband.precincts = precincts;
  15685. }
  15686. function createPacket(resolution, precinctNumber, layerNumber) {
  15687. var precinctCodeblocks = [];
  15688. var subbands = resolution.subbands;
  15689. for (var i = 0, ii = subbands.length; i < ii; i++) {
  15690. var subband = subbands[i];
  15691. var codeblocks = subband.codeblocks;
  15692. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  15693. var codeblock = codeblocks[j];
  15694. if (codeblock.precinctNumber !== precinctNumber) {
  15695. continue;
  15696. }
  15697. precinctCodeblocks.push(codeblock);
  15698. }
  15699. }
  15700. return {
  15701. layerNumber: layerNumber,
  15702. codeblocks: precinctCodeblocks
  15703. };
  15704. }
  15705. function LayerResolutionComponentPositionIterator(context) {
  15706. var siz = context.SIZ;
  15707. var tileIndex = context.currentTile.index;
  15708. var tile = context.tiles[tileIndex];
  15709. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15710. var componentsCount = siz.Csiz;
  15711. var maxDecompositionLevelsCount = 0;
  15712. for (var q = 0; q < componentsCount; q++) {
  15713. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15714. }
  15715. var l = 0, r = 0, i = 0, k = 0;
  15716. this.nextPacket = function JpxImage_nextPacket() {
  15717. for (; l < layersCount; l++) {
  15718. for (; r <= maxDecompositionLevelsCount; r++) {
  15719. for (; i < componentsCount; i++) {
  15720. var component = tile.components[i];
  15721. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15722. continue;
  15723. }
  15724. var resolution = component.resolutions[r];
  15725. var numprecincts = resolution.precinctParameters.numprecincts;
  15726. for (; k < numprecincts;) {
  15727. var packet = createPacket(resolution, k, l);
  15728. k++;
  15729. return packet;
  15730. }
  15731. k = 0;
  15732. }
  15733. i = 0;
  15734. }
  15735. r = 0;
  15736. }
  15737. error('JPX Error: Out of packets');
  15738. };
  15739. }
  15740. function ResolutionLayerComponentPositionIterator(context) {
  15741. var siz = context.SIZ;
  15742. var tileIndex = context.currentTile.index;
  15743. var tile = context.tiles[tileIndex];
  15744. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15745. var componentsCount = siz.Csiz;
  15746. var maxDecompositionLevelsCount = 0;
  15747. for (var q = 0; q < componentsCount; q++) {
  15748. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15749. }
  15750. var r = 0, l = 0, i = 0, k = 0;
  15751. this.nextPacket = function JpxImage_nextPacket() {
  15752. for (; r <= maxDecompositionLevelsCount; r++) {
  15753. for (; l < layersCount; l++) {
  15754. for (; i < componentsCount; i++) {
  15755. var component = tile.components[i];
  15756. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15757. continue;
  15758. }
  15759. var resolution = component.resolutions[r];
  15760. var numprecincts = resolution.precinctParameters.numprecincts;
  15761. for (; k < numprecincts;) {
  15762. var packet = createPacket(resolution, k, l);
  15763. k++;
  15764. return packet;
  15765. }
  15766. k = 0;
  15767. }
  15768. i = 0;
  15769. }
  15770. l = 0;
  15771. }
  15772. error('JPX Error: Out of packets');
  15773. };
  15774. }
  15775. function ResolutionPositionComponentLayerIterator(context) {
  15776. var siz = context.SIZ;
  15777. var tileIndex = context.currentTile.index;
  15778. var tile = context.tiles[tileIndex];
  15779. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15780. var componentsCount = siz.Csiz;
  15781. var l, r, c, p;
  15782. var maxDecompositionLevelsCount = 0;
  15783. for (c = 0; c < componentsCount; c++) {
  15784. var component = tile.components[c];
  15785. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  15786. }
  15787. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  15788. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  15789. var maxNumPrecincts = 0;
  15790. for (c = 0; c < componentsCount; ++c) {
  15791. var resolutions = tile.components[c].resolutions;
  15792. if (r < resolutions.length) {
  15793. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  15794. }
  15795. }
  15796. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  15797. }
  15798. l = 0;
  15799. r = 0;
  15800. c = 0;
  15801. p = 0;
  15802. this.nextPacket = function JpxImage_nextPacket() {
  15803. for (; r <= maxDecompositionLevelsCount; r++) {
  15804. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  15805. for (; c < componentsCount; c++) {
  15806. var component = tile.components[c];
  15807. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15808. continue;
  15809. }
  15810. var resolution = component.resolutions[r];
  15811. var numprecincts = resolution.precinctParameters.numprecincts;
  15812. if (p >= numprecincts) {
  15813. continue;
  15814. }
  15815. for (; l < layersCount;) {
  15816. var packet = createPacket(resolution, p, l);
  15817. l++;
  15818. return packet;
  15819. }
  15820. l = 0;
  15821. }
  15822. c = 0;
  15823. }
  15824. p = 0;
  15825. }
  15826. error('JPX Error: Out of packets');
  15827. };
  15828. }
  15829. function PositionComponentResolutionLayerIterator(context) {
  15830. var siz = context.SIZ;
  15831. var tileIndex = context.currentTile.index;
  15832. var tile = context.tiles[tileIndex];
  15833. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15834. var componentsCount = siz.Csiz;
  15835. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15836. var precinctsIterationSizes = precinctsSizes;
  15837. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15838. this.nextPacket = function JpxImage_nextPacket() {
  15839. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15840. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15841. for (; c < componentsCount; c++) {
  15842. var component = tile.components[c];
  15843. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15844. for (; r <= decompositionLevelsCount; r++) {
  15845. var resolution = component.resolutions[r];
  15846. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  15847. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15848. if (k === null) {
  15849. continue;
  15850. }
  15851. for (; l < layersCount;) {
  15852. var packet = createPacket(resolution, k, l);
  15853. l++;
  15854. return packet;
  15855. }
  15856. l = 0;
  15857. }
  15858. r = 0;
  15859. }
  15860. c = 0;
  15861. }
  15862. px = 0;
  15863. }
  15864. error('JPX Error: Out of packets');
  15865. };
  15866. }
  15867. function ComponentPositionResolutionLayerIterator(context) {
  15868. var siz = context.SIZ;
  15869. var tileIndex = context.currentTile.index;
  15870. var tile = context.tiles[tileIndex];
  15871. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15872. var componentsCount = siz.Csiz;
  15873. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15874. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15875. this.nextPacket = function JpxImage_nextPacket() {
  15876. for (; c < componentsCount; ++c) {
  15877. var component = tile.components[c];
  15878. var precinctsIterationSizes = precinctsSizes.components[c];
  15879. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15880. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15881. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15882. for (; r <= decompositionLevelsCount; r++) {
  15883. var resolution = component.resolutions[r];
  15884. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  15885. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15886. if (k === null) {
  15887. continue;
  15888. }
  15889. for (; l < layersCount;) {
  15890. var packet = createPacket(resolution, k, l);
  15891. l++;
  15892. return packet;
  15893. }
  15894. l = 0;
  15895. }
  15896. r = 0;
  15897. }
  15898. px = 0;
  15899. }
  15900. py = 0;
  15901. }
  15902. error('JPX Error: Out of packets');
  15903. };
  15904. }
  15905. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  15906. var posX = pxIndex * precinctIterationSizes.minWidth;
  15907. var posY = pyIndex * precinctIterationSizes.minHeight;
  15908. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  15909. return null;
  15910. }
  15911. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  15912. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  15913. }
  15914. function getPrecinctSizesInImageScale(tile) {
  15915. var componentsCount = tile.components.length;
  15916. var minWidth = Number.MAX_VALUE;
  15917. var minHeight = Number.MAX_VALUE;
  15918. var maxNumWide = 0;
  15919. var maxNumHigh = 0;
  15920. var sizePerComponent = new Array(componentsCount);
  15921. for (var c = 0; c < componentsCount; c++) {
  15922. var component = tile.components[c];
  15923. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15924. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  15925. var minWidthCurrentComponent = Number.MAX_VALUE;
  15926. var minHeightCurrentComponent = Number.MAX_VALUE;
  15927. var maxNumWideCurrentComponent = 0;
  15928. var maxNumHighCurrentComponent = 0;
  15929. var scale = 1;
  15930. for (var r = decompositionLevelsCount; r >= 0; --r) {
  15931. var resolution = component.resolutions[r];
  15932. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  15933. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  15934. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  15935. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  15936. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  15937. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  15938. sizePerResolution[r] = {
  15939. width: widthCurrentResolution,
  15940. height: heightCurrentResolution
  15941. };
  15942. scale <<= 1;
  15943. }
  15944. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  15945. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  15946. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  15947. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  15948. sizePerComponent[c] = {
  15949. resolutions: sizePerResolution,
  15950. minWidth: minWidthCurrentComponent,
  15951. minHeight: minHeightCurrentComponent,
  15952. maxNumWide: maxNumWideCurrentComponent,
  15953. maxNumHigh: maxNumHighCurrentComponent
  15954. };
  15955. }
  15956. return {
  15957. components: sizePerComponent,
  15958. minWidth: minWidth,
  15959. minHeight: minHeight,
  15960. maxNumWide: maxNumWide,
  15961. maxNumHigh: maxNumHigh
  15962. };
  15963. }
  15964. function buildPackets(context) {
  15965. var siz = context.SIZ;
  15966. var tileIndex = context.currentTile.index;
  15967. var tile = context.tiles[tileIndex];
  15968. var componentsCount = siz.Csiz;
  15969. for (var c = 0; c < componentsCount; c++) {
  15970. var component = tile.components[c];
  15971. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15972. var resolutions = [];
  15973. var subbands = [];
  15974. for (var r = 0; r <= decompositionLevelsCount; r++) {
  15975. var blocksDimensions = getBlocksDimensions(context, component, r);
  15976. var resolution = {};
  15977. var scale = 1 << decompositionLevelsCount - r;
  15978. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  15979. resolution.try0 = Math.ceil(component.tcy0 / scale);
  15980. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  15981. resolution.try1 = Math.ceil(component.tcy1 / scale);
  15982. resolution.resLevel = r;
  15983. buildPrecincts(context, resolution, blocksDimensions);
  15984. resolutions.push(resolution);
  15985. var subband;
  15986. if (r === 0) {
  15987. subband = {};
  15988. subband.type = 'LL';
  15989. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  15990. subband.tby0 = Math.ceil(component.tcy0 / scale);
  15991. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  15992. subband.tby1 = Math.ceil(component.tcy1 / scale);
  15993. subband.resolution = resolution;
  15994. buildCodeblocks(context, subband, blocksDimensions);
  15995. subbands.push(subband);
  15996. resolution.subbands = [subband];
  15997. } else {
  15998. var bscale = 1 << decompositionLevelsCount - r + 1;
  15999. var resolutionSubbands = [];
  16000. subband = {};
  16001. subband.type = 'HL';
  16002. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  16003. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  16004. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  16005. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  16006. subband.resolution = resolution;
  16007. buildCodeblocks(context, subband, blocksDimensions);
  16008. subbands.push(subband);
  16009. resolutionSubbands.push(subband);
  16010. subband = {};
  16011. subband.type = 'LH';
  16012. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  16013. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  16014. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  16015. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  16016. subband.resolution = resolution;
  16017. buildCodeblocks(context, subband, blocksDimensions);
  16018. subbands.push(subband);
  16019. resolutionSubbands.push(subband);
  16020. subband = {};
  16021. subband.type = 'HH';
  16022. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  16023. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  16024. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  16025. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  16026. subband.resolution = resolution;
  16027. buildCodeblocks(context, subband, blocksDimensions);
  16028. subbands.push(subband);
  16029. resolutionSubbands.push(subband);
  16030. resolution.subbands = resolutionSubbands;
  16031. }
  16032. }
  16033. component.resolutions = resolutions;
  16034. component.subbands = subbands;
  16035. }
  16036. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  16037. switch (progressionOrder) {
  16038. case 0:
  16039. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  16040. break;
  16041. case 1:
  16042. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  16043. break;
  16044. case 2:
  16045. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  16046. break;
  16047. case 3:
  16048. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  16049. break;
  16050. case 4:
  16051. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  16052. break;
  16053. default:
  16054. error('JPX Error: Unsupported progression order ' + progressionOrder);
  16055. }
  16056. }
  16057. function parseTilePackets(context, data, offset, dataLength) {
  16058. var position = 0;
  16059. var buffer, bufferSize = 0, skipNextBit = false;
  16060. function readBits(count) {
  16061. while (bufferSize < count) {
  16062. var b = data[offset + position];
  16063. position++;
  16064. if (skipNextBit) {
  16065. buffer = buffer << 7 | b;
  16066. bufferSize += 7;
  16067. skipNextBit = false;
  16068. } else {
  16069. buffer = buffer << 8 | b;
  16070. bufferSize += 8;
  16071. }
  16072. if (b === 0xFF) {
  16073. skipNextBit = true;
  16074. }
  16075. }
  16076. bufferSize -= count;
  16077. return buffer >>> bufferSize & (1 << count) - 1;
  16078. }
  16079. function skipMarkerIfEqual(value) {
  16080. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  16081. skipBytes(1);
  16082. return true;
  16083. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  16084. skipBytes(2);
  16085. return true;
  16086. }
  16087. return false;
  16088. }
  16089. function skipBytes(count) {
  16090. position += count;
  16091. }
  16092. function alignToByte() {
  16093. bufferSize = 0;
  16094. if (skipNextBit) {
  16095. position++;
  16096. skipNextBit = false;
  16097. }
  16098. }
  16099. function readCodingpasses() {
  16100. if (readBits(1) === 0) {
  16101. return 1;
  16102. }
  16103. if (readBits(1) === 0) {
  16104. return 2;
  16105. }
  16106. var value = readBits(2);
  16107. if (value < 3) {
  16108. return value + 3;
  16109. }
  16110. value = readBits(5);
  16111. if (value < 31) {
  16112. return value + 6;
  16113. }
  16114. value = readBits(7);
  16115. return value + 37;
  16116. }
  16117. var tileIndex = context.currentTile.index;
  16118. var tile = context.tiles[tileIndex];
  16119. var sopMarkerUsed = context.COD.sopMarkerUsed;
  16120. var ephMarkerUsed = context.COD.ephMarkerUsed;
  16121. var packetsIterator = tile.packetsIterator;
  16122. while (position < dataLength) {
  16123. alignToByte();
  16124. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  16125. skipBytes(4);
  16126. }
  16127. var packet = packetsIterator.nextPacket();
  16128. if (!readBits(1)) {
  16129. continue;
  16130. }
  16131. var layerNumber = packet.layerNumber;
  16132. var queue = [], codeblock;
  16133. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  16134. codeblock = packet.codeblocks[i];
  16135. var precinct = codeblock.precinct;
  16136. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  16137. var codeblockRow = codeblock.cby - precinct.cbyMin;
  16138. var codeblockIncluded = false;
  16139. var firstTimeInclusion = false;
  16140. var valueReady;
  16141. if (codeblock['included'] !== undefined) {
  16142. codeblockIncluded = !!readBits(1);
  16143. } else {
  16144. precinct = codeblock.precinct;
  16145. var inclusionTree, zeroBitPlanesTree;
  16146. if (precinct['inclusionTree'] !== undefined) {
  16147. inclusionTree = precinct.inclusionTree;
  16148. } else {
  16149. var width = precinct.cbxMax - precinct.cbxMin + 1;
  16150. var height = precinct.cbyMax - precinct.cbyMin + 1;
  16151. inclusionTree = new InclusionTree(width, height, layerNumber);
  16152. zeroBitPlanesTree = new TagTree(width, height);
  16153. precinct.inclusionTree = inclusionTree;
  16154. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  16155. }
  16156. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  16157. while (true) {
  16158. if (readBits(1)) {
  16159. valueReady = !inclusionTree.nextLevel();
  16160. if (valueReady) {
  16161. codeblock.included = true;
  16162. codeblockIncluded = firstTimeInclusion = true;
  16163. break;
  16164. }
  16165. } else {
  16166. inclusionTree.incrementValue(layerNumber);
  16167. break;
  16168. }
  16169. }
  16170. }
  16171. }
  16172. if (!codeblockIncluded) {
  16173. continue;
  16174. }
  16175. if (firstTimeInclusion) {
  16176. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  16177. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  16178. while (true) {
  16179. if (readBits(1)) {
  16180. valueReady = !zeroBitPlanesTree.nextLevel();
  16181. if (valueReady) {
  16182. break;
  16183. }
  16184. } else {
  16185. zeroBitPlanesTree.incrementValue();
  16186. }
  16187. }
  16188. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  16189. }
  16190. var codingpasses = readCodingpasses();
  16191. while (readBits(1)) {
  16192. codeblock.Lblock++;
  16193. }
  16194. var codingpassesLog2 = log2(codingpasses);
  16195. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  16196. var codedDataLength = readBits(bits);
  16197. queue.push({
  16198. codeblock: codeblock,
  16199. codingpasses: codingpasses,
  16200. dataLength: codedDataLength
  16201. });
  16202. }
  16203. alignToByte();
  16204. if (ephMarkerUsed) {
  16205. skipMarkerIfEqual(0x92);
  16206. }
  16207. while (queue.length > 0) {
  16208. var packetItem = queue.shift();
  16209. codeblock = packetItem.codeblock;
  16210. if (codeblock['data'] === undefined) {
  16211. codeblock.data = [];
  16212. }
  16213. codeblock.data.push({
  16214. data: data,
  16215. start: offset + position,
  16216. end: offset + position + packetItem.dataLength,
  16217. codingpasses: packetItem.codingpasses
  16218. });
  16219. position += packetItem.dataLength;
  16220. }
  16221. }
  16222. return position;
  16223. }
  16224. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  16225. var x0 = subband.tbx0;
  16226. var y0 = subband.tby0;
  16227. var width = subband.tbx1 - subband.tbx0;
  16228. var codeblocks = subband.codeblocks;
  16229. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  16230. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  16231. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  16232. var codeblock = codeblocks[i];
  16233. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  16234. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  16235. if (blockWidth === 0 || blockHeight === 0) {
  16236. continue;
  16237. }
  16238. if (codeblock['data'] === undefined) {
  16239. continue;
  16240. }
  16241. var bitModel, currentCodingpassType;
  16242. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  16243. currentCodingpassType = 2;
  16244. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  16245. var j, jj, dataItem;
  16246. for (j = 0, jj = data.length; j < jj; j++) {
  16247. dataItem = data[j];
  16248. totalLength += dataItem.end - dataItem.start;
  16249. codingpasses += dataItem.codingpasses;
  16250. }
  16251. var encodedData = new Uint8Array(totalLength);
  16252. var position = 0;
  16253. for (j = 0, jj = data.length; j < jj; j++) {
  16254. dataItem = data[j];
  16255. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  16256. encodedData.set(chunk, position);
  16257. position += chunk.length;
  16258. }
  16259. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  16260. bitModel.setDecoder(decoder);
  16261. for (j = 0; j < codingpasses; j++) {
  16262. switch (currentCodingpassType) {
  16263. case 0:
  16264. bitModel.runSignificancePropagationPass();
  16265. break;
  16266. case 1:
  16267. bitModel.runMagnitudeRefinementPass();
  16268. break;
  16269. case 2:
  16270. bitModel.runCleanupPass();
  16271. if (segmentationSymbolUsed) {
  16272. bitModel.checkSegmentationSymbol();
  16273. }
  16274. break;
  16275. }
  16276. currentCodingpassType = (currentCodingpassType + 1) % 3;
  16277. }
  16278. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  16279. var sign = bitModel.coefficentsSign;
  16280. var magnitude = bitModel.coefficentsMagnitude;
  16281. var bitsDecoded = bitModel.bitsDecoded;
  16282. var magnitudeCorrection = reversible ? 0 : 0.5;
  16283. var k, n, nb;
  16284. position = 0;
  16285. var interleave = subband.type !== 'LL';
  16286. for (j = 0; j < blockHeight; j++) {
  16287. var row = offset / width | 0;
  16288. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  16289. for (k = 0; k < blockWidth; k++) {
  16290. n = magnitude[position];
  16291. if (n !== 0) {
  16292. n = (n + magnitudeCorrection) * delta;
  16293. if (sign[position] !== 0) {
  16294. n = -n;
  16295. }
  16296. nb = bitsDecoded[position];
  16297. var pos = interleave ? levelOffset + (offset << 1) : offset;
  16298. if (reversible && nb >= mb) {
  16299. coefficients[pos] = n;
  16300. } else {
  16301. coefficients[pos] = n * (1 << mb - nb);
  16302. }
  16303. }
  16304. offset++;
  16305. position++;
  16306. }
  16307. offset += width - blockWidth;
  16308. }
  16309. }
  16310. }
  16311. function transformTile(context, tile, c) {
  16312. var component = tile.components[c];
  16313. var codingStyleParameters = component.codingStyleParameters;
  16314. var quantizationParameters = component.quantizationParameters;
  16315. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  16316. var spqcds = quantizationParameters.SPqcds;
  16317. var scalarExpounded = quantizationParameters.scalarExpounded;
  16318. var guardBits = quantizationParameters.guardBits;
  16319. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  16320. var precision = context.components[c].precision;
  16321. var reversible = codingStyleParameters.reversibleTransformation;
  16322. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  16323. var subbandCoefficients = [];
  16324. var b = 0;
  16325. for (var i = 0; i <= decompositionLevelsCount; i++) {
  16326. var resolution = component.resolutions[i];
  16327. var width = resolution.trx1 - resolution.trx0;
  16328. var height = resolution.try1 - resolution.try0;
  16329. var coefficients = new Float32Array(width * height);
  16330. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  16331. var mu, epsilon;
  16332. if (!scalarExpounded) {
  16333. mu = spqcds[0].mu;
  16334. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  16335. } else {
  16336. mu = spqcds[b].mu;
  16337. epsilon = spqcds[b].epsilon;
  16338. b++;
  16339. }
  16340. var subband = resolution.subbands[j];
  16341. var gainLog2 = SubbandsGainLog2[subband.type];
  16342. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  16343. var mb = guardBits + epsilon - 1;
  16344. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  16345. }
  16346. subbandCoefficients.push({
  16347. width: width,
  16348. height: height,
  16349. items: coefficients
  16350. });
  16351. }
  16352. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  16353. return {
  16354. left: component.tcx0,
  16355. top: component.tcy0,
  16356. width: result.width,
  16357. height: result.height,
  16358. items: result.items
  16359. };
  16360. }
  16361. function transformComponents(context) {
  16362. var siz = context.SIZ;
  16363. var components = context.components;
  16364. var componentsCount = siz.Csiz;
  16365. var resultImages = [];
  16366. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  16367. var tile = context.tiles[i];
  16368. var transformedTiles = [];
  16369. var c;
  16370. for (c = 0; c < componentsCount; c++) {
  16371. transformedTiles[c] = transformTile(context, tile, c);
  16372. }
  16373. var tile0 = transformedTiles[0];
  16374. var out = new Uint8Array(tile0.items.length * componentsCount);
  16375. var result = {
  16376. left: tile0.left,
  16377. top: tile0.top,
  16378. width: tile0.width,
  16379. height: tile0.height,
  16380. items: out
  16381. };
  16382. var shift, offset, max, min, maxK;
  16383. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  16384. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  16385. var fourComponents = componentsCount === 4;
  16386. var y0items = transformedTiles[0].items;
  16387. var y1items = transformedTiles[1].items;
  16388. var y2items = transformedTiles[2].items;
  16389. var y3items = fourComponents ? transformedTiles[3].items : null;
  16390. shift = components[0].precision - 8;
  16391. offset = (128 << shift) + 0.5;
  16392. max = 255 * (1 << shift);
  16393. maxK = max * 0.5;
  16394. min = -maxK;
  16395. var component0 = tile.components[0];
  16396. var alpha01 = componentsCount - 3;
  16397. jj = y0items.length;
  16398. if (!component0.codingStyleParameters.reversibleTransformation) {
  16399. for (j = 0; j < jj; j++, pos += alpha01) {
  16400. y0 = y0items[j] + offset;
  16401. y1 = y1items[j];
  16402. y2 = y2items[j];
  16403. r = y0 + 1.402 * y2;
  16404. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  16405. b = y0 + 1.772 * y1;
  16406. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16407. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16408. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16409. }
  16410. } else {
  16411. for (j = 0; j < jj; j++, pos += alpha01) {
  16412. y0 = y0items[j] + offset;
  16413. y1 = y1items[j];
  16414. y2 = y2items[j];
  16415. g = y0 - (y2 + y1 >> 2);
  16416. r = g + y2;
  16417. b = g + y1;
  16418. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16419. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16420. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16421. }
  16422. }
  16423. if (fourComponents) {
  16424. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  16425. k = y3items[j];
  16426. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  16427. }
  16428. }
  16429. } else {
  16430. for (c = 0; c < componentsCount; c++) {
  16431. var items = transformedTiles[c].items;
  16432. shift = components[c].precision - 8;
  16433. offset = (128 << shift) + 0.5;
  16434. max = 127.5 * (1 << shift);
  16435. min = -max;
  16436. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  16437. val = items[j];
  16438. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  16439. pos += componentsCount;
  16440. }
  16441. }
  16442. }
  16443. resultImages.push(result);
  16444. }
  16445. return resultImages;
  16446. }
  16447. function initializeTile(context, tileIndex) {
  16448. var siz = context.SIZ;
  16449. var componentsCount = siz.Csiz;
  16450. var tile = context.tiles[tileIndex];
  16451. for (var c = 0; c < componentsCount; c++) {
  16452. var component = tile.components[c];
  16453. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  16454. component.quantizationParameters = qcdOrQcc;
  16455. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  16456. component.codingStyleParameters = codOrCoc;
  16457. }
  16458. tile.codingStyleDefaultParameters = context.currentTile.COD;
  16459. }
  16460. var TagTree = function TagTreeClosure() {
  16461. function TagTree(width, height) {
  16462. var levelsLength = log2(Math.max(width, height)) + 1;
  16463. this.levels = [];
  16464. for (var i = 0; i < levelsLength; i++) {
  16465. var level = {
  16466. width: width,
  16467. height: height,
  16468. items: []
  16469. };
  16470. this.levels.push(level);
  16471. width = Math.ceil(width / 2);
  16472. height = Math.ceil(height / 2);
  16473. }
  16474. }
  16475. TagTree.prototype = {
  16476. reset: function TagTree_reset(i, j) {
  16477. var currentLevel = 0, value = 0, level;
  16478. while (currentLevel < this.levels.length) {
  16479. level = this.levels[currentLevel];
  16480. var index = i + j * level.width;
  16481. if (level.items[index] !== undefined) {
  16482. value = level.items[index];
  16483. break;
  16484. }
  16485. level.index = index;
  16486. i >>= 1;
  16487. j >>= 1;
  16488. currentLevel++;
  16489. }
  16490. currentLevel--;
  16491. level = this.levels[currentLevel];
  16492. level.items[level.index] = value;
  16493. this.currentLevel = currentLevel;
  16494. delete this.value;
  16495. },
  16496. incrementValue: function TagTree_incrementValue() {
  16497. var level = this.levels[this.currentLevel];
  16498. level.items[level.index]++;
  16499. },
  16500. nextLevel: function TagTree_nextLevel() {
  16501. var currentLevel = this.currentLevel;
  16502. var level = this.levels[currentLevel];
  16503. var value = level.items[level.index];
  16504. currentLevel--;
  16505. if (currentLevel < 0) {
  16506. this.value = value;
  16507. return false;
  16508. }
  16509. this.currentLevel = currentLevel;
  16510. level = this.levels[currentLevel];
  16511. level.items[level.index] = value;
  16512. return true;
  16513. }
  16514. };
  16515. return TagTree;
  16516. }();
  16517. var InclusionTree = function InclusionTreeClosure() {
  16518. function InclusionTree(width, height, defaultValue) {
  16519. var levelsLength = log2(Math.max(width, height)) + 1;
  16520. this.levels = [];
  16521. for (var i = 0; i < levelsLength; i++) {
  16522. var items = new Uint8Array(width * height);
  16523. for (var j = 0, jj = items.length; j < jj; j++) {
  16524. items[j] = defaultValue;
  16525. }
  16526. var level = {
  16527. width: width,
  16528. height: height,
  16529. items: items
  16530. };
  16531. this.levels.push(level);
  16532. width = Math.ceil(width / 2);
  16533. height = Math.ceil(height / 2);
  16534. }
  16535. }
  16536. InclusionTree.prototype = {
  16537. reset: function InclusionTree_reset(i, j, stopValue) {
  16538. var currentLevel = 0;
  16539. while (currentLevel < this.levels.length) {
  16540. var level = this.levels[currentLevel];
  16541. var index = i + j * level.width;
  16542. level.index = index;
  16543. var value = level.items[index];
  16544. if (value === 0xFF) {
  16545. break;
  16546. }
  16547. if (value > stopValue) {
  16548. this.currentLevel = currentLevel;
  16549. this.propagateValues();
  16550. return false;
  16551. }
  16552. i >>= 1;
  16553. j >>= 1;
  16554. currentLevel++;
  16555. }
  16556. this.currentLevel = currentLevel - 1;
  16557. return true;
  16558. },
  16559. incrementValue: function InclusionTree_incrementValue(stopValue) {
  16560. var level = this.levels[this.currentLevel];
  16561. level.items[level.index] = stopValue + 1;
  16562. this.propagateValues();
  16563. },
  16564. propagateValues: function InclusionTree_propagateValues() {
  16565. var levelIndex = this.currentLevel;
  16566. var level = this.levels[levelIndex];
  16567. var currentValue = level.items[level.index];
  16568. while (--levelIndex >= 0) {
  16569. level = this.levels[levelIndex];
  16570. level.items[level.index] = currentValue;
  16571. }
  16572. },
  16573. nextLevel: function InclusionTree_nextLevel() {
  16574. var currentLevel = this.currentLevel;
  16575. var level = this.levels[currentLevel];
  16576. var value = level.items[level.index];
  16577. level.items[level.index] = 0xFF;
  16578. currentLevel--;
  16579. if (currentLevel < 0) {
  16580. return false;
  16581. }
  16582. this.currentLevel = currentLevel;
  16583. level = this.levels[currentLevel];
  16584. level.items[level.index] = value;
  16585. return true;
  16586. }
  16587. };
  16588. return InclusionTree;
  16589. }();
  16590. var BitModel = function BitModelClosure() {
  16591. var UNIFORM_CONTEXT = 17;
  16592. var RUNLENGTH_CONTEXT = 18;
  16593. var LLAndLHContextsLabel = new Uint8Array([
  16594. 0,
  16595. 5,
  16596. 8,
  16597. 0,
  16598. 3,
  16599. 7,
  16600. 8,
  16601. 0,
  16602. 4,
  16603. 7,
  16604. 8,
  16605. 0,
  16606. 0,
  16607. 0,
  16608. 0,
  16609. 0,
  16610. 1,
  16611. 6,
  16612. 8,
  16613. 0,
  16614. 3,
  16615. 7,
  16616. 8,
  16617. 0,
  16618. 4,
  16619. 7,
  16620. 8,
  16621. 0,
  16622. 0,
  16623. 0,
  16624. 0,
  16625. 0,
  16626. 2,
  16627. 6,
  16628. 8,
  16629. 0,
  16630. 3,
  16631. 7,
  16632. 8,
  16633. 0,
  16634. 4,
  16635. 7,
  16636. 8,
  16637. 0,
  16638. 0,
  16639. 0,
  16640. 0,
  16641. 0,
  16642. 2,
  16643. 6,
  16644. 8,
  16645. 0,
  16646. 3,
  16647. 7,
  16648. 8,
  16649. 0,
  16650. 4,
  16651. 7,
  16652. 8,
  16653. 0,
  16654. 0,
  16655. 0,
  16656. 0,
  16657. 0,
  16658. 2,
  16659. 6,
  16660. 8,
  16661. 0,
  16662. 3,
  16663. 7,
  16664. 8,
  16665. 0,
  16666. 4,
  16667. 7,
  16668. 8
  16669. ]);
  16670. var HLContextLabel = new Uint8Array([
  16671. 0,
  16672. 3,
  16673. 4,
  16674. 0,
  16675. 5,
  16676. 7,
  16677. 7,
  16678. 0,
  16679. 8,
  16680. 8,
  16681. 8,
  16682. 0,
  16683. 0,
  16684. 0,
  16685. 0,
  16686. 0,
  16687. 1,
  16688. 3,
  16689. 4,
  16690. 0,
  16691. 6,
  16692. 7,
  16693. 7,
  16694. 0,
  16695. 8,
  16696. 8,
  16697. 8,
  16698. 0,
  16699. 0,
  16700. 0,
  16701. 0,
  16702. 0,
  16703. 2,
  16704. 3,
  16705. 4,
  16706. 0,
  16707. 6,
  16708. 7,
  16709. 7,
  16710. 0,
  16711. 8,
  16712. 8,
  16713. 8,
  16714. 0,
  16715. 0,
  16716. 0,
  16717. 0,
  16718. 0,
  16719. 2,
  16720. 3,
  16721. 4,
  16722. 0,
  16723. 6,
  16724. 7,
  16725. 7,
  16726. 0,
  16727. 8,
  16728. 8,
  16729. 8,
  16730. 0,
  16731. 0,
  16732. 0,
  16733. 0,
  16734. 0,
  16735. 2,
  16736. 3,
  16737. 4,
  16738. 0,
  16739. 6,
  16740. 7,
  16741. 7,
  16742. 0,
  16743. 8,
  16744. 8,
  16745. 8
  16746. ]);
  16747. var HHContextLabel = new Uint8Array([
  16748. 0,
  16749. 1,
  16750. 2,
  16751. 0,
  16752. 1,
  16753. 2,
  16754. 2,
  16755. 0,
  16756. 2,
  16757. 2,
  16758. 2,
  16759. 0,
  16760. 0,
  16761. 0,
  16762. 0,
  16763. 0,
  16764. 3,
  16765. 4,
  16766. 5,
  16767. 0,
  16768. 4,
  16769. 5,
  16770. 5,
  16771. 0,
  16772. 5,
  16773. 5,
  16774. 5,
  16775. 0,
  16776. 0,
  16777. 0,
  16778. 0,
  16779. 0,
  16780. 6,
  16781. 7,
  16782. 7,
  16783. 0,
  16784. 7,
  16785. 7,
  16786. 7,
  16787. 0,
  16788. 7,
  16789. 7,
  16790. 7,
  16791. 0,
  16792. 0,
  16793. 0,
  16794. 0,
  16795. 0,
  16796. 8,
  16797. 8,
  16798. 8,
  16799. 0,
  16800. 8,
  16801. 8,
  16802. 8,
  16803. 0,
  16804. 8,
  16805. 8,
  16806. 8,
  16807. 0,
  16808. 0,
  16809. 0,
  16810. 0,
  16811. 0,
  16812. 8,
  16813. 8,
  16814. 8,
  16815. 0,
  16816. 8,
  16817. 8,
  16818. 8,
  16819. 0,
  16820. 8,
  16821. 8,
  16822. 8
  16823. ]);
  16824. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  16825. this.width = width;
  16826. this.height = height;
  16827. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  16828. var coefficientCount = width * height;
  16829. this.neighborsSignificance = new Uint8Array(coefficientCount);
  16830. this.coefficentsSign = new Uint8Array(coefficientCount);
  16831. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  16832. this.processingFlags = new Uint8Array(coefficientCount);
  16833. var bitsDecoded = new Uint8Array(coefficientCount);
  16834. if (zeroBitPlanes !== 0) {
  16835. for (var i = 0; i < coefficientCount; i++) {
  16836. bitsDecoded[i] = zeroBitPlanes;
  16837. }
  16838. }
  16839. this.bitsDecoded = bitsDecoded;
  16840. this.reset();
  16841. }
  16842. BitModel.prototype = {
  16843. setDecoder: function BitModel_setDecoder(decoder) {
  16844. this.decoder = decoder;
  16845. },
  16846. reset: function BitModel_reset() {
  16847. this.contexts = new Int8Array(19);
  16848. this.contexts[0] = 4 << 1 | 0;
  16849. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  16850. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  16851. },
  16852. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  16853. var neighborsSignificance = this.neighborsSignificance;
  16854. var width = this.width, height = this.height;
  16855. var left = column > 0;
  16856. var right = column + 1 < width;
  16857. var i;
  16858. if (row > 0) {
  16859. i = index - width;
  16860. if (left) {
  16861. neighborsSignificance[i - 1] += 0x10;
  16862. }
  16863. if (right) {
  16864. neighborsSignificance[i + 1] += 0x10;
  16865. }
  16866. neighborsSignificance[i] += 0x04;
  16867. }
  16868. if (row + 1 < height) {
  16869. i = index + width;
  16870. if (left) {
  16871. neighborsSignificance[i - 1] += 0x10;
  16872. }
  16873. if (right) {
  16874. neighborsSignificance[i + 1] += 0x10;
  16875. }
  16876. neighborsSignificance[i] += 0x04;
  16877. }
  16878. if (left) {
  16879. neighborsSignificance[index - 1] += 0x01;
  16880. }
  16881. if (right) {
  16882. neighborsSignificance[index + 1] += 0x01;
  16883. }
  16884. neighborsSignificance[index] |= 0x80;
  16885. },
  16886. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  16887. var decoder = this.decoder;
  16888. var width = this.width, height = this.height;
  16889. var coefficentsMagnitude = this.coefficentsMagnitude;
  16890. var coefficentsSign = this.coefficentsSign;
  16891. var neighborsSignificance = this.neighborsSignificance;
  16892. var processingFlags = this.processingFlags;
  16893. var contexts = this.contexts;
  16894. var labels = this.contextLabelTable;
  16895. var bitsDecoded = this.bitsDecoded;
  16896. var processedInverseMask = ~1;
  16897. var processedMask = 1;
  16898. var firstMagnitudeBitMask = 2;
  16899. for (var i0 = 0; i0 < height; i0 += 4) {
  16900. for (var j = 0; j < width; j++) {
  16901. var index = i0 * width + j;
  16902. for (var i1 = 0; i1 < 4; i1++, index += width) {
  16903. var i = i0 + i1;
  16904. if (i >= height) {
  16905. break;
  16906. }
  16907. processingFlags[index] &= processedInverseMask;
  16908. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  16909. continue;
  16910. }
  16911. var contextLabel = labels[neighborsSignificance[index]];
  16912. var decision = decoder.readBit(contexts, contextLabel);
  16913. if (decision) {
  16914. var sign = this.decodeSignBit(i, j, index);
  16915. coefficentsSign[index] = sign;
  16916. coefficentsMagnitude[index] = 1;
  16917. this.setNeighborsSignificance(i, j, index);
  16918. processingFlags[index] |= firstMagnitudeBitMask;
  16919. }
  16920. bitsDecoded[index]++;
  16921. processingFlags[index] |= processedMask;
  16922. }
  16923. }
  16924. }
  16925. },
  16926. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  16927. var width = this.width, height = this.height;
  16928. var coefficentsMagnitude = this.coefficentsMagnitude;
  16929. var coefficentsSign = this.coefficentsSign;
  16930. var contribution, sign0, sign1, significance1;
  16931. var contextLabel, decoded;
  16932. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  16933. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  16934. sign1 = coefficentsSign[index + 1];
  16935. if (significance1) {
  16936. sign0 = coefficentsSign[index - 1];
  16937. contribution = 1 - sign1 - sign0;
  16938. } else {
  16939. contribution = 1 - sign1 - sign1;
  16940. }
  16941. } else if (significance1) {
  16942. sign0 = coefficentsSign[index - 1];
  16943. contribution = 1 - sign0 - sign0;
  16944. } else {
  16945. contribution = 0;
  16946. }
  16947. var horizontalContribution = 3 * contribution;
  16948. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  16949. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  16950. sign1 = coefficentsSign[index + width];
  16951. if (significance1) {
  16952. sign0 = coefficentsSign[index - width];
  16953. contribution = 1 - sign1 - sign0 + horizontalContribution;
  16954. } else {
  16955. contribution = 1 - sign1 - sign1 + horizontalContribution;
  16956. }
  16957. } else if (significance1) {
  16958. sign0 = coefficentsSign[index - width];
  16959. contribution = 1 - sign0 - sign0 + horizontalContribution;
  16960. } else {
  16961. contribution = horizontalContribution;
  16962. }
  16963. if (contribution >= 0) {
  16964. contextLabel = 9 + contribution;
  16965. decoded = this.decoder.readBit(this.contexts, contextLabel);
  16966. } else {
  16967. contextLabel = 9 - contribution;
  16968. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  16969. }
  16970. return decoded;
  16971. },
  16972. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  16973. var decoder = this.decoder;
  16974. var width = this.width, height = this.height;
  16975. var coefficentsMagnitude = this.coefficentsMagnitude;
  16976. var neighborsSignificance = this.neighborsSignificance;
  16977. var contexts = this.contexts;
  16978. var bitsDecoded = this.bitsDecoded;
  16979. var processingFlags = this.processingFlags;
  16980. var processedMask = 1;
  16981. var firstMagnitudeBitMask = 2;
  16982. var length = width * height;
  16983. var width4 = width * 4;
  16984. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  16985. indexNext = Math.min(length, index0 + width4);
  16986. for (var j = 0; j < width; j++) {
  16987. for (var index = index0 + j; index < indexNext; index += width) {
  16988. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16989. continue;
  16990. }
  16991. var contextLabel = 16;
  16992. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  16993. processingFlags[index] ^= firstMagnitudeBitMask;
  16994. var significance = neighborsSignificance[index] & 127;
  16995. contextLabel = significance === 0 ? 15 : 14;
  16996. }
  16997. var bit = decoder.readBit(contexts, contextLabel);
  16998. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  16999. bitsDecoded[index]++;
  17000. processingFlags[index] |= processedMask;
  17001. }
  17002. }
  17003. }
  17004. },
  17005. runCleanupPass: function BitModel_runCleanupPass() {
  17006. var decoder = this.decoder;
  17007. var width = this.width, height = this.height;
  17008. var neighborsSignificance = this.neighborsSignificance;
  17009. var coefficentsMagnitude = this.coefficentsMagnitude;
  17010. var coefficentsSign = this.coefficentsSign;
  17011. var contexts = this.contexts;
  17012. var labels = this.contextLabelTable;
  17013. var bitsDecoded = this.bitsDecoded;
  17014. var processingFlags = this.processingFlags;
  17015. var processedMask = 1;
  17016. var firstMagnitudeBitMask = 2;
  17017. var oneRowDown = width;
  17018. var twoRowsDown = width * 2;
  17019. var threeRowsDown = width * 3;
  17020. var iNext;
  17021. for (var i0 = 0; i0 < height; i0 = iNext) {
  17022. iNext = Math.min(i0 + 4, height);
  17023. var indexBase = i0 * width;
  17024. var checkAllEmpty = i0 + 3 < height;
  17025. for (var j = 0; j < width; j++) {
  17026. var index0 = indexBase + j;
  17027. 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;
  17028. var i1 = 0, index = index0;
  17029. var i = i0, sign;
  17030. if (allEmpty) {
  17031. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  17032. if (!hasSignificantCoefficent) {
  17033. bitsDecoded[index0]++;
  17034. bitsDecoded[index0 + oneRowDown]++;
  17035. bitsDecoded[index0 + twoRowsDown]++;
  17036. bitsDecoded[index0 + threeRowsDown]++;
  17037. continue;
  17038. }
  17039. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  17040. if (i1 !== 0) {
  17041. i = i0 + i1;
  17042. index += i1 * width;
  17043. }
  17044. sign = this.decodeSignBit(i, j, index);
  17045. coefficentsSign[index] = sign;
  17046. coefficentsMagnitude[index] = 1;
  17047. this.setNeighborsSignificance(i, j, index);
  17048. processingFlags[index] |= firstMagnitudeBitMask;
  17049. index = index0;
  17050. for (var i2 = i0; i2 <= i; i2++, index += width) {
  17051. bitsDecoded[index]++;
  17052. }
  17053. i1++;
  17054. }
  17055. for (i = i0 + i1; i < iNext; i++, index += width) {
  17056. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  17057. continue;
  17058. }
  17059. var contextLabel = labels[neighborsSignificance[index]];
  17060. var decision = decoder.readBit(contexts, contextLabel);
  17061. if (decision === 1) {
  17062. sign = this.decodeSignBit(i, j, index);
  17063. coefficentsSign[index] = sign;
  17064. coefficentsMagnitude[index] = 1;
  17065. this.setNeighborsSignificance(i, j, index);
  17066. processingFlags[index] |= firstMagnitudeBitMask;
  17067. }
  17068. bitsDecoded[index]++;
  17069. }
  17070. }
  17071. }
  17072. },
  17073. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  17074. var decoder = this.decoder;
  17075. var contexts = this.contexts;
  17076. 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);
  17077. if (symbol !== 0xA) {
  17078. error('JPX Error: Invalid segmentation symbol');
  17079. }
  17080. }
  17081. };
  17082. return BitModel;
  17083. }();
  17084. var Transform = function TransformClosure() {
  17085. function Transform() {
  17086. }
  17087. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  17088. var ll = subbands[0];
  17089. for (var i = 1, ii = subbands.length; i < ii; i++) {
  17090. ll = this.iterate(ll, subbands[i], u0, v0);
  17091. }
  17092. return ll;
  17093. };
  17094. Transform.prototype.extend = function extend(buffer, offset, size) {
  17095. var i1 = offset - 1, j1 = offset + 1;
  17096. var i2 = offset + size - 2, j2 = offset + size;
  17097. buffer[i1--] = buffer[j1++];
  17098. buffer[j2++] = buffer[i2--];
  17099. buffer[i1--] = buffer[j1++];
  17100. buffer[j2++] = buffer[i2--];
  17101. buffer[i1--] = buffer[j1++];
  17102. buffer[j2++] = buffer[i2--];
  17103. buffer[i1] = buffer[j1];
  17104. buffer[j2] = buffer[i2];
  17105. };
  17106. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  17107. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  17108. var width = hl_lh_hh.width;
  17109. var height = hl_lh_hh.height;
  17110. var items = hl_lh_hh.items;
  17111. var i, j, k, l, u, v;
  17112. for (k = 0, i = 0; i < llHeight; i++) {
  17113. l = i * 2 * width;
  17114. for (j = 0; j < llWidth; j++, k++, l += 2) {
  17115. items[l] = llItems[k];
  17116. }
  17117. }
  17118. llItems = ll.items = null;
  17119. var bufferPadding = 4;
  17120. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  17121. if (width === 1) {
  17122. if ((u0 & 1) !== 0) {
  17123. for (v = 0, k = 0; v < height; v++, k += width) {
  17124. items[k] *= 0.5;
  17125. }
  17126. }
  17127. } else {
  17128. for (v = 0, k = 0; v < height; v++, k += width) {
  17129. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  17130. this.extend(rowBuffer, bufferPadding, width);
  17131. this.filter(rowBuffer, bufferPadding, width);
  17132. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  17133. }
  17134. }
  17135. var numBuffers = 16;
  17136. var colBuffers = [];
  17137. for (i = 0; i < numBuffers; i++) {
  17138. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  17139. }
  17140. var b, currentBuffer = 0;
  17141. ll = bufferPadding + height;
  17142. if (height === 1) {
  17143. if ((v0 & 1) !== 0) {
  17144. for (u = 0; u < width; u++) {
  17145. items[u] *= 0.5;
  17146. }
  17147. }
  17148. } else {
  17149. for (u = 0; u < width; u++) {
  17150. if (currentBuffer === 0) {
  17151. numBuffers = Math.min(width - u, numBuffers);
  17152. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  17153. for (b = 0; b < numBuffers; b++) {
  17154. colBuffers[b][l] = items[k + b];
  17155. }
  17156. }
  17157. currentBuffer = numBuffers;
  17158. }
  17159. currentBuffer--;
  17160. var buffer = colBuffers[currentBuffer];
  17161. this.extend(buffer, bufferPadding, height);
  17162. this.filter(buffer, bufferPadding, height);
  17163. if (currentBuffer === 0) {
  17164. k = u - numBuffers + 1;
  17165. for (l = bufferPadding; l < ll; k += width, l++) {
  17166. for (b = 0; b < numBuffers; b++) {
  17167. items[k + b] = colBuffers[b][l];
  17168. }
  17169. }
  17170. }
  17171. }
  17172. }
  17173. return {
  17174. width: width,
  17175. height: height,
  17176. items: items
  17177. };
  17178. };
  17179. return Transform;
  17180. }();
  17181. var IrreversibleTransform = function IrreversibleTransformClosure() {
  17182. function IrreversibleTransform() {
  17183. Transform.call(this);
  17184. }
  17185. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  17186. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  17187. var len = length >> 1;
  17188. offset = offset | 0;
  17189. var j, n, current, next;
  17190. var alpha = -1.586134342059924;
  17191. var beta = -0.052980118572961;
  17192. var gamma = 0.882911075530934;
  17193. var delta = 0.443506852043971;
  17194. var K = 1.230174104914001;
  17195. var K_ = 1 / K;
  17196. j = offset - 3;
  17197. for (n = len + 4; n--; j += 2) {
  17198. x[j] *= K_;
  17199. }
  17200. j = offset - 2;
  17201. current = delta * x[j - 1];
  17202. for (n = len + 3; n--; j += 2) {
  17203. next = delta * x[j + 1];
  17204. x[j] = K * x[j] - current - next;
  17205. if (n--) {
  17206. j += 2;
  17207. current = delta * x[j + 1];
  17208. x[j] = K * x[j] - current - next;
  17209. } else {
  17210. break;
  17211. }
  17212. }
  17213. j = offset - 1;
  17214. current = gamma * x[j - 1];
  17215. for (n = len + 2; n--; j += 2) {
  17216. next = gamma * x[j + 1];
  17217. x[j] -= current + next;
  17218. if (n--) {
  17219. j += 2;
  17220. current = gamma * x[j + 1];
  17221. x[j] -= current + next;
  17222. } else {
  17223. break;
  17224. }
  17225. }
  17226. j = offset;
  17227. current = beta * x[j - 1];
  17228. for (n = len + 1; n--; j += 2) {
  17229. next = beta * x[j + 1];
  17230. x[j] -= current + next;
  17231. if (n--) {
  17232. j += 2;
  17233. current = beta * x[j + 1];
  17234. x[j] -= current + next;
  17235. } else {
  17236. break;
  17237. }
  17238. }
  17239. if (len !== 0) {
  17240. j = offset + 1;
  17241. current = alpha * x[j - 1];
  17242. for (n = len; n--; j += 2) {
  17243. next = alpha * x[j + 1];
  17244. x[j] -= current + next;
  17245. if (n--) {
  17246. j += 2;
  17247. current = alpha * x[j + 1];
  17248. x[j] -= current + next;
  17249. } else {
  17250. break;
  17251. }
  17252. }
  17253. }
  17254. };
  17255. return IrreversibleTransform;
  17256. }();
  17257. var ReversibleTransform = function ReversibleTransformClosure() {
  17258. function ReversibleTransform() {
  17259. Transform.call(this);
  17260. }
  17261. ReversibleTransform.prototype = Object.create(Transform.prototype);
  17262. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  17263. var len = length >> 1;
  17264. offset = offset | 0;
  17265. var j, n;
  17266. for (j = offset, n = len + 1; n--; j += 2) {
  17267. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  17268. }
  17269. for (j = offset + 1, n = len; n--; j += 2) {
  17270. x[j] += x[j - 1] + x[j + 1] >> 1;
  17271. }
  17272. };
  17273. return ReversibleTransform;
  17274. }();
  17275. return JpxImage;
  17276. }();
  17277. exports.JpxImage = JpxImage;
  17278. }));
  17279. (function (root, factory) {
  17280. factory(root.pdfjsCoreMetrics = {}, root.pdfjsSharedUtil);
  17281. }(this, function (exports, sharedUtil) {
  17282. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  17283. var getMetrics = getLookupTableFactory(function (t) {
  17284. t['Courier'] = 600;
  17285. t['Courier-Bold'] = 600;
  17286. t['Courier-BoldOblique'] = 600;
  17287. t['Courier-Oblique'] = 600;
  17288. t['Helvetica'] = getLookupTableFactory(function (t) {
  17289. t['space'] = 278;
  17290. t['exclam'] = 278;
  17291. t['quotedbl'] = 355;
  17292. t['numbersign'] = 556;
  17293. t['dollar'] = 556;
  17294. t['percent'] = 889;
  17295. t['ampersand'] = 667;
  17296. t['quoteright'] = 222;
  17297. t['parenleft'] = 333;
  17298. t['parenright'] = 333;
  17299. t['asterisk'] = 389;
  17300. t['plus'] = 584;
  17301. t['comma'] = 278;
  17302. t['hyphen'] = 333;
  17303. t['period'] = 278;
  17304. t['slash'] = 278;
  17305. t['zero'] = 556;
  17306. t['one'] = 556;
  17307. t['two'] = 556;
  17308. t['three'] = 556;
  17309. t['four'] = 556;
  17310. t['five'] = 556;
  17311. t['six'] = 556;
  17312. t['seven'] = 556;
  17313. t['eight'] = 556;
  17314. t['nine'] = 556;
  17315. t['colon'] = 278;
  17316. t['semicolon'] = 278;
  17317. t['less'] = 584;
  17318. t['equal'] = 584;
  17319. t['greater'] = 584;
  17320. t['question'] = 556;
  17321. t['at'] = 1015;
  17322. t['A'] = 667;
  17323. t['B'] = 667;
  17324. t['C'] = 722;
  17325. t['D'] = 722;
  17326. t['E'] = 667;
  17327. t['F'] = 611;
  17328. t['G'] = 778;
  17329. t['H'] = 722;
  17330. t['I'] = 278;
  17331. t['J'] = 500;
  17332. t['K'] = 667;
  17333. t['L'] = 556;
  17334. t['M'] = 833;
  17335. t['N'] = 722;
  17336. t['O'] = 778;
  17337. t['P'] = 667;
  17338. t['Q'] = 778;
  17339. t['R'] = 722;
  17340. t['S'] = 667;
  17341. t['T'] = 611;
  17342. t['U'] = 722;
  17343. t['V'] = 667;
  17344. t['W'] = 944;
  17345. t['X'] = 667;
  17346. t['Y'] = 667;
  17347. t['Z'] = 611;
  17348. t['bracketleft'] = 278;
  17349. t['backslash'] = 278;
  17350. t['bracketright'] = 278;
  17351. t['asciicircum'] = 469;
  17352. t['underscore'] = 556;
  17353. t['quoteleft'] = 222;
  17354. t['a'] = 556;
  17355. t['b'] = 556;
  17356. t['c'] = 500;
  17357. t['d'] = 556;
  17358. t['e'] = 556;
  17359. t['f'] = 278;
  17360. t['g'] = 556;
  17361. t['h'] = 556;
  17362. t['i'] = 222;
  17363. t['j'] = 222;
  17364. t['k'] = 500;
  17365. t['l'] = 222;
  17366. t['m'] = 833;
  17367. t['n'] = 556;
  17368. t['o'] = 556;
  17369. t['p'] = 556;
  17370. t['q'] = 556;
  17371. t['r'] = 333;
  17372. t['s'] = 500;
  17373. t['t'] = 278;
  17374. t['u'] = 556;
  17375. t['v'] = 500;
  17376. t['w'] = 722;
  17377. t['x'] = 500;
  17378. t['y'] = 500;
  17379. t['z'] = 500;
  17380. t['braceleft'] = 334;
  17381. t['bar'] = 260;
  17382. t['braceright'] = 334;
  17383. t['asciitilde'] = 584;
  17384. t['exclamdown'] = 333;
  17385. t['cent'] = 556;
  17386. t['sterling'] = 556;
  17387. t['fraction'] = 167;
  17388. t['yen'] = 556;
  17389. t['florin'] = 556;
  17390. t['section'] = 556;
  17391. t['currency'] = 556;
  17392. t['quotesingle'] = 191;
  17393. t['quotedblleft'] = 333;
  17394. t['guillemotleft'] = 556;
  17395. t['guilsinglleft'] = 333;
  17396. t['guilsinglright'] = 333;
  17397. t['fi'] = 500;
  17398. t['fl'] = 500;
  17399. t['endash'] = 556;
  17400. t['dagger'] = 556;
  17401. t['daggerdbl'] = 556;
  17402. t['periodcentered'] = 278;
  17403. t['paragraph'] = 537;
  17404. t['bullet'] = 350;
  17405. t['quotesinglbase'] = 222;
  17406. t['quotedblbase'] = 333;
  17407. t['quotedblright'] = 333;
  17408. t['guillemotright'] = 556;
  17409. t['ellipsis'] = 1000;
  17410. t['perthousand'] = 1000;
  17411. t['questiondown'] = 611;
  17412. t['grave'] = 333;
  17413. t['acute'] = 333;
  17414. t['circumflex'] = 333;
  17415. t['tilde'] = 333;
  17416. t['macron'] = 333;
  17417. t['breve'] = 333;
  17418. t['dotaccent'] = 333;
  17419. t['dieresis'] = 333;
  17420. t['ring'] = 333;
  17421. t['cedilla'] = 333;
  17422. t['hungarumlaut'] = 333;
  17423. t['ogonek'] = 333;
  17424. t['caron'] = 333;
  17425. t['emdash'] = 1000;
  17426. t['AE'] = 1000;
  17427. t['ordfeminine'] = 370;
  17428. t['Lslash'] = 556;
  17429. t['Oslash'] = 778;
  17430. t['OE'] = 1000;
  17431. t['ordmasculine'] = 365;
  17432. t['ae'] = 889;
  17433. t['dotlessi'] = 278;
  17434. t['lslash'] = 222;
  17435. t['oslash'] = 611;
  17436. t['oe'] = 944;
  17437. t['germandbls'] = 611;
  17438. t['Idieresis'] = 278;
  17439. t['eacute'] = 556;
  17440. t['abreve'] = 556;
  17441. t['uhungarumlaut'] = 556;
  17442. t['ecaron'] = 556;
  17443. t['Ydieresis'] = 667;
  17444. t['divide'] = 584;
  17445. t['Yacute'] = 667;
  17446. t['Acircumflex'] = 667;
  17447. t['aacute'] = 556;
  17448. t['Ucircumflex'] = 722;
  17449. t['yacute'] = 500;
  17450. t['scommaaccent'] = 500;
  17451. t['ecircumflex'] = 556;
  17452. t['Uring'] = 722;
  17453. t['Udieresis'] = 722;
  17454. t['aogonek'] = 556;
  17455. t['Uacute'] = 722;
  17456. t['uogonek'] = 556;
  17457. t['Edieresis'] = 667;
  17458. t['Dcroat'] = 722;
  17459. t['commaaccent'] = 250;
  17460. t['copyright'] = 737;
  17461. t['Emacron'] = 667;
  17462. t['ccaron'] = 500;
  17463. t['aring'] = 556;
  17464. t['Ncommaaccent'] = 722;
  17465. t['lacute'] = 222;
  17466. t['agrave'] = 556;
  17467. t['Tcommaaccent'] = 611;
  17468. t['Cacute'] = 722;
  17469. t['atilde'] = 556;
  17470. t['Edotaccent'] = 667;
  17471. t['scaron'] = 500;
  17472. t['scedilla'] = 500;
  17473. t['iacute'] = 278;
  17474. t['lozenge'] = 471;
  17475. t['Rcaron'] = 722;
  17476. t['Gcommaaccent'] = 778;
  17477. t['ucircumflex'] = 556;
  17478. t['acircumflex'] = 556;
  17479. t['Amacron'] = 667;
  17480. t['rcaron'] = 333;
  17481. t['ccedilla'] = 500;
  17482. t['Zdotaccent'] = 611;
  17483. t['Thorn'] = 667;
  17484. t['Omacron'] = 778;
  17485. t['Racute'] = 722;
  17486. t['Sacute'] = 667;
  17487. t['dcaron'] = 643;
  17488. t['Umacron'] = 722;
  17489. t['uring'] = 556;
  17490. t['threesuperior'] = 333;
  17491. t['Ograve'] = 778;
  17492. t['Agrave'] = 667;
  17493. t['Abreve'] = 667;
  17494. t['multiply'] = 584;
  17495. t['uacute'] = 556;
  17496. t['Tcaron'] = 611;
  17497. t['partialdiff'] = 476;
  17498. t['ydieresis'] = 500;
  17499. t['Nacute'] = 722;
  17500. t['icircumflex'] = 278;
  17501. t['Ecircumflex'] = 667;
  17502. t['adieresis'] = 556;
  17503. t['edieresis'] = 556;
  17504. t['cacute'] = 500;
  17505. t['nacute'] = 556;
  17506. t['umacron'] = 556;
  17507. t['Ncaron'] = 722;
  17508. t['Iacute'] = 278;
  17509. t['plusminus'] = 584;
  17510. t['brokenbar'] = 260;
  17511. t['registered'] = 737;
  17512. t['Gbreve'] = 778;
  17513. t['Idotaccent'] = 278;
  17514. t['summation'] = 600;
  17515. t['Egrave'] = 667;
  17516. t['racute'] = 333;
  17517. t['omacron'] = 556;
  17518. t['Zacute'] = 611;
  17519. t['Zcaron'] = 611;
  17520. t['greaterequal'] = 549;
  17521. t['Eth'] = 722;
  17522. t['Ccedilla'] = 722;
  17523. t['lcommaaccent'] = 222;
  17524. t['tcaron'] = 317;
  17525. t['eogonek'] = 556;
  17526. t['Uogonek'] = 722;
  17527. t['Aacute'] = 667;
  17528. t['Adieresis'] = 667;
  17529. t['egrave'] = 556;
  17530. t['zacute'] = 500;
  17531. t['iogonek'] = 222;
  17532. t['Oacute'] = 778;
  17533. t['oacute'] = 556;
  17534. t['amacron'] = 556;
  17535. t['sacute'] = 500;
  17536. t['idieresis'] = 278;
  17537. t['Ocircumflex'] = 778;
  17538. t['Ugrave'] = 722;
  17539. t['Delta'] = 612;
  17540. t['thorn'] = 556;
  17541. t['twosuperior'] = 333;
  17542. t['Odieresis'] = 778;
  17543. t['mu'] = 556;
  17544. t['igrave'] = 278;
  17545. t['ohungarumlaut'] = 556;
  17546. t['Eogonek'] = 667;
  17547. t['dcroat'] = 556;
  17548. t['threequarters'] = 834;
  17549. t['Scedilla'] = 667;
  17550. t['lcaron'] = 299;
  17551. t['Kcommaaccent'] = 667;
  17552. t['Lacute'] = 556;
  17553. t['trademark'] = 1000;
  17554. t['edotaccent'] = 556;
  17555. t['Igrave'] = 278;
  17556. t['Imacron'] = 278;
  17557. t['Lcaron'] = 556;
  17558. t['onehalf'] = 834;
  17559. t['lessequal'] = 549;
  17560. t['ocircumflex'] = 556;
  17561. t['ntilde'] = 556;
  17562. t['Uhungarumlaut'] = 722;
  17563. t['Eacute'] = 667;
  17564. t['emacron'] = 556;
  17565. t['gbreve'] = 556;
  17566. t['onequarter'] = 834;
  17567. t['Scaron'] = 667;
  17568. t['Scommaaccent'] = 667;
  17569. t['Ohungarumlaut'] = 778;
  17570. t['degree'] = 400;
  17571. t['ograve'] = 556;
  17572. t['Ccaron'] = 722;
  17573. t['ugrave'] = 556;
  17574. t['radical'] = 453;
  17575. t['Dcaron'] = 722;
  17576. t['rcommaaccent'] = 333;
  17577. t['Ntilde'] = 722;
  17578. t['otilde'] = 556;
  17579. t['Rcommaaccent'] = 722;
  17580. t['Lcommaaccent'] = 556;
  17581. t['Atilde'] = 667;
  17582. t['Aogonek'] = 667;
  17583. t['Aring'] = 667;
  17584. t['Otilde'] = 778;
  17585. t['zdotaccent'] = 500;
  17586. t['Ecaron'] = 667;
  17587. t['Iogonek'] = 278;
  17588. t['kcommaaccent'] = 500;
  17589. t['minus'] = 584;
  17590. t['Icircumflex'] = 278;
  17591. t['ncaron'] = 556;
  17592. t['tcommaaccent'] = 278;
  17593. t['logicalnot'] = 584;
  17594. t['odieresis'] = 556;
  17595. t['udieresis'] = 556;
  17596. t['notequal'] = 549;
  17597. t['gcommaaccent'] = 556;
  17598. t['eth'] = 556;
  17599. t['zcaron'] = 500;
  17600. t['ncommaaccent'] = 556;
  17601. t['onesuperior'] = 333;
  17602. t['imacron'] = 278;
  17603. t['Euro'] = 556;
  17604. });
  17605. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  17606. t['space'] = 278;
  17607. t['exclam'] = 333;
  17608. t['quotedbl'] = 474;
  17609. t['numbersign'] = 556;
  17610. t['dollar'] = 556;
  17611. t['percent'] = 889;
  17612. t['ampersand'] = 722;
  17613. t['quoteright'] = 278;
  17614. t['parenleft'] = 333;
  17615. t['parenright'] = 333;
  17616. t['asterisk'] = 389;
  17617. t['plus'] = 584;
  17618. t['comma'] = 278;
  17619. t['hyphen'] = 333;
  17620. t['period'] = 278;
  17621. t['slash'] = 278;
  17622. t['zero'] = 556;
  17623. t['one'] = 556;
  17624. t['two'] = 556;
  17625. t['three'] = 556;
  17626. t['four'] = 556;
  17627. t['five'] = 556;
  17628. t['six'] = 556;
  17629. t['seven'] = 556;
  17630. t['eight'] = 556;
  17631. t['nine'] = 556;
  17632. t['colon'] = 333;
  17633. t['semicolon'] = 333;
  17634. t['less'] = 584;
  17635. t['equal'] = 584;
  17636. t['greater'] = 584;
  17637. t['question'] = 611;
  17638. t['at'] = 975;
  17639. t['A'] = 722;
  17640. t['B'] = 722;
  17641. t['C'] = 722;
  17642. t['D'] = 722;
  17643. t['E'] = 667;
  17644. t['F'] = 611;
  17645. t['G'] = 778;
  17646. t['H'] = 722;
  17647. t['I'] = 278;
  17648. t['J'] = 556;
  17649. t['K'] = 722;
  17650. t['L'] = 611;
  17651. t['M'] = 833;
  17652. t['N'] = 722;
  17653. t['O'] = 778;
  17654. t['P'] = 667;
  17655. t['Q'] = 778;
  17656. t['R'] = 722;
  17657. t['S'] = 667;
  17658. t['T'] = 611;
  17659. t['U'] = 722;
  17660. t['V'] = 667;
  17661. t['W'] = 944;
  17662. t['X'] = 667;
  17663. t['Y'] = 667;
  17664. t['Z'] = 611;
  17665. t['bracketleft'] = 333;
  17666. t['backslash'] = 278;
  17667. t['bracketright'] = 333;
  17668. t['asciicircum'] = 584;
  17669. t['underscore'] = 556;
  17670. t['quoteleft'] = 278;
  17671. t['a'] = 556;
  17672. t['b'] = 611;
  17673. t['c'] = 556;
  17674. t['d'] = 611;
  17675. t['e'] = 556;
  17676. t['f'] = 333;
  17677. t['g'] = 611;
  17678. t['h'] = 611;
  17679. t['i'] = 278;
  17680. t['j'] = 278;
  17681. t['k'] = 556;
  17682. t['l'] = 278;
  17683. t['m'] = 889;
  17684. t['n'] = 611;
  17685. t['o'] = 611;
  17686. t['p'] = 611;
  17687. t['q'] = 611;
  17688. t['r'] = 389;
  17689. t['s'] = 556;
  17690. t['t'] = 333;
  17691. t['u'] = 611;
  17692. t['v'] = 556;
  17693. t['w'] = 778;
  17694. t['x'] = 556;
  17695. t['y'] = 556;
  17696. t['z'] = 500;
  17697. t['braceleft'] = 389;
  17698. t['bar'] = 280;
  17699. t['braceright'] = 389;
  17700. t['asciitilde'] = 584;
  17701. t['exclamdown'] = 333;
  17702. t['cent'] = 556;
  17703. t['sterling'] = 556;
  17704. t['fraction'] = 167;
  17705. t['yen'] = 556;
  17706. t['florin'] = 556;
  17707. t['section'] = 556;
  17708. t['currency'] = 556;
  17709. t['quotesingle'] = 238;
  17710. t['quotedblleft'] = 500;
  17711. t['guillemotleft'] = 556;
  17712. t['guilsinglleft'] = 333;
  17713. t['guilsinglright'] = 333;
  17714. t['fi'] = 611;
  17715. t['fl'] = 611;
  17716. t['endash'] = 556;
  17717. t['dagger'] = 556;
  17718. t['daggerdbl'] = 556;
  17719. t['periodcentered'] = 278;
  17720. t['paragraph'] = 556;
  17721. t['bullet'] = 350;
  17722. t['quotesinglbase'] = 278;
  17723. t['quotedblbase'] = 500;
  17724. t['quotedblright'] = 500;
  17725. t['guillemotright'] = 556;
  17726. t['ellipsis'] = 1000;
  17727. t['perthousand'] = 1000;
  17728. t['questiondown'] = 611;
  17729. t['grave'] = 333;
  17730. t['acute'] = 333;
  17731. t['circumflex'] = 333;
  17732. t['tilde'] = 333;
  17733. t['macron'] = 333;
  17734. t['breve'] = 333;
  17735. t['dotaccent'] = 333;
  17736. t['dieresis'] = 333;
  17737. t['ring'] = 333;
  17738. t['cedilla'] = 333;
  17739. t['hungarumlaut'] = 333;
  17740. t['ogonek'] = 333;
  17741. t['caron'] = 333;
  17742. t['emdash'] = 1000;
  17743. t['AE'] = 1000;
  17744. t['ordfeminine'] = 370;
  17745. t['Lslash'] = 611;
  17746. t['Oslash'] = 778;
  17747. t['OE'] = 1000;
  17748. t['ordmasculine'] = 365;
  17749. t['ae'] = 889;
  17750. t['dotlessi'] = 278;
  17751. t['lslash'] = 278;
  17752. t['oslash'] = 611;
  17753. t['oe'] = 944;
  17754. t['germandbls'] = 611;
  17755. t['Idieresis'] = 278;
  17756. t['eacute'] = 556;
  17757. t['abreve'] = 556;
  17758. t['uhungarumlaut'] = 611;
  17759. t['ecaron'] = 556;
  17760. t['Ydieresis'] = 667;
  17761. t['divide'] = 584;
  17762. t['Yacute'] = 667;
  17763. t['Acircumflex'] = 722;
  17764. t['aacute'] = 556;
  17765. t['Ucircumflex'] = 722;
  17766. t['yacute'] = 556;
  17767. t['scommaaccent'] = 556;
  17768. t['ecircumflex'] = 556;
  17769. t['Uring'] = 722;
  17770. t['Udieresis'] = 722;
  17771. t['aogonek'] = 556;
  17772. t['Uacute'] = 722;
  17773. t['uogonek'] = 611;
  17774. t['Edieresis'] = 667;
  17775. t['Dcroat'] = 722;
  17776. t['commaaccent'] = 250;
  17777. t['copyright'] = 737;
  17778. t['Emacron'] = 667;
  17779. t['ccaron'] = 556;
  17780. t['aring'] = 556;
  17781. t['Ncommaaccent'] = 722;
  17782. t['lacute'] = 278;
  17783. t['agrave'] = 556;
  17784. t['Tcommaaccent'] = 611;
  17785. t['Cacute'] = 722;
  17786. t['atilde'] = 556;
  17787. t['Edotaccent'] = 667;
  17788. t['scaron'] = 556;
  17789. t['scedilla'] = 556;
  17790. t['iacute'] = 278;
  17791. t['lozenge'] = 494;
  17792. t['Rcaron'] = 722;
  17793. t['Gcommaaccent'] = 778;
  17794. t['ucircumflex'] = 611;
  17795. t['acircumflex'] = 556;
  17796. t['Amacron'] = 722;
  17797. t['rcaron'] = 389;
  17798. t['ccedilla'] = 556;
  17799. t['Zdotaccent'] = 611;
  17800. t['Thorn'] = 667;
  17801. t['Omacron'] = 778;
  17802. t['Racute'] = 722;
  17803. t['Sacute'] = 667;
  17804. t['dcaron'] = 743;
  17805. t['Umacron'] = 722;
  17806. t['uring'] = 611;
  17807. t['threesuperior'] = 333;
  17808. t['Ograve'] = 778;
  17809. t['Agrave'] = 722;
  17810. t['Abreve'] = 722;
  17811. t['multiply'] = 584;
  17812. t['uacute'] = 611;
  17813. t['Tcaron'] = 611;
  17814. t['partialdiff'] = 494;
  17815. t['ydieresis'] = 556;
  17816. t['Nacute'] = 722;
  17817. t['icircumflex'] = 278;
  17818. t['Ecircumflex'] = 667;
  17819. t['adieresis'] = 556;
  17820. t['edieresis'] = 556;
  17821. t['cacute'] = 556;
  17822. t['nacute'] = 611;
  17823. t['umacron'] = 611;
  17824. t['Ncaron'] = 722;
  17825. t['Iacute'] = 278;
  17826. t['plusminus'] = 584;
  17827. t['brokenbar'] = 280;
  17828. t['registered'] = 737;
  17829. t['Gbreve'] = 778;
  17830. t['Idotaccent'] = 278;
  17831. t['summation'] = 600;
  17832. t['Egrave'] = 667;
  17833. t['racute'] = 389;
  17834. t['omacron'] = 611;
  17835. t['Zacute'] = 611;
  17836. t['Zcaron'] = 611;
  17837. t['greaterequal'] = 549;
  17838. t['Eth'] = 722;
  17839. t['Ccedilla'] = 722;
  17840. t['lcommaaccent'] = 278;
  17841. t['tcaron'] = 389;
  17842. t['eogonek'] = 556;
  17843. t['Uogonek'] = 722;
  17844. t['Aacute'] = 722;
  17845. t['Adieresis'] = 722;
  17846. t['egrave'] = 556;
  17847. t['zacute'] = 500;
  17848. t['iogonek'] = 278;
  17849. t['Oacute'] = 778;
  17850. t['oacute'] = 611;
  17851. t['amacron'] = 556;
  17852. t['sacute'] = 556;
  17853. t['idieresis'] = 278;
  17854. t['Ocircumflex'] = 778;
  17855. t['Ugrave'] = 722;
  17856. t['Delta'] = 612;
  17857. t['thorn'] = 611;
  17858. t['twosuperior'] = 333;
  17859. t['Odieresis'] = 778;
  17860. t['mu'] = 611;
  17861. t['igrave'] = 278;
  17862. t['ohungarumlaut'] = 611;
  17863. t['Eogonek'] = 667;
  17864. t['dcroat'] = 611;
  17865. t['threequarters'] = 834;
  17866. t['Scedilla'] = 667;
  17867. t['lcaron'] = 400;
  17868. t['Kcommaaccent'] = 722;
  17869. t['Lacute'] = 611;
  17870. t['trademark'] = 1000;
  17871. t['edotaccent'] = 556;
  17872. t['Igrave'] = 278;
  17873. t['Imacron'] = 278;
  17874. t['Lcaron'] = 611;
  17875. t['onehalf'] = 834;
  17876. t['lessequal'] = 549;
  17877. t['ocircumflex'] = 611;
  17878. t['ntilde'] = 611;
  17879. t['Uhungarumlaut'] = 722;
  17880. t['Eacute'] = 667;
  17881. t['emacron'] = 556;
  17882. t['gbreve'] = 611;
  17883. t['onequarter'] = 834;
  17884. t['Scaron'] = 667;
  17885. t['Scommaaccent'] = 667;
  17886. t['Ohungarumlaut'] = 778;
  17887. t['degree'] = 400;
  17888. t['ograve'] = 611;
  17889. t['Ccaron'] = 722;
  17890. t['ugrave'] = 611;
  17891. t['radical'] = 549;
  17892. t['Dcaron'] = 722;
  17893. t['rcommaaccent'] = 389;
  17894. t['Ntilde'] = 722;
  17895. t['otilde'] = 611;
  17896. t['Rcommaaccent'] = 722;
  17897. t['Lcommaaccent'] = 611;
  17898. t['Atilde'] = 722;
  17899. t['Aogonek'] = 722;
  17900. t['Aring'] = 722;
  17901. t['Otilde'] = 778;
  17902. t['zdotaccent'] = 500;
  17903. t['Ecaron'] = 667;
  17904. t['Iogonek'] = 278;
  17905. t['kcommaaccent'] = 556;
  17906. t['minus'] = 584;
  17907. t['Icircumflex'] = 278;
  17908. t['ncaron'] = 611;
  17909. t['tcommaaccent'] = 333;
  17910. t['logicalnot'] = 584;
  17911. t['odieresis'] = 611;
  17912. t['udieresis'] = 611;
  17913. t['notequal'] = 549;
  17914. t['gcommaaccent'] = 611;
  17915. t['eth'] = 611;
  17916. t['zcaron'] = 500;
  17917. t['ncommaaccent'] = 611;
  17918. t['onesuperior'] = 333;
  17919. t['imacron'] = 278;
  17920. t['Euro'] = 556;
  17921. });
  17922. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  17923. t['space'] = 278;
  17924. t['exclam'] = 333;
  17925. t['quotedbl'] = 474;
  17926. t['numbersign'] = 556;
  17927. t['dollar'] = 556;
  17928. t['percent'] = 889;
  17929. t['ampersand'] = 722;
  17930. t['quoteright'] = 278;
  17931. t['parenleft'] = 333;
  17932. t['parenright'] = 333;
  17933. t['asterisk'] = 389;
  17934. t['plus'] = 584;
  17935. t['comma'] = 278;
  17936. t['hyphen'] = 333;
  17937. t['period'] = 278;
  17938. t['slash'] = 278;
  17939. t['zero'] = 556;
  17940. t['one'] = 556;
  17941. t['two'] = 556;
  17942. t['three'] = 556;
  17943. t['four'] = 556;
  17944. t['five'] = 556;
  17945. t['six'] = 556;
  17946. t['seven'] = 556;
  17947. t['eight'] = 556;
  17948. t['nine'] = 556;
  17949. t['colon'] = 333;
  17950. t['semicolon'] = 333;
  17951. t['less'] = 584;
  17952. t['equal'] = 584;
  17953. t['greater'] = 584;
  17954. t['question'] = 611;
  17955. t['at'] = 975;
  17956. t['A'] = 722;
  17957. t['B'] = 722;
  17958. t['C'] = 722;
  17959. t['D'] = 722;
  17960. t['E'] = 667;
  17961. t['F'] = 611;
  17962. t['G'] = 778;
  17963. t['H'] = 722;
  17964. t['I'] = 278;
  17965. t['J'] = 556;
  17966. t['K'] = 722;
  17967. t['L'] = 611;
  17968. t['M'] = 833;
  17969. t['N'] = 722;
  17970. t['O'] = 778;
  17971. t['P'] = 667;
  17972. t['Q'] = 778;
  17973. t['R'] = 722;
  17974. t['S'] = 667;
  17975. t['T'] = 611;
  17976. t['U'] = 722;
  17977. t['V'] = 667;
  17978. t['W'] = 944;
  17979. t['X'] = 667;
  17980. t['Y'] = 667;
  17981. t['Z'] = 611;
  17982. t['bracketleft'] = 333;
  17983. t['backslash'] = 278;
  17984. t['bracketright'] = 333;
  17985. t['asciicircum'] = 584;
  17986. t['underscore'] = 556;
  17987. t['quoteleft'] = 278;
  17988. t['a'] = 556;
  17989. t['b'] = 611;
  17990. t['c'] = 556;
  17991. t['d'] = 611;
  17992. t['e'] = 556;
  17993. t['f'] = 333;
  17994. t['g'] = 611;
  17995. t['h'] = 611;
  17996. t['i'] = 278;
  17997. t['j'] = 278;
  17998. t['k'] = 556;
  17999. t['l'] = 278;
  18000. t['m'] = 889;
  18001. t['n'] = 611;
  18002. t['o'] = 611;
  18003. t['p'] = 611;
  18004. t['q'] = 611;
  18005. t['r'] = 389;
  18006. t['s'] = 556;
  18007. t['t'] = 333;
  18008. t['u'] = 611;
  18009. t['v'] = 556;
  18010. t['w'] = 778;
  18011. t['x'] = 556;
  18012. t['y'] = 556;
  18013. t['z'] = 500;
  18014. t['braceleft'] = 389;
  18015. t['bar'] = 280;
  18016. t['braceright'] = 389;
  18017. t['asciitilde'] = 584;
  18018. t['exclamdown'] = 333;
  18019. t['cent'] = 556;
  18020. t['sterling'] = 556;
  18021. t['fraction'] = 167;
  18022. t['yen'] = 556;
  18023. t['florin'] = 556;
  18024. t['section'] = 556;
  18025. t['currency'] = 556;
  18026. t['quotesingle'] = 238;
  18027. t['quotedblleft'] = 500;
  18028. t['guillemotleft'] = 556;
  18029. t['guilsinglleft'] = 333;
  18030. t['guilsinglright'] = 333;
  18031. t['fi'] = 611;
  18032. t['fl'] = 611;
  18033. t['endash'] = 556;
  18034. t['dagger'] = 556;
  18035. t['daggerdbl'] = 556;
  18036. t['periodcentered'] = 278;
  18037. t['paragraph'] = 556;
  18038. t['bullet'] = 350;
  18039. t['quotesinglbase'] = 278;
  18040. t['quotedblbase'] = 500;
  18041. t['quotedblright'] = 500;
  18042. t['guillemotright'] = 556;
  18043. t['ellipsis'] = 1000;
  18044. t['perthousand'] = 1000;
  18045. t['questiondown'] = 611;
  18046. t['grave'] = 333;
  18047. t['acute'] = 333;
  18048. t['circumflex'] = 333;
  18049. t['tilde'] = 333;
  18050. t['macron'] = 333;
  18051. t['breve'] = 333;
  18052. t['dotaccent'] = 333;
  18053. t['dieresis'] = 333;
  18054. t['ring'] = 333;
  18055. t['cedilla'] = 333;
  18056. t['hungarumlaut'] = 333;
  18057. t['ogonek'] = 333;
  18058. t['caron'] = 333;
  18059. t['emdash'] = 1000;
  18060. t['AE'] = 1000;
  18061. t['ordfeminine'] = 370;
  18062. t['Lslash'] = 611;
  18063. t['Oslash'] = 778;
  18064. t['OE'] = 1000;
  18065. t['ordmasculine'] = 365;
  18066. t['ae'] = 889;
  18067. t['dotlessi'] = 278;
  18068. t['lslash'] = 278;
  18069. t['oslash'] = 611;
  18070. t['oe'] = 944;
  18071. t['germandbls'] = 611;
  18072. t['Idieresis'] = 278;
  18073. t['eacute'] = 556;
  18074. t['abreve'] = 556;
  18075. t['uhungarumlaut'] = 611;
  18076. t['ecaron'] = 556;
  18077. t['Ydieresis'] = 667;
  18078. t['divide'] = 584;
  18079. t['Yacute'] = 667;
  18080. t['Acircumflex'] = 722;
  18081. t['aacute'] = 556;
  18082. t['Ucircumflex'] = 722;
  18083. t['yacute'] = 556;
  18084. t['scommaaccent'] = 556;
  18085. t['ecircumflex'] = 556;
  18086. t['Uring'] = 722;
  18087. t['Udieresis'] = 722;
  18088. t['aogonek'] = 556;
  18089. t['Uacute'] = 722;
  18090. t['uogonek'] = 611;
  18091. t['Edieresis'] = 667;
  18092. t['Dcroat'] = 722;
  18093. t['commaaccent'] = 250;
  18094. t['copyright'] = 737;
  18095. t['Emacron'] = 667;
  18096. t['ccaron'] = 556;
  18097. t['aring'] = 556;
  18098. t['Ncommaaccent'] = 722;
  18099. t['lacute'] = 278;
  18100. t['agrave'] = 556;
  18101. t['Tcommaaccent'] = 611;
  18102. t['Cacute'] = 722;
  18103. t['atilde'] = 556;
  18104. t['Edotaccent'] = 667;
  18105. t['scaron'] = 556;
  18106. t['scedilla'] = 556;
  18107. t['iacute'] = 278;
  18108. t['lozenge'] = 494;
  18109. t['Rcaron'] = 722;
  18110. t['Gcommaaccent'] = 778;
  18111. t['ucircumflex'] = 611;
  18112. t['acircumflex'] = 556;
  18113. t['Amacron'] = 722;
  18114. t['rcaron'] = 389;
  18115. t['ccedilla'] = 556;
  18116. t['Zdotaccent'] = 611;
  18117. t['Thorn'] = 667;
  18118. t['Omacron'] = 778;
  18119. t['Racute'] = 722;
  18120. t['Sacute'] = 667;
  18121. t['dcaron'] = 743;
  18122. t['Umacron'] = 722;
  18123. t['uring'] = 611;
  18124. t['threesuperior'] = 333;
  18125. t['Ograve'] = 778;
  18126. t['Agrave'] = 722;
  18127. t['Abreve'] = 722;
  18128. t['multiply'] = 584;
  18129. t['uacute'] = 611;
  18130. t['Tcaron'] = 611;
  18131. t['partialdiff'] = 494;
  18132. t['ydieresis'] = 556;
  18133. t['Nacute'] = 722;
  18134. t['icircumflex'] = 278;
  18135. t['Ecircumflex'] = 667;
  18136. t['adieresis'] = 556;
  18137. t['edieresis'] = 556;
  18138. t['cacute'] = 556;
  18139. t['nacute'] = 611;
  18140. t['umacron'] = 611;
  18141. t['Ncaron'] = 722;
  18142. t['Iacute'] = 278;
  18143. t['plusminus'] = 584;
  18144. t['brokenbar'] = 280;
  18145. t['registered'] = 737;
  18146. t['Gbreve'] = 778;
  18147. t['Idotaccent'] = 278;
  18148. t['summation'] = 600;
  18149. t['Egrave'] = 667;
  18150. t['racute'] = 389;
  18151. t['omacron'] = 611;
  18152. t['Zacute'] = 611;
  18153. t['Zcaron'] = 611;
  18154. t['greaterequal'] = 549;
  18155. t['Eth'] = 722;
  18156. t['Ccedilla'] = 722;
  18157. t['lcommaaccent'] = 278;
  18158. t['tcaron'] = 389;
  18159. t['eogonek'] = 556;
  18160. t['Uogonek'] = 722;
  18161. t['Aacute'] = 722;
  18162. t['Adieresis'] = 722;
  18163. t['egrave'] = 556;
  18164. t['zacute'] = 500;
  18165. t['iogonek'] = 278;
  18166. t['Oacute'] = 778;
  18167. t['oacute'] = 611;
  18168. t['amacron'] = 556;
  18169. t['sacute'] = 556;
  18170. t['idieresis'] = 278;
  18171. t['Ocircumflex'] = 778;
  18172. t['Ugrave'] = 722;
  18173. t['Delta'] = 612;
  18174. t['thorn'] = 611;
  18175. t['twosuperior'] = 333;
  18176. t['Odieresis'] = 778;
  18177. t['mu'] = 611;
  18178. t['igrave'] = 278;
  18179. t['ohungarumlaut'] = 611;
  18180. t['Eogonek'] = 667;
  18181. t['dcroat'] = 611;
  18182. t['threequarters'] = 834;
  18183. t['Scedilla'] = 667;
  18184. t['lcaron'] = 400;
  18185. t['Kcommaaccent'] = 722;
  18186. t['Lacute'] = 611;
  18187. t['trademark'] = 1000;
  18188. t['edotaccent'] = 556;
  18189. t['Igrave'] = 278;
  18190. t['Imacron'] = 278;
  18191. t['Lcaron'] = 611;
  18192. t['onehalf'] = 834;
  18193. t['lessequal'] = 549;
  18194. t['ocircumflex'] = 611;
  18195. t['ntilde'] = 611;
  18196. t['Uhungarumlaut'] = 722;
  18197. t['Eacute'] = 667;
  18198. t['emacron'] = 556;
  18199. t['gbreve'] = 611;
  18200. t['onequarter'] = 834;
  18201. t['Scaron'] = 667;
  18202. t['Scommaaccent'] = 667;
  18203. t['Ohungarumlaut'] = 778;
  18204. t['degree'] = 400;
  18205. t['ograve'] = 611;
  18206. t['Ccaron'] = 722;
  18207. t['ugrave'] = 611;
  18208. t['radical'] = 549;
  18209. t['Dcaron'] = 722;
  18210. t['rcommaaccent'] = 389;
  18211. t['Ntilde'] = 722;
  18212. t['otilde'] = 611;
  18213. t['Rcommaaccent'] = 722;
  18214. t['Lcommaaccent'] = 611;
  18215. t['Atilde'] = 722;
  18216. t['Aogonek'] = 722;
  18217. t['Aring'] = 722;
  18218. t['Otilde'] = 778;
  18219. t['zdotaccent'] = 500;
  18220. t['Ecaron'] = 667;
  18221. t['Iogonek'] = 278;
  18222. t['kcommaaccent'] = 556;
  18223. t['minus'] = 584;
  18224. t['Icircumflex'] = 278;
  18225. t['ncaron'] = 611;
  18226. t['tcommaaccent'] = 333;
  18227. t['logicalnot'] = 584;
  18228. t['odieresis'] = 611;
  18229. t['udieresis'] = 611;
  18230. t['notequal'] = 549;
  18231. t['gcommaaccent'] = 611;
  18232. t['eth'] = 611;
  18233. t['zcaron'] = 500;
  18234. t['ncommaaccent'] = 611;
  18235. t['onesuperior'] = 333;
  18236. t['imacron'] = 278;
  18237. t['Euro'] = 556;
  18238. });
  18239. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  18240. t['space'] = 278;
  18241. t['exclam'] = 278;
  18242. t['quotedbl'] = 355;
  18243. t['numbersign'] = 556;
  18244. t['dollar'] = 556;
  18245. t['percent'] = 889;
  18246. t['ampersand'] = 667;
  18247. t['quoteright'] = 222;
  18248. t['parenleft'] = 333;
  18249. t['parenright'] = 333;
  18250. t['asterisk'] = 389;
  18251. t['plus'] = 584;
  18252. t['comma'] = 278;
  18253. t['hyphen'] = 333;
  18254. t['period'] = 278;
  18255. t['slash'] = 278;
  18256. t['zero'] = 556;
  18257. t['one'] = 556;
  18258. t['two'] = 556;
  18259. t['three'] = 556;
  18260. t['four'] = 556;
  18261. t['five'] = 556;
  18262. t['six'] = 556;
  18263. t['seven'] = 556;
  18264. t['eight'] = 556;
  18265. t['nine'] = 556;
  18266. t['colon'] = 278;
  18267. t['semicolon'] = 278;
  18268. t['less'] = 584;
  18269. t['equal'] = 584;
  18270. t['greater'] = 584;
  18271. t['question'] = 556;
  18272. t['at'] = 1015;
  18273. t['A'] = 667;
  18274. t['B'] = 667;
  18275. t['C'] = 722;
  18276. t['D'] = 722;
  18277. t['E'] = 667;
  18278. t['F'] = 611;
  18279. t['G'] = 778;
  18280. t['H'] = 722;
  18281. t['I'] = 278;
  18282. t['J'] = 500;
  18283. t['K'] = 667;
  18284. t['L'] = 556;
  18285. t['M'] = 833;
  18286. t['N'] = 722;
  18287. t['O'] = 778;
  18288. t['P'] = 667;
  18289. t['Q'] = 778;
  18290. t['R'] = 722;
  18291. t['S'] = 667;
  18292. t['T'] = 611;
  18293. t['U'] = 722;
  18294. t['V'] = 667;
  18295. t['W'] = 944;
  18296. t['X'] = 667;
  18297. t['Y'] = 667;
  18298. t['Z'] = 611;
  18299. t['bracketleft'] = 278;
  18300. t['backslash'] = 278;
  18301. t['bracketright'] = 278;
  18302. t['asciicircum'] = 469;
  18303. t['underscore'] = 556;
  18304. t['quoteleft'] = 222;
  18305. t['a'] = 556;
  18306. t['b'] = 556;
  18307. t['c'] = 500;
  18308. t['d'] = 556;
  18309. t['e'] = 556;
  18310. t['f'] = 278;
  18311. t['g'] = 556;
  18312. t['h'] = 556;
  18313. t['i'] = 222;
  18314. t['j'] = 222;
  18315. t['k'] = 500;
  18316. t['l'] = 222;
  18317. t['m'] = 833;
  18318. t['n'] = 556;
  18319. t['o'] = 556;
  18320. t['p'] = 556;
  18321. t['q'] = 556;
  18322. t['r'] = 333;
  18323. t['s'] = 500;
  18324. t['t'] = 278;
  18325. t['u'] = 556;
  18326. t['v'] = 500;
  18327. t['w'] = 722;
  18328. t['x'] = 500;
  18329. t['y'] = 500;
  18330. t['z'] = 500;
  18331. t['braceleft'] = 334;
  18332. t['bar'] = 260;
  18333. t['braceright'] = 334;
  18334. t['asciitilde'] = 584;
  18335. t['exclamdown'] = 333;
  18336. t['cent'] = 556;
  18337. t['sterling'] = 556;
  18338. t['fraction'] = 167;
  18339. t['yen'] = 556;
  18340. t['florin'] = 556;
  18341. t['section'] = 556;
  18342. t['currency'] = 556;
  18343. t['quotesingle'] = 191;
  18344. t['quotedblleft'] = 333;
  18345. t['guillemotleft'] = 556;
  18346. t['guilsinglleft'] = 333;
  18347. t['guilsinglright'] = 333;
  18348. t['fi'] = 500;
  18349. t['fl'] = 500;
  18350. t['endash'] = 556;
  18351. t['dagger'] = 556;
  18352. t['daggerdbl'] = 556;
  18353. t['periodcentered'] = 278;
  18354. t['paragraph'] = 537;
  18355. t['bullet'] = 350;
  18356. t['quotesinglbase'] = 222;
  18357. t['quotedblbase'] = 333;
  18358. t['quotedblright'] = 333;
  18359. t['guillemotright'] = 556;
  18360. t['ellipsis'] = 1000;
  18361. t['perthousand'] = 1000;
  18362. t['questiondown'] = 611;
  18363. t['grave'] = 333;
  18364. t['acute'] = 333;
  18365. t['circumflex'] = 333;
  18366. t['tilde'] = 333;
  18367. t['macron'] = 333;
  18368. t['breve'] = 333;
  18369. t['dotaccent'] = 333;
  18370. t['dieresis'] = 333;
  18371. t['ring'] = 333;
  18372. t['cedilla'] = 333;
  18373. t['hungarumlaut'] = 333;
  18374. t['ogonek'] = 333;
  18375. t['caron'] = 333;
  18376. t['emdash'] = 1000;
  18377. t['AE'] = 1000;
  18378. t['ordfeminine'] = 370;
  18379. t['Lslash'] = 556;
  18380. t['Oslash'] = 778;
  18381. t['OE'] = 1000;
  18382. t['ordmasculine'] = 365;
  18383. t['ae'] = 889;
  18384. t['dotlessi'] = 278;
  18385. t['lslash'] = 222;
  18386. t['oslash'] = 611;
  18387. t['oe'] = 944;
  18388. t['germandbls'] = 611;
  18389. t['Idieresis'] = 278;
  18390. t['eacute'] = 556;
  18391. t['abreve'] = 556;
  18392. t['uhungarumlaut'] = 556;
  18393. t['ecaron'] = 556;
  18394. t['Ydieresis'] = 667;
  18395. t['divide'] = 584;
  18396. t['Yacute'] = 667;
  18397. t['Acircumflex'] = 667;
  18398. t['aacute'] = 556;
  18399. t['Ucircumflex'] = 722;
  18400. t['yacute'] = 500;
  18401. t['scommaaccent'] = 500;
  18402. t['ecircumflex'] = 556;
  18403. t['Uring'] = 722;
  18404. t['Udieresis'] = 722;
  18405. t['aogonek'] = 556;
  18406. t['Uacute'] = 722;
  18407. t['uogonek'] = 556;
  18408. t['Edieresis'] = 667;
  18409. t['Dcroat'] = 722;
  18410. t['commaaccent'] = 250;
  18411. t['copyright'] = 737;
  18412. t['Emacron'] = 667;
  18413. t['ccaron'] = 500;
  18414. t['aring'] = 556;
  18415. t['Ncommaaccent'] = 722;
  18416. t['lacute'] = 222;
  18417. t['agrave'] = 556;
  18418. t['Tcommaaccent'] = 611;
  18419. t['Cacute'] = 722;
  18420. t['atilde'] = 556;
  18421. t['Edotaccent'] = 667;
  18422. t['scaron'] = 500;
  18423. t['scedilla'] = 500;
  18424. t['iacute'] = 278;
  18425. t['lozenge'] = 471;
  18426. t['Rcaron'] = 722;
  18427. t['Gcommaaccent'] = 778;
  18428. t['ucircumflex'] = 556;
  18429. t['acircumflex'] = 556;
  18430. t['Amacron'] = 667;
  18431. t['rcaron'] = 333;
  18432. t['ccedilla'] = 500;
  18433. t['Zdotaccent'] = 611;
  18434. t['Thorn'] = 667;
  18435. t['Omacron'] = 778;
  18436. t['Racute'] = 722;
  18437. t['Sacute'] = 667;
  18438. t['dcaron'] = 643;
  18439. t['Umacron'] = 722;
  18440. t['uring'] = 556;
  18441. t['threesuperior'] = 333;
  18442. t['Ograve'] = 778;
  18443. t['Agrave'] = 667;
  18444. t['Abreve'] = 667;
  18445. t['multiply'] = 584;
  18446. t['uacute'] = 556;
  18447. t['Tcaron'] = 611;
  18448. t['partialdiff'] = 476;
  18449. t['ydieresis'] = 500;
  18450. t['Nacute'] = 722;
  18451. t['icircumflex'] = 278;
  18452. t['Ecircumflex'] = 667;
  18453. t['adieresis'] = 556;
  18454. t['edieresis'] = 556;
  18455. t['cacute'] = 500;
  18456. t['nacute'] = 556;
  18457. t['umacron'] = 556;
  18458. t['Ncaron'] = 722;
  18459. t['Iacute'] = 278;
  18460. t['plusminus'] = 584;
  18461. t['brokenbar'] = 260;
  18462. t['registered'] = 737;
  18463. t['Gbreve'] = 778;
  18464. t['Idotaccent'] = 278;
  18465. t['summation'] = 600;
  18466. t['Egrave'] = 667;
  18467. t['racute'] = 333;
  18468. t['omacron'] = 556;
  18469. t['Zacute'] = 611;
  18470. t['Zcaron'] = 611;
  18471. t['greaterequal'] = 549;
  18472. t['Eth'] = 722;
  18473. t['Ccedilla'] = 722;
  18474. t['lcommaaccent'] = 222;
  18475. t['tcaron'] = 317;
  18476. t['eogonek'] = 556;
  18477. t['Uogonek'] = 722;
  18478. t['Aacute'] = 667;
  18479. t['Adieresis'] = 667;
  18480. t['egrave'] = 556;
  18481. t['zacute'] = 500;
  18482. t['iogonek'] = 222;
  18483. t['Oacute'] = 778;
  18484. t['oacute'] = 556;
  18485. t['amacron'] = 556;
  18486. t['sacute'] = 500;
  18487. t['idieresis'] = 278;
  18488. t['Ocircumflex'] = 778;
  18489. t['Ugrave'] = 722;
  18490. t['Delta'] = 612;
  18491. t['thorn'] = 556;
  18492. t['twosuperior'] = 333;
  18493. t['Odieresis'] = 778;
  18494. t['mu'] = 556;
  18495. t['igrave'] = 278;
  18496. t['ohungarumlaut'] = 556;
  18497. t['Eogonek'] = 667;
  18498. t['dcroat'] = 556;
  18499. t['threequarters'] = 834;
  18500. t['Scedilla'] = 667;
  18501. t['lcaron'] = 299;
  18502. t['Kcommaaccent'] = 667;
  18503. t['Lacute'] = 556;
  18504. t['trademark'] = 1000;
  18505. t['edotaccent'] = 556;
  18506. t['Igrave'] = 278;
  18507. t['Imacron'] = 278;
  18508. t['Lcaron'] = 556;
  18509. t['onehalf'] = 834;
  18510. t['lessequal'] = 549;
  18511. t['ocircumflex'] = 556;
  18512. t['ntilde'] = 556;
  18513. t['Uhungarumlaut'] = 722;
  18514. t['Eacute'] = 667;
  18515. t['emacron'] = 556;
  18516. t['gbreve'] = 556;
  18517. t['onequarter'] = 834;
  18518. t['Scaron'] = 667;
  18519. t['Scommaaccent'] = 667;
  18520. t['Ohungarumlaut'] = 778;
  18521. t['degree'] = 400;
  18522. t['ograve'] = 556;
  18523. t['Ccaron'] = 722;
  18524. t['ugrave'] = 556;
  18525. t['radical'] = 453;
  18526. t['Dcaron'] = 722;
  18527. t['rcommaaccent'] = 333;
  18528. t['Ntilde'] = 722;
  18529. t['otilde'] = 556;
  18530. t['Rcommaaccent'] = 722;
  18531. t['Lcommaaccent'] = 556;
  18532. t['Atilde'] = 667;
  18533. t['Aogonek'] = 667;
  18534. t['Aring'] = 667;
  18535. t['Otilde'] = 778;
  18536. t['zdotaccent'] = 500;
  18537. t['Ecaron'] = 667;
  18538. t['Iogonek'] = 278;
  18539. t['kcommaaccent'] = 500;
  18540. t['minus'] = 584;
  18541. t['Icircumflex'] = 278;
  18542. t['ncaron'] = 556;
  18543. t['tcommaaccent'] = 278;
  18544. t['logicalnot'] = 584;
  18545. t['odieresis'] = 556;
  18546. t['udieresis'] = 556;
  18547. t['notequal'] = 549;
  18548. t['gcommaaccent'] = 556;
  18549. t['eth'] = 556;
  18550. t['zcaron'] = 500;
  18551. t['ncommaaccent'] = 556;
  18552. t['onesuperior'] = 333;
  18553. t['imacron'] = 278;
  18554. t['Euro'] = 556;
  18555. });
  18556. t['Symbol'] = getLookupTableFactory(function (t) {
  18557. t['space'] = 250;
  18558. t['exclam'] = 333;
  18559. t['universal'] = 713;
  18560. t['numbersign'] = 500;
  18561. t['existential'] = 549;
  18562. t['percent'] = 833;
  18563. t['ampersand'] = 778;
  18564. t['suchthat'] = 439;
  18565. t['parenleft'] = 333;
  18566. t['parenright'] = 333;
  18567. t['asteriskmath'] = 500;
  18568. t['plus'] = 549;
  18569. t['comma'] = 250;
  18570. t['minus'] = 549;
  18571. t['period'] = 250;
  18572. t['slash'] = 278;
  18573. t['zero'] = 500;
  18574. t['one'] = 500;
  18575. t['two'] = 500;
  18576. t['three'] = 500;
  18577. t['four'] = 500;
  18578. t['five'] = 500;
  18579. t['six'] = 500;
  18580. t['seven'] = 500;
  18581. t['eight'] = 500;
  18582. t['nine'] = 500;
  18583. t['colon'] = 278;
  18584. t['semicolon'] = 278;
  18585. t['less'] = 549;
  18586. t['equal'] = 549;
  18587. t['greater'] = 549;
  18588. t['question'] = 444;
  18589. t['congruent'] = 549;
  18590. t['Alpha'] = 722;
  18591. t['Beta'] = 667;
  18592. t['Chi'] = 722;
  18593. t['Delta'] = 612;
  18594. t['Epsilon'] = 611;
  18595. t['Phi'] = 763;
  18596. t['Gamma'] = 603;
  18597. t['Eta'] = 722;
  18598. t['Iota'] = 333;
  18599. t['theta1'] = 631;
  18600. t['Kappa'] = 722;
  18601. t['Lambda'] = 686;
  18602. t['Mu'] = 889;
  18603. t['Nu'] = 722;
  18604. t['Omicron'] = 722;
  18605. t['Pi'] = 768;
  18606. t['Theta'] = 741;
  18607. t['Rho'] = 556;
  18608. t['Sigma'] = 592;
  18609. t['Tau'] = 611;
  18610. t['Upsilon'] = 690;
  18611. t['sigma1'] = 439;
  18612. t['Omega'] = 768;
  18613. t['Xi'] = 645;
  18614. t['Psi'] = 795;
  18615. t['Zeta'] = 611;
  18616. t['bracketleft'] = 333;
  18617. t['therefore'] = 863;
  18618. t['bracketright'] = 333;
  18619. t['perpendicular'] = 658;
  18620. t['underscore'] = 500;
  18621. t['radicalex'] = 500;
  18622. t['alpha'] = 631;
  18623. t['beta'] = 549;
  18624. t['chi'] = 549;
  18625. t['delta'] = 494;
  18626. t['epsilon'] = 439;
  18627. t['phi'] = 521;
  18628. t['gamma'] = 411;
  18629. t['eta'] = 603;
  18630. t['iota'] = 329;
  18631. t['phi1'] = 603;
  18632. t['kappa'] = 549;
  18633. t['lambda'] = 549;
  18634. t['mu'] = 576;
  18635. t['nu'] = 521;
  18636. t['omicron'] = 549;
  18637. t['pi'] = 549;
  18638. t['theta'] = 521;
  18639. t['rho'] = 549;
  18640. t['sigma'] = 603;
  18641. t['tau'] = 439;
  18642. t['upsilon'] = 576;
  18643. t['omega1'] = 713;
  18644. t['omega'] = 686;
  18645. t['xi'] = 493;
  18646. t['psi'] = 686;
  18647. t['zeta'] = 494;
  18648. t['braceleft'] = 480;
  18649. t['bar'] = 200;
  18650. t['braceright'] = 480;
  18651. t['similar'] = 549;
  18652. t['Euro'] = 750;
  18653. t['Upsilon1'] = 620;
  18654. t['minute'] = 247;
  18655. t['lessequal'] = 549;
  18656. t['fraction'] = 167;
  18657. t['infinity'] = 713;
  18658. t['florin'] = 500;
  18659. t['club'] = 753;
  18660. t['diamond'] = 753;
  18661. t['heart'] = 753;
  18662. t['spade'] = 753;
  18663. t['arrowboth'] = 1042;
  18664. t['arrowleft'] = 987;
  18665. t['arrowup'] = 603;
  18666. t['arrowright'] = 987;
  18667. t['arrowdown'] = 603;
  18668. t['degree'] = 400;
  18669. t['plusminus'] = 549;
  18670. t['second'] = 411;
  18671. t['greaterequal'] = 549;
  18672. t['multiply'] = 549;
  18673. t['proportional'] = 713;
  18674. t['partialdiff'] = 494;
  18675. t['bullet'] = 460;
  18676. t['divide'] = 549;
  18677. t['notequal'] = 549;
  18678. t['equivalence'] = 549;
  18679. t['approxequal'] = 549;
  18680. t['ellipsis'] = 1000;
  18681. t['arrowvertex'] = 603;
  18682. t['arrowhorizex'] = 1000;
  18683. t['carriagereturn'] = 658;
  18684. t['aleph'] = 823;
  18685. t['Ifraktur'] = 686;
  18686. t['Rfraktur'] = 795;
  18687. t['weierstrass'] = 987;
  18688. t['circlemultiply'] = 768;
  18689. t['circleplus'] = 768;
  18690. t['emptyset'] = 823;
  18691. t['intersection'] = 768;
  18692. t['union'] = 768;
  18693. t['propersuperset'] = 713;
  18694. t['reflexsuperset'] = 713;
  18695. t['notsubset'] = 713;
  18696. t['propersubset'] = 713;
  18697. t['reflexsubset'] = 713;
  18698. t['element'] = 713;
  18699. t['notelement'] = 713;
  18700. t['angle'] = 768;
  18701. t['gradient'] = 713;
  18702. t['registerserif'] = 790;
  18703. t['copyrightserif'] = 790;
  18704. t['trademarkserif'] = 890;
  18705. t['product'] = 823;
  18706. t['radical'] = 549;
  18707. t['dotmath'] = 250;
  18708. t['logicalnot'] = 713;
  18709. t['logicaland'] = 603;
  18710. t['logicalor'] = 603;
  18711. t['arrowdblboth'] = 1042;
  18712. t['arrowdblleft'] = 987;
  18713. t['arrowdblup'] = 603;
  18714. t['arrowdblright'] = 987;
  18715. t['arrowdbldown'] = 603;
  18716. t['lozenge'] = 494;
  18717. t['angleleft'] = 329;
  18718. t['registersans'] = 790;
  18719. t['copyrightsans'] = 790;
  18720. t['trademarksans'] = 786;
  18721. t['summation'] = 713;
  18722. t['parenlefttp'] = 384;
  18723. t['parenleftex'] = 384;
  18724. t['parenleftbt'] = 384;
  18725. t['bracketlefttp'] = 384;
  18726. t['bracketleftex'] = 384;
  18727. t['bracketleftbt'] = 384;
  18728. t['bracelefttp'] = 494;
  18729. t['braceleftmid'] = 494;
  18730. t['braceleftbt'] = 494;
  18731. t['braceex'] = 494;
  18732. t['angleright'] = 329;
  18733. t['integral'] = 274;
  18734. t['integraltp'] = 686;
  18735. t['integralex'] = 686;
  18736. t['integralbt'] = 686;
  18737. t['parenrighttp'] = 384;
  18738. t['parenrightex'] = 384;
  18739. t['parenrightbt'] = 384;
  18740. t['bracketrighttp'] = 384;
  18741. t['bracketrightex'] = 384;
  18742. t['bracketrightbt'] = 384;
  18743. t['bracerighttp'] = 494;
  18744. t['bracerightmid'] = 494;
  18745. t['bracerightbt'] = 494;
  18746. t['apple'] = 790;
  18747. });
  18748. t['Times-Roman'] = getLookupTableFactory(function (t) {
  18749. t['space'] = 250;
  18750. t['exclam'] = 333;
  18751. t['quotedbl'] = 408;
  18752. t['numbersign'] = 500;
  18753. t['dollar'] = 500;
  18754. t['percent'] = 833;
  18755. t['ampersand'] = 778;
  18756. t['quoteright'] = 333;
  18757. t['parenleft'] = 333;
  18758. t['parenright'] = 333;
  18759. t['asterisk'] = 500;
  18760. t['plus'] = 564;
  18761. t['comma'] = 250;
  18762. t['hyphen'] = 333;
  18763. t['period'] = 250;
  18764. t['slash'] = 278;
  18765. t['zero'] = 500;
  18766. t['one'] = 500;
  18767. t['two'] = 500;
  18768. t['three'] = 500;
  18769. t['four'] = 500;
  18770. t['five'] = 500;
  18771. t['six'] = 500;
  18772. t['seven'] = 500;
  18773. t['eight'] = 500;
  18774. t['nine'] = 500;
  18775. t['colon'] = 278;
  18776. t['semicolon'] = 278;
  18777. t['less'] = 564;
  18778. t['equal'] = 564;
  18779. t['greater'] = 564;
  18780. t['question'] = 444;
  18781. t['at'] = 921;
  18782. t['A'] = 722;
  18783. t['B'] = 667;
  18784. t['C'] = 667;
  18785. t['D'] = 722;
  18786. t['E'] = 611;
  18787. t['F'] = 556;
  18788. t['G'] = 722;
  18789. t['H'] = 722;
  18790. t['I'] = 333;
  18791. t['J'] = 389;
  18792. t['K'] = 722;
  18793. t['L'] = 611;
  18794. t['M'] = 889;
  18795. t['N'] = 722;
  18796. t['O'] = 722;
  18797. t['P'] = 556;
  18798. t['Q'] = 722;
  18799. t['R'] = 667;
  18800. t['S'] = 556;
  18801. t['T'] = 611;
  18802. t['U'] = 722;
  18803. t['V'] = 722;
  18804. t['W'] = 944;
  18805. t['X'] = 722;
  18806. t['Y'] = 722;
  18807. t['Z'] = 611;
  18808. t['bracketleft'] = 333;
  18809. t['backslash'] = 278;
  18810. t['bracketright'] = 333;
  18811. t['asciicircum'] = 469;
  18812. t['underscore'] = 500;
  18813. t['quoteleft'] = 333;
  18814. t['a'] = 444;
  18815. t['b'] = 500;
  18816. t['c'] = 444;
  18817. t['d'] = 500;
  18818. t['e'] = 444;
  18819. t['f'] = 333;
  18820. t['g'] = 500;
  18821. t['h'] = 500;
  18822. t['i'] = 278;
  18823. t['j'] = 278;
  18824. t['k'] = 500;
  18825. t['l'] = 278;
  18826. t['m'] = 778;
  18827. t['n'] = 500;
  18828. t['o'] = 500;
  18829. t['p'] = 500;
  18830. t['q'] = 500;
  18831. t['r'] = 333;
  18832. t['s'] = 389;
  18833. t['t'] = 278;
  18834. t['u'] = 500;
  18835. t['v'] = 500;
  18836. t['w'] = 722;
  18837. t['x'] = 500;
  18838. t['y'] = 500;
  18839. t['z'] = 444;
  18840. t['braceleft'] = 480;
  18841. t['bar'] = 200;
  18842. t['braceright'] = 480;
  18843. t['asciitilde'] = 541;
  18844. t['exclamdown'] = 333;
  18845. t['cent'] = 500;
  18846. t['sterling'] = 500;
  18847. t['fraction'] = 167;
  18848. t['yen'] = 500;
  18849. t['florin'] = 500;
  18850. t['section'] = 500;
  18851. t['currency'] = 500;
  18852. t['quotesingle'] = 180;
  18853. t['quotedblleft'] = 444;
  18854. t['guillemotleft'] = 500;
  18855. t['guilsinglleft'] = 333;
  18856. t['guilsinglright'] = 333;
  18857. t['fi'] = 556;
  18858. t['fl'] = 556;
  18859. t['endash'] = 500;
  18860. t['dagger'] = 500;
  18861. t['daggerdbl'] = 500;
  18862. t['periodcentered'] = 250;
  18863. t['paragraph'] = 453;
  18864. t['bullet'] = 350;
  18865. t['quotesinglbase'] = 333;
  18866. t['quotedblbase'] = 444;
  18867. t['quotedblright'] = 444;
  18868. t['guillemotright'] = 500;
  18869. t['ellipsis'] = 1000;
  18870. t['perthousand'] = 1000;
  18871. t['questiondown'] = 444;
  18872. t['grave'] = 333;
  18873. t['acute'] = 333;
  18874. t['circumflex'] = 333;
  18875. t['tilde'] = 333;
  18876. t['macron'] = 333;
  18877. t['breve'] = 333;
  18878. t['dotaccent'] = 333;
  18879. t['dieresis'] = 333;
  18880. t['ring'] = 333;
  18881. t['cedilla'] = 333;
  18882. t['hungarumlaut'] = 333;
  18883. t['ogonek'] = 333;
  18884. t['caron'] = 333;
  18885. t['emdash'] = 1000;
  18886. t['AE'] = 889;
  18887. t['ordfeminine'] = 276;
  18888. t['Lslash'] = 611;
  18889. t['Oslash'] = 722;
  18890. t['OE'] = 889;
  18891. t['ordmasculine'] = 310;
  18892. t['ae'] = 667;
  18893. t['dotlessi'] = 278;
  18894. t['lslash'] = 278;
  18895. t['oslash'] = 500;
  18896. t['oe'] = 722;
  18897. t['germandbls'] = 500;
  18898. t['Idieresis'] = 333;
  18899. t['eacute'] = 444;
  18900. t['abreve'] = 444;
  18901. t['uhungarumlaut'] = 500;
  18902. t['ecaron'] = 444;
  18903. t['Ydieresis'] = 722;
  18904. t['divide'] = 564;
  18905. t['Yacute'] = 722;
  18906. t['Acircumflex'] = 722;
  18907. t['aacute'] = 444;
  18908. t['Ucircumflex'] = 722;
  18909. t['yacute'] = 500;
  18910. t['scommaaccent'] = 389;
  18911. t['ecircumflex'] = 444;
  18912. t['Uring'] = 722;
  18913. t['Udieresis'] = 722;
  18914. t['aogonek'] = 444;
  18915. t['Uacute'] = 722;
  18916. t['uogonek'] = 500;
  18917. t['Edieresis'] = 611;
  18918. t['Dcroat'] = 722;
  18919. t['commaaccent'] = 250;
  18920. t['copyright'] = 760;
  18921. t['Emacron'] = 611;
  18922. t['ccaron'] = 444;
  18923. t['aring'] = 444;
  18924. t['Ncommaaccent'] = 722;
  18925. t['lacute'] = 278;
  18926. t['agrave'] = 444;
  18927. t['Tcommaaccent'] = 611;
  18928. t['Cacute'] = 667;
  18929. t['atilde'] = 444;
  18930. t['Edotaccent'] = 611;
  18931. t['scaron'] = 389;
  18932. t['scedilla'] = 389;
  18933. t['iacute'] = 278;
  18934. t['lozenge'] = 471;
  18935. t['Rcaron'] = 667;
  18936. t['Gcommaaccent'] = 722;
  18937. t['ucircumflex'] = 500;
  18938. t['acircumflex'] = 444;
  18939. t['Amacron'] = 722;
  18940. t['rcaron'] = 333;
  18941. t['ccedilla'] = 444;
  18942. t['Zdotaccent'] = 611;
  18943. t['Thorn'] = 556;
  18944. t['Omacron'] = 722;
  18945. t['Racute'] = 667;
  18946. t['Sacute'] = 556;
  18947. t['dcaron'] = 588;
  18948. t['Umacron'] = 722;
  18949. t['uring'] = 500;
  18950. t['threesuperior'] = 300;
  18951. t['Ograve'] = 722;
  18952. t['Agrave'] = 722;
  18953. t['Abreve'] = 722;
  18954. t['multiply'] = 564;
  18955. t['uacute'] = 500;
  18956. t['Tcaron'] = 611;
  18957. t['partialdiff'] = 476;
  18958. t['ydieresis'] = 500;
  18959. t['Nacute'] = 722;
  18960. t['icircumflex'] = 278;
  18961. t['Ecircumflex'] = 611;
  18962. t['adieresis'] = 444;
  18963. t['edieresis'] = 444;
  18964. t['cacute'] = 444;
  18965. t['nacute'] = 500;
  18966. t['umacron'] = 500;
  18967. t['Ncaron'] = 722;
  18968. t['Iacute'] = 333;
  18969. t['plusminus'] = 564;
  18970. t['brokenbar'] = 200;
  18971. t['registered'] = 760;
  18972. t['Gbreve'] = 722;
  18973. t['Idotaccent'] = 333;
  18974. t['summation'] = 600;
  18975. t['Egrave'] = 611;
  18976. t['racute'] = 333;
  18977. t['omacron'] = 500;
  18978. t['Zacute'] = 611;
  18979. t['Zcaron'] = 611;
  18980. t['greaterequal'] = 549;
  18981. t['Eth'] = 722;
  18982. t['Ccedilla'] = 667;
  18983. t['lcommaaccent'] = 278;
  18984. t['tcaron'] = 326;
  18985. t['eogonek'] = 444;
  18986. t['Uogonek'] = 722;
  18987. t['Aacute'] = 722;
  18988. t['Adieresis'] = 722;
  18989. t['egrave'] = 444;
  18990. t['zacute'] = 444;
  18991. t['iogonek'] = 278;
  18992. t['Oacute'] = 722;
  18993. t['oacute'] = 500;
  18994. t['amacron'] = 444;
  18995. t['sacute'] = 389;
  18996. t['idieresis'] = 278;
  18997. t['Ocircumflex'] = 722;
  18998. t['Ugrave'] = 722;
  18999. t['Delta'] = 612;
  19000. t['thorn'] = 500;
  19001. t['twosuperior'] = 300;
  19002. t['Odieresis'] = 722;
  19003. t['mu'] = 500;
  19004. t['igrave'] = 278;
  19005. t['ohungarumlaut'] = 500;
  19006. t['Eogonek'] = 611;
  19007. t['dcroat'] = 500;
  19008. t['threequarters'] = 750;
  19009. t['Scedilla'] = 556;
  19010. t['lcaron'] = 344;
  19011. t['Kcommaaccent'] = 722;
  19012. t['Lacute'] = 611;
  19013. t['trademark'] = 980;
  19014. t['edotaccent'] = 444;
  19015. t['Igrave'] = 333;
  19016. t['Imacron'] = 333;
  19017. t['Lcaron'] = 611;
  19018. t['onehalf'] = 750;
  19019. t['lessequal'] = 549;
  19020. t['ocircumflex'] = 500;
  19021. t['ntilde'] = 500;
  19022. t['Uhungarumlaut'] = 722;
  19023. t['Eacute'] = 611;
  19024. t['emacron'] = 444;
  19025. t['gbreve'] = 500;
  19026. t['onequarter'] = 750;
  19027. t['Scaron'] = 556;
  19028. t['Scommaaccent'] = 556;
  19029. t['Ohungarumlaut'] = 722;
  19030. t['degree'] = 400;
  19031. t['ograve'] = 500;
  19032. t['Ccaron'] = 667;
  19033. t['ugrave'] = 500;
  19034. t['radical'] = 453;
  19035. t['Dcaron'] = 722;
  19036. t['rcommaaccent'] = 333;
  19037. t['Ntilde'] = 722;
  19038. t['otilde'] = 500;
  19039. t['Rcommaaccent'] = 667;
  19040. t['Lcommaaccent'] = 611;
  19041. t['Atilde'] = 722;
  19042. t['Aogonek'] = 722;
  19043. t['Aring'] = 722;
  19044. t['Otilde'] = 722;
  19045. t['zdotaccent'] = 444;
  19046. t['Ecaron'] = 611;
  19047. t['Iogonek'] = 333;
  19048. t['kcommaaccent'] = 500;
  19049. t['minus'] = 564;
  19050. t['Icircumflex'] = 333;
  19051. t['ncaron'] = 500;
  19052. t['tcommaaccent'] = 278;
  19053. t['logicalnot'] = 564;
  19054. t['odieresis'] = 500;
  19055. t['udieresis'] = 500;
  19056. t['notequal'] = 549;
  19057. t['gcommaaccent'] = 500;
  19058. t['eth'] = 500;
  19059. t['zcaron'] = 444;
  19060. t['ncommaaccent'] = 500;
  19061. t['onesuperior'] = 300;
  19062. t['imacron'] = 278;
  19063. t['Euro'] = 500;
  19064. });
  19065. t['Times-Bold'] = getLookupTableFactory(function (t) {
  19066. t['space'] = 250;
  19067. t['exclam'] = 333;
  19068. t['quotedbl'] = 555;
  19069. t['numbersign'] = 500;
  19070. t['dollar'] = 500;
  19071. t['percent'] = 1000;
  19072. t['ampersand'] = 833;
  19073. t['quoteright'] = 333;
  19074. t['parenleft'] = 333;
  19075. t['parenright'] = 333;
  19076. t['asterisk'] = 500;
  19077. t['plus'] = 570;
  19078. t['comma'] = 250;
  19079. t['hyphen'] = 333;
  19080. t['period'] = 250;
  19081. t['slash'] = 278;
  19082. t['zero'] = 500;
  19083. t['one'] = 500;
  19084. t['two'] = 500;
  19085. t['three'] = 500;
  19086. t['four'] = 500;
  19087. t['five'] = 500;
  19088. t['six'] = 500;
  19089. t['seven'] = 500;
  19090. t['eight'] = 500;
  19091. t['nine'] = 500;
  19092. t['colon'] = 333;
  19093. t['semicolon'] = 333;
  19094. t['less'] = 570;
  19095. t['equal'] = 570;
  19096. t['greater'] = 570;
  19097. t['question'] = 500;
  19098. t['at'] = 930;
  19099. t['A'] = 722;
  19100. t['B'] = 667;
  19101. t['C'] = 722;
  19102. t['D'] = 722;
  19103. t['E'] = 667;
  19104. t['F'] = 611;
  19105. t['G'] = 778;
  19106. t['H'] = 778;
  19107. t['I'] = 389;
  19108. t['J'] = 500;
  19109. t['K'] = 778;
  19110. t['L'] = 667;
  19111. t['M'] = 944;
  19112. t['N'] = 722;
  19113. t['O'] = 778;
  19114. t['P'] = 611;
  19115. t['Q'] = 778;
  19116. t['R'] = 722;
  19117. t['S'] = 556;
  19118. t['T'] = 667;
  19119. t['U'] = 722;
  19120. t['V'] = 722;
  19121. t['W'] = 1000;
  19122. t['X'] = 722;
  19123. t['Y'] = 722;
  19124. t['Z'] = 667;
  19125. t['bracketleft'] = 333;
  19126. t['backslash'] = 278;
  19127. t['bracketright'] = 333;
  19128. t['asciicircum'] = 581;
  19129. t['underscore'] = 500;
  19130. t['quoteleft'] = 333;
  19131. t['a'] = 500;
  19132. t['b'] = 556;
  19133. t['c'] = 444;
  19134. t['d'] = 556;
  19135. t['e'] = 444;
  19136. t['f'] = 333;
  19137. t['g'] = 500;
  19138. t['h'] = 556;
  19139. t['i'] = 278;
  19140. t['j'] = 333;
  19141. t['k'] = 556;
  19142. t['l'] = 278;
  19143. t['m'] = 833;
  19144. t['n'] = 556;
  19145. t['o'] = 500;
  19146. t['p'] = 556;
  19147. t['q'] = 556;
  19148. t['r'] = 444;
  19149. t['s'] = 389;
  19150. t['t'] = 333;
  19151. t['u'] = 556;
  19152. t['v'] = 500;
  19153. t['w'] = 722;
  19154. t['x'] = 500;
  19155. t['y'] = 500;
  19156. t['z'] = 444;
  19157. t['braceleft'] = 394;
  19158. t['bar'] = 220;
  19159. t['braceright'] = 394;
  19160. t['asciitilde'] = 520;
  19161. t['exclamdown'] = 333;
  19162. t['cent'] = 500;
  19163. t['sterling'] = 500;
  19164. t['fraction'] = 167;
  19165. t['yen'] = 500;
  19166. t['florin'] = 500;
  19167. t['section'] = 500;
  19168. t['currency'] = 500;
  19169. t['quotesingle'] = 278;
  19170. t['quotedblleft'] = 500;
  19171. t['guillemotleft'] = 500;
  19172. t['guilsinglleft'] = 333;
  19173. t['guilsinglright'] = 333;
  19174. t['fi'] = 556;
  19175. t['fl'] = 556;
  19176. t['endash'] = 500;
  19177. t['dagger'] = 500;
  19178. t['daggerdbl'] = 500;
  19179. t['periodcentered'] = 250;
  19180. t['paragraph'] = 540;
  19181. t['bullet'] = 350;
  19182. t['quotesinglbase'] = 333;
  19183. t['quotedblbase'] = 500;
  19184. t['quotedblright'] = 500;
  19185. t['guillemotright'] = 500;
  19186. t['ellipsis'] = 1000;
  19187. t['perthousand'] = 1000;
  19188. t['questiondown'] = 500;
  19189. t['grave'] = 333;
  19190. t['acute'] = 333;
  19191. t['circumflex'] = 333;
  19192. t['tilde'] = 333;
  19193. t['macron'] = 333;
  19194. t['breve'] = 333;
  19195. t['dotaccent'] = 333;
  19196. t['dieresis'] = 333;
  19197. t['ring'] = 333;
  19198. t['cedilla'] = 333;
  19199. t['hungarumlaut'] = 333;
  19200. t['ogonek'] = 333;
  19201. t['caron'] = 333;
  19202. t['emdash'] = 1000;
  19203. t['AE'] = 1000;
  19204. t['ordfeminine'] = 300;
  19205. t['Lslash'] = 667;
  19206. t['Oslash'] = 778;
  19207. t['OE'] = 1000;
  19208. t['ordmasculine'] = 330;
  19209. t['ae'] = 722;
  19210. t['dotlessi'] = 278;
  19211. t['lslash'] = 278;
  19212. t['oslash'] = 500;
  19213. t['oe'] = 722;
  19214. t['germandbls'] = 556;
  19215. t['Idieresis'] = 389;
  19216. t['eacute'] = 444;
  19217. t['abreve'] = 500;
  19218. t['uhungarumlaut'] = 556;
  19219. t['ecaron'] = 444;
  19220. t['Ydieresis'] = 722;
  19221. t['divide'] = 570;
  19222. t['Yacute'] = 722;
  19223. t['Acircumflex'] = 722;
  19224. t['aacute'] = 500;
  19225. t['Ucircumflex'] = 722;
  19226. t['yacute'] = 500;
  19227. t['scommaaccent'] = 389;
  19228. t['ecircumflex'] = 444;
  19229. t['Uring'] = 722;
  19230. t['Udieresis'] = 722;
  19231. t['aogonek'] = 500;
  19232. t['Uacute'] = 722;
  19233. t['uogonek'] = 556;
  19234. t['Edieresis'] = 667;
  19235. t['Dcroat'] = 722;
  19236. t['commaaccent'] = 250;
  19237. t['copyright'] = 747;
  19238. t['Emacron'] = 667;
  19239. t['ccaron'] = 444;
  19240. t['aring'] = 500;
  19241. t['Ncommaaccent'] = 722;
  19242. t['lacute'] = 278;
  19243. t['agrave'] = 500;
  19244. t['Tcommaaccent'] = 667;
  19245. t['Cacute'] = 722;
  19246. t['atilde'] = 500;
  19247. t['Edotaccent'] = 667;
  19248. t['scaron'] = 389;
  19249. t['scedilla'] = 389;
  19250. t['iacute'] = 278;
  19251. t['lozenge'] = 494;
  19252. t['Rcaron'] = 722;
  19253. t['Gcommaaccent'] = 778;
  19254. t['ucircumflex'] = 556;
  19255. t['acircumflex'] = 500;
  19256. t['Amacron'] = 722;
  19257. t['rcaron'] = 444;
  19258. t['ccedilla'] = 444;
  19259. t['Zdotaccent'] = 667;
  19260. t['Thorn'] = 611;
  19261. t['Omacron'] = 778;
  19262. t['Racute'] = 722;
  19263. t['Sacute'] = 556;
  19264. t['dcaron'] = 672;
  19265. t['Umacron'] = 722;
  19266. t['uring'] = 556;
  19267. t['threesuperior'] = 300;
  19268. t['Ograve'] = 778;
  19269. t['Agrave'] = 722;
  19270. t['Abreve'] = 722;
  19271. t['multiply'] = 570;
  19272. t['uacute'] = 556;
  19273. t['Tcaron'] = 667;
  19274. t['partialdiff'] = 494;
  19275. t['ydieresis'] = 500;
  19276. t['Nacute'] = 722;
  19277. t['icircumflex'] = 278;
  19278. t['Ecircumflex'] = 667;
  19279. t['adieresis'] = 500;
  19280. t['edieresis'] = 444;
  19281. t['cacute'] = 444;
  19282. t['nacute'] = 556;
  19283. t['umacron'] = 556;
  19284. t['Ncaron'] = 722;
  19285. t['Iacute'] = 389;
  19286. t['plusminus'] = 570;
  19287. t['brokenbar'] = 220;
  19288. t['registered'] = 747;
  19289. t['Gbreve'] = 778;
  19290. t['Idotaccent'] = 389;
  19291. t['summation'] = 600;
  19292. t['Egrave'] = 667;
  19293. t['racute'] = 444;
  19294. t['omacron'] = 500;
  19295. t['Zacute'] = 667;
  19296. t['Zcaron'] = 667;
  19297. t['greaterequal'] = 549;
  19298. t['Eth'] = 722;
  19299. t['Ccedilla'] = 722;
  19300. t['lcommaaccent'] = 278;
  19301. t['tcaron'] = 416;
  19302. t['eogonek'] = 444;
  19303. t['Uogonek'] = 722;
  19304. t['Aacute'] = 722;
  19305. t['Adieresis'] = 722;
  19306. t['egrave'] = 444;
  19307. t['zacute'] = 444;
  19308. t['iogonek'] = 278;
  19309. t['Oacute'] = 778;
  19310. t['oacute'] = 500;
  19311. t['amacron'] = 500;
  19312. t['sacute'] = 389;
  19313. t['idieresis'] = 278;
  19314. t['Ocircumflex'] = 778;
  19315. t['Ugrave'] = 722;
  19316. t['Delta'] = 612;
  19317. t['thorn'] = 556;
  19318. t['twosuperior'] = 300;
  19319. t['Odieresis'] = 778;
  19320. t['mu'] = 556;
  19321. t['igrave'] = 278;
  19322. t['ohungarumlaut'] = 500;
  19323. t['Eogonek'] = 667;
  19324. t['dcroat'] = 556;
  19325. t['threequarters'] = 750;
  19326. t['Scedilla'] = 556;
  19327. t['lcaron'] = 394;
  19328. t['Kcommaaccent'] = 778;
  19329. t['Lacute'] = 667;
  19330. t['trademark'] = 1000;
  19331. t['edotaccent'] = 444;
  19332. t['Igrave'] = 389;
  19333. t['Imacron'] = 389;
  19334. t['Lcaron'] = 667;
  19335. t['onehalf'] = 750;
  19336. t['lessequal'] = 549;
  19337. t['ocircumflex'] = 500;
  19338. t['ntilde'] = 556;
  19339. t['Uhungarumlaut'] = 722;
  19340. t['Eacute'] = 667;
  19341. t['emacron'] = 444;
  19342. t['gbreve'] = 500;
  19343. t['onequarter'] = 750;
  19344. t['Scaron'] = 556;
  19345. t['Scommaaccent'] = 556;
  19346. t['Ohungarumlaut'] = 778;
  19347. t['degree'] = 400;
  19348. t['ograve'] = 500;
  19349. t['Ccaron'] = 722;
  19350. t['ugrave'] = 556;
  19351. t['radical'] = 549;
  19352. t['Dcaron'] = 722;
  19353. t['rcommaaccent'] = 444;
  19354. t['Ntilde'] = 722;
  19355. t['otilde'] = 500;
  19356. t['Rcommaaccent'] = 722;
  19357. t['Lcommaaccent'] = 667;
  19358. t['Atilde'] = 722;
  19359. t['Aogonek'] = 722;
  19360. t['Aring'] = 722;
  19361. t['Otilde'] = 778;
  19362. t['zdotaccent'] = 444;
  19363. t['Ecaron'] = 667;
  19364. t['Iogonek'] = 389;
  19365. t['kcommaaccent'] = 556;
  19366. t['minus'] = 570;
  19367. t['Icircumflex'] = 389;
  19368. t['ncaron'] = 556;
  19369. t['tcommaaccent'] = 333;
  19370. t['logicalnot'] = 570;
  19371. t['odieresis'] = 500;
  19372. t['udieresis'] = 556;
  19373. t['notequal'] = 549;
  19374. t['gcommaaccent'] = 500;
  19375. t['eth'] = 500;
  19376. t['zcaron'] = 444;
  19377. t['ncommaaccent'] = 556;
  19378. t['onesuperior'] = 300;
  19379. t['imacron'] = 278;
  19380. t['Euro'] = 500;
  19381. });
  19382. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  19383. t['space'] = 250;
  19384. t['exclam'] = 389;
  19385. t['quotedbl'] = 555;
  19386. t['numbersign'] = 500;
  19387. t['dollar'] = 500;
  19388. t['percent'] = 833;
  19389. t['ampersand'] = 778;
  19390. t['quoteright'] = 333;
  19391. t['parenleft'] = 333;
  19392. t['parenright'] = 333;
  19393. t['asterisk'] = 500;
  19394. t['plus'] = 570;
  19395. t['comma'] = 250;
  19396. t['hyphen'] = 333;
  19397. t['period'] = 250;
  19398. t['slash'] = 278;
  19399. t['zero'] = 500;
  19400. t['one'] = 500;
  19401. t['two'] = 500;
  19402. t['three'] = 500;
  19403. t['four'] = 500;
  19404. t['five'] = 500;
  19405. t['six'] = 500;
  19406. t['seven'] = 500;
  19407. t['eight'] = 500;
  19408. t['nine'] = 500;
  19409. t['colon'] = 333;
  19410. t['semicolon'] = 333;
  19411. t['less'] = 570;
  19412. t['equal'] = 570;
  19413. t['greater'] = 570;
  19414. t['question'] = 500;
  19415. t['at'] = 832;
  19416. t['A'] = 667;
  19417. t['B'] = 667;
  19418. t['C'] = 667;
  19419. t['D'] = 722;
  19420. t['E'] = 667;
  19421. t['F'] = 667;
  19422. t['G'] = 722;
  19423. t['H'] = 778;
  19424. t['I'] = 389;
  19425. t['J'] = 500;
  19426. t['K'] = 667;
  19427. t['L'] = 611;
  19428. t['M'] = 889;
  19429. t['N'] = 722;
  19430. t['O'] = 722;
  19431. t['P'] = 611;
  19432. t['Q'] = 722;
  19433. t['R'] = 667;
  19434. t['S'] = 556;
  19435. t['T'] = 611;
  19436. t['U'] = 722;
  19437. t['V'] = 667;
  19438. t['W'] = 889;
  19439. t['X'] = 667;
  19440. t['Y'] = 611;
  19441. t['Z'] = 611;
  19442. t['bracketleft'] = 333;
  19443. t['backslash'] = 278;
  19444. t['bracketright'] = 333;
  19445. t['asciicircum'] = 570;
  19446. t['underscore'] = 500;
  19447. t['quoteleft'] = 333;
  19448. t['a'] = 500;
  19449. t['b'] = 500;
  19450. t['c'] = 444;
  19451. t['d'] = 500;
  19452. t['e'] = 444;
  19453. t['f'] = 333;
  19454. t['g'] = 500;
  19455. t['h'] = 556;
  19456. t['i'] = 278;
  19457. t['j'] = 278;
  19458. t['k'] = 500;
  19459. t['l'] = 278;
  19460. t['m'] = 778;
  19461. t['n'] = 556;
  19462. t['o'] = 500;
  19463. t['p'] = 500;
  19464. t['q'] = 500;
  19465. t['r'] = 389;
  19466. t['s'] = 389;
  19467. t['t'] = 278;
  19468. t['u'] = 556;
  19469. t['v'] = 444;
  19470. t['w'] = 667;
  19471. t['x'] = 500;
  19472. t['y'] = 444;
  19473. t['z'] = 389;
  19474. t['braceleft'] = 348;
  19475. t['bar'] = 220;
  19476. t['braceright'] = 348;
  19477. t['asciitilde'] = 570;
  19478. t['exclamdown'] = 389;
  19479. t['cent'] = 500;
  19480. t['sterling'] = 500;
  19481. t['fraction'] = 167;
  19482. t['yen'] = 500;
  19483. t['florin'] = 500;
  19484. t['section'] = 500;
  19485. t['currency'] = 500;
  19486. t['quotesingle'] = 278;
  19487. t['quotedblleft'] = 500;
  19488. t['guillemotleft'] = 500;
  19489. t['guilsinglleft'] = 333;
  19490. t['guilsinglright'] = 333;
  19491. t['fi'] = 556;
  19492. t['fl'] = 556;
  19493. t['endash'] = 500;
  19494. t['dagger'] = 500;
  19495. t['daggerdbl'] = 500;
  19496. t['periodcentered'] = 250;
  19497. t['paragraph'] = 500;
  19498. t['bullet'] = 350;
  19499. t['quotesinglbase'] = 333;
  19500. t['quotedblbase'] = 500;
  19501. t['quotedblright'] = 500;
  19502. t['guillemotright'] = 500;
  19503. t['ellipsis'] = 1000;
  19504. t['perthousand'] = 1000;
  19505. t['questiondown'] = 500;
  19506. t['grave'] = 333;
  19507. t['acute'] = 333;
  19508. t['circumflex'] = 333;
  19509. t['tilde'] = 333;
  19510. t['macron'] = 333;
  19511. t['breve'] = 333;
  19512. t['dotaccent'] = 333;
  19513. t['dieresis'] = 333;
  19514. t['ring'] = 333;
  19515. t['cedilla'] = 333;
  19516. t['hungarumlaut'] = 333;
  19517. t['ogonek'] = 333;
  19518. t['caron'] = 333;
  19519. t['emdash'] = 1000;
  19520. t['AE'] = 944;
  19521. t['ordfeminine'] = 266;
  19522. t['Lslash'] = 611;
  19523. t['Oslash'] = 722;
  19524. t['OE'] = 944;
  19525. t['ordmasculine'] = 300;
  19526. t['ae'] = 722;
  19527. t['dotlessi'] = 278;
  19528. t['lslash'] = 278;
  19529. t['oslash'] = 500;
  19530. t['oe'] = 722;
  19531. t['germandbls'] = 500;
  19532. t['Idieresis'] = 389;
  19533. t['eacute'] = 444;
  19534. t['abreve'] = 500;
  19535. t['uhungarumlaut'] = 556;
  19536. t['ecaron'] = 444;
  19537. t['Ydieresis'] = 611;
  19538. t['divide'] = 570;
  19539. t['Yacute'] = 611;
  19540. t['Acircumflex'] = 667;
  19541. t['aacute'] = 500;
  19542. t['Ucircumflex'] = 722;
  19543. t['yacute'] = 444;
  19544. t['scommaaccent'] = 389;
  19545. t['ecircumflex'] = 444;
  19546. t['Uring'] = 722;
  19547. t['Udieresis'] = 722;
  19548. t['aogonek'] = 500;
  19549. t['Uacute'] = 722;
  19550. t['uogonek'] = 556;
  19551. t['Edieresis'] = 667;
  19552. t['Dcroat'] = 722;
  19553. t['commaaccent'] = 250;
  19554. t['copyright'] = 747;
  19555. t['Emacron'] = 667;
  19556. t['ccaron'] = 444;
  19557. t['aring'] = 500;
  19558. t['Ncommaaccent'] = 722;
  19559. t['lacute'] = 278;
  19560. t['agrave'] = 500;
  19561. t['Tcommaaccent'] = 611;
  19562. t['Cacute'] = 667;
  19563. t['atilde'] = 500;
  19564. t['Edotaccent'] = 667;
  19565. t['scaron'] = 389;
  19566. t['scedilla'] = 389;
  19567. t['iacute'] = 278;
  19568. t['lozenge'] = 494;
  19569. t['Rcaron'] = 667;
  19570. t['Gcommaaccent'] = 722;
  19571. t['ucircumflex'] = 556;
  19572. t['acircumflex'] = 500;
  19573. t['Amacron'] = 667;
  19574. t['rcaron'] = 389;
  19575. t['ccedilla'] = 444;
  19576. t['Zdotaccent'] = 611;
  19577. t['Thorn'] = 611;
  19578. t['Omacron'] = 722;
  19579. t['Racute'] = 667;
  19580. t['Sacute'] = 556;
  19581. t['dcaron'] = 608;
  19582. t['Umacron'] = 722;
  19583. t['uring'] = 556;
  19584. t['threesuperior'] = 300;
  19585. t['Ograve'] = 722;
  19586. t['Agrave'] = 667;
  19587. t['Abreve'] = 667;
  19588. t['multiply'] = 570;
  19589. t['uacute'] = 556;
  19590. t['Tcaron'] = 611;
  19591. t['partialdiff'] = 494;
  19592. t['ydieresis'] = 444;
  19593. t['Nacute'] = 722;
  19594. t['icircumflex'] = 278;
  19595. t['Ecircumflex'] = 667;
  19596. t['adieresis'] = 500;
  19597. t['edieresis'] = 444;
  19598. t['cacute'] = 444;
  19599. t['nacute'] = 556;
  19600. t['umacron'] = 556;
  19601. t['Ncaron'] = 722;
  19602. t['Iacute'] = 389;
  19603. t['plusminus'] = 570;
  19604. t['brokenbar'] = 220;
  19605. t['registered'] = 747;
  19606. t['Gbreve'] = 722;
  19607. t['Idotaccent'] = 389;
  19608. t['summation'] = 600;
  19609. t['Egrave'] = 667;
  19610. t['racute'] = 389;
  19611. t['omacron'] = 500;
  19612. t['Zacute'] = 611;
  19613. t['Zcaron'] = 611;
  19614. t['greaterequal'] = 549;
  19615. t['Eth'] = 722;
  19616. t['Ccedilla'] = 667;
  19617. t['lcommaaccent'] = 278;
  19618. t['tcaron'] = 366;
  19619. t['eogonek'] = 444;
  19620. t['Uogonek'] = 722;
  19621. t['Aacute'] = 667;
  19622. t['Adieresis'] = 667;
  19623. t['egrave'] = 444;
  19624. t['zacute'] = 389;
  19625. t['iogonek'] = 278;
  19626. t['Oacute'] = 722;
  19627. t['oacute'] = 500;
  19628. t['amacron'] = 500;
  19629. t['sacute'] = 389;
  19630. t['idieresis'] = 278;
  19631. t['Ocircumflex'] = 722;
  19632. t['Ugrave'] = 722;
  19633. t['Delta'] = 612;
  19634. t['thorn'] = 500;
  19635. t['twosuperior'] = 300;
  19636. t['Odieresis'] = 722;
  19637. t['mu'] = 576;
  19638. t['igrave'] = 278;
  19639. t['ohungarumlaut'] = 500;
  19640. t['Eogonek'] = 667;
  19641. t['dcroat'] = 500;
  19642. t['threequarters'] = 750;
  19643. t['Scedilla'] = 556;
  19644. t['lcaron'] = 382;
  19645. t['Kcommaaccent'] = 667;
  19646. t['Lacute'] = 611;
  19647. t['trademark'] = 1000;
  19648. t['edotaccent'] = 444;
  19649. t['Igrave'] = 389;
  19650. t['Imacron'] = 389;
  19651. t['Lcaron'] = 611;
  19652. t['onehalf'] = 750;
  19653. t['lessequal'] = 549;
  19654. t['ocircumflex'] = 500;
  19655. t['ntilde'] = 556;
  19656. t['Uhungarumlaut'] = 722;
  19657. t['Eacute'] = 667;
  19658. t['emacron'] = 444;
  19659. t['gbreve'] = 500;
  19660. t['onequarter'] = 750;
  19661. t['Scaron'] = 556;
  19662. t['Scommaaccent'] = 556;
  19663. t['Ohungarumlaut'] = 722;
  19664. t['degree'] = 400;
  19665. t['ograve'] = 500;
  19666. t['Ccaron'] = 667;
  19667. t['ugrave'] = 556;
  19668. t['radical'] = 549;
  19669. t['Dcaron'] = 722;
  19670. t['rcommaaccent'] = 389;
  19671. t['Ntilde'] = 722;
  19672. t['otilde'] = 500;
  19673. t['Rcommaaccent'] = 667;
  19674. t['Lcommaaccent'] = 611;
  19675. t['Atilde'] = 667;
  19676. t['Aogonek'] = 667;
  19677. t['Aring'] = 667;
  19678. t['Otilde'] = 722;
  19679. t['zdotaccent'] = 389;
  19680. t['Ecaron'] = 667;
  19681. t['Iogonek'] = 389;
  19682. t['kcommaaccent'] = 500;
  19683. t['minus'] = 606;
  19684. t['Icircumflex'] = 389;
  19685. t['ncaron'] = 556;
  19686. t['tcommaaccent'] = 278;
  19687. t['logicalnot'] = 606;
  19688. t['odieresis'] = 500;
  19689. t['udieresis'] = 556;
  19690. t['notequal'] = 549;
  19691. t['gcommaaccent'] = 500;
  19692. t['eth'] = 500;
  19693. t['zcaron'] = 389;
  19694. t['ncommaaccent'] = 556;
  19695. t['onesuperior'] = 300;
  19696. t['imacron'] = 278;
  19697. t['Euro'] = 500;
  19698. });
  19699. t['Times-Italic'] = getLookupTableFactory(function (t) {
  19700. t['space'] = 250;
  19701. t['exclam'] = 333;
  19702. t['quotedbl'] = 420;
  19703. t['numbersign'] = 500;
  19704. t['dollar'] = 500;
  19705. t['percent'] = 833;
  19706. t['ampersand'] = 778;
  19707. t['quoteright'] = 333;
  19708. t['parenleft'] = 333;
  19709. t['parenright'] = 333;
  19710. t['asterisk'] = 500;
  19711. t['plus'] = 675;
  19712. t['comma'] = 250;
  19713. t['hyphen'] = 333;
  19714. t['period'] = 250;
  19715. t['slash'] = 278;
  19716. t['zero'] = 500;
  19717. t['one'] = 500;
  19718. t['two'] = 500;
  19719. t['three'] = 500;
  19720. t['four'] = 500;
  19721. t['five'] = 500;
  19722. t['six'] = 500;
  19723. t['seven'] = 500;
  19724. t['eight'] = 500;
  19725. t['nine'] = 500;
  19726. t['colon'] = 333;
  19727. t['semicolon'] = 333;
  19728. t['less'] = 675;
  19729. t['equal'] = 675;
  19730. t['greater'] = 675;
  19731. t['question'] = 500;
  19732. t['at'] = 920;
  19733. t['A'] = 611;
  19734. t['B'] = 611;
  19735. t['C'] = 667;
  19736. t['D'] = 722;
  19737. t['E'] = 611;
  19738. t['F'] = 611;
  19739. t['G'] = 722;
  19740. t['H'] = 722;
  19741. t['I'] = 333;
  19742. t['J'] = 444;
  19743. t['K'] = 667;
  19744. t['L'] = 556;
  19745. t['M'] = 833;
  19746. t['N'] = 667;
  19747. t['O'] = 722;
  19748. t['P'] = 611;
  19749. t['Q'] = 722;
  19750. t['R'] = 611;
  19751. t['S'] = 500;
  19752. t['T'] = 556;
  19753. t['U'] = 722;
  19754. t['V'] = 611;
  19755. t['W'] = 833;
  19756. t['X'] = 611;
  19757. t['Y'] = 556;
  19758. t['Z'] = 556;
  19759. t['bracketleft'] = 389;
  19760. t['backslash'] = 278;
  19761. t['bracketright'] = 389;
  19762. t['asciicircum'] = 422;
  19763. t['underscore'] = 500;
  19764. t['quoteleft'] = 333;
  19765. t['a'] = 500;
  19766. t['b'] = 500;
  19767. t['c'] = 444;
  19768. t['d'] = 500;
  19769. t['e'] = 444;
  19770. t['f'] = 278;
  19771. t['g'] = 500;
  19772. t['h'] = 500;
  19773. t['i'] = 278;
  19774. t['j'] = 278;
  19775. t['k'] = 444;
  19776. t['l'] = 278;
  19777. t['m'] = 722;
  19778. t['n'] = 500;
  19779. t['o'] = 500;
  19780. t['p'] = 500;
  19781. t['q'] = 500;
  19782. t['r'] = 389;
  19783. t['s'] = 389;
  19784. t['t'] = 278;
  19785. t['u'] = 500;
  19786. t['v'] = 444;
  19787. t['w'] = 667;
  19788. t['x'] = 444;
  19789. t['y'] = 444;
  19790. t['z'] = 389;
  19791. t['braceleft'] = 400;
  19792. t['bar'] = 275;
  19793. t['braceright'] = 400;
  19794. t['asciitilde'] = 541;
  19795. t['exclamdown'] = 389;
  19796. t['cent'] = 500;
  19797. t['sterling'] = 500;
  19798. t['fraction'] = 167;
  19799. t['yen'] = 500;
  19800. t['florin'] = 500;
  19801. t['section'] = 500;
  19802. t['currency'] = 500;
  19803. t['quotesingle'] = 214;
  19804. t['quotedblleft'] = 556;
  19805. t['guillemotleft'] = 500;
  19806. t['guilsinglleft'] = 333;
  19807. t['guilsinglright'] = 333;
  19808. t['fi'] = 500;
  19809. t['fl'] = 500;
  19810. t['endash'] = 500;
  19811. t['dagger'] = 500;
  19812. t['daggerdbl'] = 500;
  19813. t['periodcentered'] = 250;
  19814. t['paragraph'] = 523;
  19815. t['bullet'] = 350;
  19816. t['quotesinglbase'] = 333;
  19817. t['quotedblbase'] = 556;
  19818. t['quotedblright'] = 556;
  19819. t['guillemotright'] = 500;
  19820. t['ellipsis'] = 889;
  19821. t['perthousand'] = 1000;
  19822. t['questiondown'] = 500;
  19823. t['grave'] = 333;
  19824. t['acute'] = 333;
  19825. t['circumflex'] = 333;
  19826. t['tilde'] = 333;
  19827. t['macron'] = 333;
  19828. t['breve'] = 333;
  19829. t['dotaccent'] = 333;
  19830. t['dieresis'] = 333;
  19831. t['ring'] = 333;
  19832. t['cedilla'] = 333;
  19833. t['hungarumlaut'] = 333;
  19834. t['ogonek'] = 333;
  19835. t['caron'] = 333;
  19836. t['emdash'] = 889;
  19837. t['AE'] = 889;
  19838. t['ordfeminine'] = 276;
  19839. t['Lslash'] = 556;
  19840. t['Oslash'] = 722;
  19841. t['OE'] = 944;
  19842. t['ordmasculine'] = 310;
  19843. t['ae'] = 667;
  19844. t['dotlessi'] = 278;
  19845. t['lslash'] = 278;
  19846. t['oslash'] = 500;
  19847. t['oe'] = 667;
  19848. t['germandbls'] = 500;
  19849. t['Idieresis'] = 333;
  19850. t['eacute'] = 444;
  19851. t['abreve'] = 500;
  19852. t['uhungarumlaut'] = 500;
  19853. t['ecaron'] = 444;
  19854. t['Ydieresis'] = 556;
  19855. t['divide'] = 675;
  19856. t['Yacute'] = 556;
  19857. t['Acircumflex'] = 611;
  19858. t['aacute'] = 500;
  19859. t['Ucircumflex'] = 722;
  19860. t['yacute'] = 444;
  19861. t['scommaaccent'] = 389;
  19862. t['ecircumflex'] = 444;
  19863. t['Uring'] = 722;
  19864. t['Udieresis'] = 722;
  19865. t['aogonek'] = 500;
  19866. t['Uacute'] = 722;
  19867. t['uogonek'] = 500;
  19868. t['Edieresis'] = 611;
  19869. t['Dcroat'] = 722;
  19870. t['commaaccent'] = 250;
  19871. t['copyright'] = 760;
  19872. t['Emacron'] = 611;
  19873. t['ccaron'] = 444;
  19874. t['aring'] = 500;
  19875. t['Ncommaaccent'] = 667;
  19876. t['lacute'] = 278;
  19877. t['agrave'] = 500;
  19878. t['Tcommaaccent'] = 556;
  19879. t['Cacute'] = 667;
  19880. t['atilde'] = 500;
  19881. t['Edotaccent'] = 611;
  19882. t['scaron'] = 389;
  19883. t['scedilla'] = 389;
  19884. t['iacute'] = 278;
  19885. t['lozenge'] = 471;
  19886. t['Rcaron'] = 611;
  19887. t['Gcommaaccent'] = 722;
  19888. t['ucircumflex'] = 500;
  19889. t['acircumflex'] = 500;
  19890. t['Amacron'] = 611;
  19891. t['rcaron'] = 389;
  19892. t['ccedilla'] = 444;
  19893. t['Zdotaccent'] = 556;
  19894. t['Thorn'] = 611;
  19895. t['Omacron'] = 722;
  19896. t['Racute'] = 611;
  19897. t['Sacute'] = 500;
  19898. t['dcaron'] = 544;
  19899. t['Umacron'] = 722;
  19900. t['uring'] = 500;
  19901. t['threesuperior'] = 300;
  19902. t['Ograve'] = 722;
  19903. t['Agrave'] = 611;
  19904. t['Abreve'] = 611;
  19905. t['multiply'] = 675;
  19906. t['uacute'] = 500;
  19907. t['Tcaron'] = 556;
  19908. t['partialdiff'] = 476;
  19909. t['ydieresis'] = 444;
  19910. t['Nacute'] = 667;
  19911. t['icircumflex'] = 278;
  19912. t['Ecircumflex'] = 611;
  19913. t['adieresis'] = 500;
  19914. t['edieresis'] = 444;
  19915. t['cacute'] = 444;
  19916. t['nacute'] = 500;
  19917. t['umacron'] = 500;
  19918. t['Ncaron'] = 667;
  19919. t['Iacute'] = 333;
  19920. t['plusminus'] = 675;
  19921. t['brokenbar'] = 275;
  19922. t['registered'] = 760;
  19923. t['Gbreve'] = 722;
  19924. t['Idotaccent'] = 333;
  19925. t['summation'] = 600;
  19926. t['Egrave'] = 611;
  19927. t['racute'] = 389;
  19928. t['omacron'] = 500;
  19929. t['Zacute'] = 556;
  19930. t['Zcaron'] = 556;
  19931. t['greaterequal'] = 549;
  19932. t['Eth'] = 722;
  19933. t['Ccedilla'] = 667;
  19934. t['lcommaaccent'] = 278;
  19935. t['tcaron'] = 300;
  19936. t['eogonek'] = 444;
  19937. t['Uogonek'] = 722;
  19938. t['Aacute'] = 611;
  19939. t['Adieresis'] = 611;
  19940. t['egrave'] = 444;
  19941. t['zacute'] = 389;
  19942. t['iogonek'] = 278;
  19943. t['Oacute'] = 722;
  19944. t['oacute'] = 500;
  19945. t['amacron'] = 500;
  19946. t['sacute'] = 389;
  19947. t['idieresis'] = 278;
  19948. t['Ocircumflex'] = 722;
  19949. t['Ugrave'] = 722;
  19950. t['Delta'] = 612;
  19951. t['thorn'] = 500;
  19952. t['twosuperior'] = 300;
  19953. t['Odieresis'] = 722;
  19954. t['mu'] = 500;
  19955. t['igrave'] = 278;
  19956. t['ohungarumlaut'] = 500;
  19957. t['Eogonek'] = 611;
  19958. t['dcroat'] = 500;
  19959. t['threequarters'] = 750;
  19960. t['Scedilla'] = 500;
  19961. t['lcaron'] = 300;
  19962. t['Kcommaaccent'] = 667;
  19963. t['Lacute'] = 556;
  19964. t['trademark'] = 980;
  19965. t['edotaccent'] = 444;
  19966. t['Igrave'] = 333;
  19967. t['Imacron'] = 333;
  19968. t['Lcaron'] = 611;
  19969. t['onehalf'] = 750;
  19970. t['lessequal'] = 549;
  19971. t['ocircumflex'] = 500;
  19972. t['ntilde'] = 500;
  19973. t['Uhungarumlaut'] = 722;
  19974. t['Eacute'] = 611;
  19975. t['emacron'] = 444;
  19976. t['gbreve'] = 500;
  19977. t['onequarter'] = 750;
  19978. t['Scaron'] = 500;
  19979. t['Scommaaccent'] = 500;
  19980. t['Ohungarumlaut'] = 722;
  19981. t['degree'] = 400;
  19982. t['ograve'] = 500;
  19983. t['Ccaron'] = 667;
  19984. t['ugrave'] = 500;
  19985. t['radical'] = 453;
  19986. t['Dcaron'] = 722;
  19987. t['rcommaaccent'] = 389;
  19988. t['Ntilde'] = 667;
  19989. t['otilde'] = 500;
  19990. t['Rcommaaccent'] = 611;
  19991. t['Lcommaaccent'] = 556;
  19992. t['Atilde'] = 611;
  19993. t['Aogonek'] = 611;
  19994. t['Aring'] = 611;
  19995. t['Otilde'] = 722;
  19996. t['zdotaccent'] = 389;
  19997. t['Ecaron'] = 611;
  19998. t['Iogonek'] = 333;
  19999. t['kcommaaccent'] = 444;
  20000. t['minus'] = 675;
  20001. t['Icircumflex'] = 333;
  20002. t['ncaron'] = 500;
  20003. t['tcommaaccent'] = 278;
  20004. t['logicalnot'] = 675;
  20005. t['odieresis'] = 500;
  20006. t['udieresis'] = 500;
  20007. t['notequal'] = 549;
  20008. t['gcommaaccent'] = 500;
  20009. t['eth'] = 500;
  20010. t['zcaron'] = 389;
  20011. t['ncommaaccent'] = 500;
  20012. t['onesuperior'] = 300;
  20013. t['imacron'] = 278;
  20014. t['Euro'] = 500;
  20015. });
  20016. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  20017. t['space'] = 278;
  20018. t['a1'] = 974;
  20019. t['a2'] = 961;
  20020. t['a202'] = 974;
  20021. t['a3'] = 980;
  20022. t['a4'] = 719;
  20023. t['a5'] = 789;
  20024. t['a119'] = 790;
  20025. t['a118'] = 791;
  20026. t['a117'] = 690;
  20027. t['a11'] = 960;
  20028. t['a12'] = 939;
  20029. t['a13'] = 549;
  20030. t['a14'] = 855;
  20031. t['a15'] = 911;
  20032. t['a16'] = 933;
  20033. t['a105'] = 911;
  20034. t['a17'] = 945;
  20035. t['a18'] = 974;
  20036. t['a19'] = 755;
  20037. t['a20'] = 846;
  20038. t['a21'] = 762;
  20039. t['a22'] = 761;
  20040. t['a23'] = 571;
  20041. t['a24'] = 677;
  20042. t['a25'] = 763;
  20043. t['a26'] = 760;
  20044. t['a27'] = 759;
  20045. t['a28'] = 754;
  20046. t['a6'] = 494;
  20047. t['a7'] = 552;
  20048. t['a8'] = 537;
  20049. t['a9'] = 577;
  20050. t['a10'] = 692;
  20051. t['a29'] = 786;
  20052. t['a30'] = 788;
  20053. t['a31'] = 788;
  20054. t['a32'] = 790;
  20055. t['a33'] = 793;
  20056. t['a34'] = 794;
  20057. t['a35'] = 816;
  20058. t['a36'] = 823;
  20059. t['a37'] = 789;
  20060. t['a38'] = 841;
  20061. t['a39'] = 823;
  20062. t['a40'] = 833;
  20063. t['a41'] = 816;
  20064. t['a42'] = 831;
  20065. t['a43'] = 923;
  20066. t['a44'] = 744;
  20067. t['a45'] = 723;
  20068. t['a46'] = 749;
  20069. t['a47'] = 790;
  20070. t['a48'] = 792;
  20071. t['a49'] = 695;
  20072. t['a50'] = 776;
  20073. t['a51'] = 768;
  20074. t['a52'] = 792;
  20075. t['a53'] = 759;
  20076. t['a54'] = 707;
  20077. t['a55'] = 708;
  20078. t['a56'] = 682;
  20079. t['a57'] = 701;
  20080. t['a58'] = 826;
  20081. t['a59'] = 815;
  20082. t['a60'] = 789;
  20083. t['a61'] = 789;
  20084. t['a62'] = 707;
  20085. t['a63'] = 687;
  20086. t['a64'] = 696;
  20087. t['a65'] = 689;
  20088. t['a66'] = 786;
  20089. t['a67'] = 787;
  20090. t['a68'] = 713;
  20091. t['a69'] = 791;
  20092. t['a70'] = 785;
  20093. t['a71'] = 791;
  20094. t['a72'] = 873;
  20095. t['a73'] = 761;
  20096. t['a74'] = 762;
  20097. t['a203'] = 762;
  20098. t['a75'] = 759;
  20099. t['a204'] = 759;
  20100. t['a76'] = 892;
  20101. t['a77'] = 892;
  20102. t['a78'] = 788;
  20103. t['a79'] = 784;
  20104. t['a81'] = 438;
  20105. t['a82'] = 138;
  20106. t['a83'] = 277;
  20107. t['a84'] = 415;
  20108. t['a97'] = 392;
  20109. t['a98'] = 392;
  20110. t['a99'] = 668;
  20111. t['a100'] = 668;
  20112. t['a89'] = 390;
  20113. t['a90'] = 390;
  20114. t['a93'] = 317;
  20115. t['a94'] = 317;
  20116. t['a91'] = 276;
  20117. t['a92'] = 276;
  20118. t['a205'] = 509;
  20119. t['a85'] = 509;
  20120. t['a206'] = 410;
  20121. t['a86'] = 410;
  20122. t['a87'] = 234;
  20123. t['a88'] = 234;
  20124. t['a95'] = 334;
  20125. t['a96'] = 334;
  20126. t['a101'] = 732;
  20127. t['a102'] = 544;
  20128. t['a103'] = 544;
  20129. t['a104'] = 910;
  20130. t['a106'] = 667;
  20131. t['a107'] = 760;
  20132. t['a108'] = 760;
  20133. t['a112'] = 776;
  20134. t['a111'] = 595;
  20135. t['a110'] = 694;
  20136. t['a109'] = 626;
  20137. t['a120'] = 788;
  20138. t['a121'] = 788;
  20139. t['a122'] = 788;
  20140. t['a123'] = 788;
  20141. t['a124'] = 788;
  20142. t['a125'] = 788;
  20143. t['a126'] = 788;
  20144. t['a127'] = 788;
  20145. t['a128'] = 788;
  20146. t['a129'] = 788;
  20147. t['a130'] = 788;
  20148. t['a131'] = 788;
  20149. t['a132'] = 788;
  20150. t['a133'] = 788;
  20151. t['a134'] = 788;
  20152. t['a135'] = 788;
  20153. t['a136'] = 788;
  20154. t['a137'] = 788;
  20155. t['a138'] = 788;
  20156. t['a139'] = 788;
  20157. t['a140'] = 788;
  20158. t['a141'] = 788;
  20159. t['a142'] = 788;
  20160. t['a143'] = 788;
  20161. t['a144'] = 788;
  20162. t['a145'] = 788;
  20163. t['a146'] = 788;
  20164. t['a147'] = 788;
  20165. t['a148'] = 788;
  20166. t['a149'] = 788;
  20167. t['a150'] = 788;
  20168. t['a151'] = 788;
  20169. t['a152'] = 788;
  20170. t['a153'] = 788;
  20171. t['a154'] = 788;
  20172. t['a155'] = 788;
  20173. t['a156'] = 788;
  20174. t['a157'] = 788;
  20175. t['a158'] = 788;
  20176. t['a159'] = 788;
  20177. t['a160'] = 894;
  20178. t['a161'] = 838;
  20179. t['a163'] = 1016;
  20180. t['a164'] = 458;
  20181. t['a196'] = 748;
  20182. t['a165'] = 924;
  20183. t['a192'] = 748;
  20184. t['a166'] = 918;
  20185. t['a167'] = 927;
  20186. t['a168'] = 928;
  20187. t['a169'] = 928;
  20188. t['a170'] = 834;
  20189. t['a171'] = 873;
  20190. t['a172'] = 828;
  20191. t['a173'] = 924;
  20192. t['a162'] = 924;
  20193. t['a174'] = 917;
  20194. t['a175'] = 930;
  20195. t['a176'] = 931;
  20196. t['a177'] = 463;
  20197. t['a178'] = 883;
  20198. t['a179'] = 836;
  20199. t['a193'] = 836;
  20200. t['a180'] = 867;
  20201. t['a199'] = 867;
  20202. t['a181'] = 696;
  20203. t['a200'] = 696;
  20204. t['a182'] = 874;
  20205. t['a201'] = 874;
  20206. t['a183'] = 760;
  20207. t['a184'] = 946;
  20208. t['a197'] = 771;
  20209. t['a185'] = 865;
  20210. t['a194'] = 771;
  20211. t['a198'] = 888;
  20212. t['a186'] = 967;
  20213. t['a195'] = 888;
  20214. t['a187'] = 831;
  20215. t['a188'] = 873;
  20216. t['a189'] = 927;
  20217. t['a190'] = 970;
  20218. t['a191'] = 918;
  20219. });
  20220. });
  20221. exports.getMetrics = getMetrics;
  20222. }));
  20223. (function (root, factory) {
  20224. factory(root.pdfjsCoreMurmurHash3 = {}, root.pdfjsSharedUtil);
  20225. }(this, function (exports, sharedUtil) {
  20226. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  20227. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  20228. var MASK_HIGH = 0xffff0000;
  20229. var MASK_LOW = 0xffff;
  20230. function MurmurHash3_64(seed) {
  20231. var SEED = 0xc3d2e1f0;
  20232. this.h1 = seed ? seed & 0xffffffff : SEED;
  20233. this.h2 = seed ? seed & 0xffffffff : SEED;
  20234. }
  20235. var alwaysUseUint32ArrayView = false;
  20236. try {
  20237. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  20238. } catch (e) {
  20239. alwaysUseUint32ArrayView = true;
  20240. }
  20241. MurmurHash3_64.prototype = {
  20242. update: function MurmurHash3_64_update(input) {
  20243. var useUint32ArrayView = alwaysUseUint32ArrayView;
  20244. var i;
  20245. if (typeof input === 'string') {
  20246. var data = new Uint8Array(input.length * 2);
  20247. var length = 0;
  20248. for (i = 0; i < input.length; i++) {
  20249. var code = input.charCodeAt(i);
  20250. if (code <= 0xff) {
  20251. data[length++] = code;
  20252. } else {
  20253. data[length++] = code >>> 8;
  20254. data[length++] = code & 0xff;
  20255. }
  20256. }
  20257. } else if (input instanceof Uint8Array) {
  20258. data = input;
  20259. length = data.length;
  20260. } else if (typeof input === 'object' && 'length' in input) {
  20261. data = input;
  20262. length = data.length;
  20263. useUint32ArrayView = true;
  20264. } else {
  20265. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  20266. }
  20267. var blockCounts = length >> 2;
  20268. var tailLength = length - blockCounts * 4;
  20269. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  20270. var k1 = 0;
  20271. var k2 = 0;
  20272. var h1 = this.h1;
  20273. var h2 = this.h2;
  20274. var C1 = 0xcc9e2d51;
  20275. var C2 = 0x1b873593;
  20276. var C1_LOW = C1 & MASK_LOW;
  20277. var C2_LOW = C2 & MASK_LOW;
  20278. for (i = 0; i < blockCounts; i++) {
  20279. if (i & 1) {
  20280. k1 = dataUint32[i];
  20281. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20282. k1 = k1 << 15 | k1 >>> 17;
  20283. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20284. h1 ^= k1;
  20285. h1 = h1 << 13 | h1 >>> 19;
  20286. h1 = h1 * 5 + 0xe6546b64;
  20287. } else {
  20288. k2 = dataUint32[i];
  20289. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  20290. k2 = k2 << 15 | k2 >>> 17;
  20291. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  20292. h2 ^= k2;
  20293. h2 = h2 << 13 | h2 >>> 19;
  20294. h2 = h2 * 5 + 0xe6546b64;
  20295. }
  20296. }
  20297. k1 = 0;
  20298. switch (tailLength) {
  20299. case 3:
  20300. k1 ^= data[blockCounts * 4 + 2] << 16;
  20301. case 2:
  20302. k1 ^= data[blockCounts * 4 + 1] << 8;
  20303. case 1:
  20304. k1 ^= data[blockCounts * 4];
  20305. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20306. k1 = k1 << 15 | k1 >>> 17;
  20307. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20308. if (blockCounts & 1) {
  20309. h1 ^= k1;
  20310. } else {
  20311. h2 ^= k1;
  20312. }
  20313. }
  20314. this.h1 = h1;
  20315. this.h2 = h2;
  20316. return this;
  20317. },
  20318. hexdigest: function MurmurHash3_64_hexdigest() {
  20319. var h1 = this.h1;
  20320. var h2 = this.h2;
  20321. h1 ^= h2 >>> 1;
  20322. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  20323. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  20324. h1 ^= h2 >>> 1;
  20325. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  20326. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  20327. h1 ^= h2 >>> 1;
  20328. for (var i = 0, arr = [
  20329. h1,
  20330. h2
  20331. ], str = ''; i < arr.length; i++) {
  20332. var hex = (arr[i] >>> 0).toString(16);
  20333. while (hex.length < 8) {
  20334. hex = '0' + hex;
  20335. }
  20336. str += hex;
  20337. }
  20338. return str;
  20339. }
  20340. };
  20341. return MurmurHash3_64;
  20342. }();
  20343. exports.MurmurHash3_64 = MurmurHash3_64;
  20344. }));
  20345. (function (root, factory) {
  20346. factory(root.pdfjsCorePrimitives = {}, root.pdfjsSharedUtil);
  20347. }(this, function (exports, sharedUtil) {
  20348. var isArray = sharedUtil.isArray;
  20349. var Name = function NameClosure() {
  20350. function Name(name) {
  20351. this.name = name;
  20352. }
  20353. Name.prototype = {};
  20354. var nameCache = Object.create(null);
  20355. Name.get = function Name_get(name) {
  20356. var nameValue = nameCache[name];
  20357. return nameValue ? nameValue : nameCache[name] = new Name(name);
  20358. };
  20359. return Name;
  20360. }();
  20361. var Cmd = function CmdClosure() {
  20362. function Cmd(cmd) {
  20363. this.cmd = cmd;
  20364. }
  20365. Cmd.prototype = {};
  20366. var cmdCache = Object.create(null);
  20367. Cmd.get = function Cmd_get(cmd) {
  20368. var cmdValue = cmdCache[cmd];
  20369. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  20370. };
  20371. return Cmd;
  20372. }();
  20373. var Dict = function DictClosure() {
  20374. var nonSerializable = function nonSerializableClosure() {
  20375. return nonSerializable;
  20376. };
  20377. function Dict(xref) {
  20378. this.map = Object.create(null);
  20379. this.xref = xref;
  20380. this.objId = null;
  20381. this.suppressEncryption = false;
  20382. this.__nonSerializable__ = nonSerializable;
  20383. }
  20384. Dict.prototype = {
  20385. assignXref: function Dict_assignXref(newXref) {
  20386. this.xref = newXref;
  20387. },
  20388. get: function Dict_get(key1, key2, key3) {
  20389. var value;
  20390. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20391. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20392. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20393. }
  20394. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20395. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20396. }
  20397. value = this.map[key3] || null;
  20398. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20399. },
  20400. getAsync: function Dict_getAsync(key1, key2, key3) {
  20401. var value;
  20402. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20403. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20404. if (xref) {
  20405. return xref.fetchIfRefAsync(value, suppressEncryption);
  20406. }
  20407. return Promise.resolve(value);
  20408. }
  20409. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20410. if (xref) {
  20411. return xref.fetchIfRefAsync(value, suppressEncryption);
  20412. }
  20413. return Promise.resolve(value);
  20414. }
  20415. value = this.map[key3] || null;
  20416. if (xref) {
  20417. return xref.fetchIfRefAsync(value, suppressEncryption);
  20418. }
  20419. return Promise.resolve(value);
  20420. },
  20421. getArray: function Dict_getArray(key1, key2, key3) {
  20422. var value = this.get(key1, key2, key3);
  20423. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20424. if (!isArray(value) || !xref) {
  20425. return value;
  20426. }
  20427. value = value.slice();
  20428. for (var i = 0, ii = value.length; i < ii; i++) {
  20429. if (!isRef(value[i])) {
  20430. continue;
  20431. }
  20432. value[i] = xref.fetch(value[i], suppressEncryption);
  20433. }
  20434. return value;
  20435. },
  20436. getRaw: function Dict_getRaw(key) {
  20437. return this.map[key];
  20438. },
  20439. getKeys: function Dict_getKeys() {
  20440. return Object.keys(this.map);
  20441. },
  20442. set: function Dict_set(key, value) {
  20443. this.map[key] = value;
  20444. },
  20445. has: function Dict_has(key) {
  20446. return key in this.map;
  20447. },
  20448. forEach: function Dict_forEach(callback) {
  20449. for (var key in this.map) {
  20450. callback(key, this.get(key));
  20451. }
  20452. }
  20453. };
  20454. Dict.empty = new Dict(null);
  20455. Dict.merge = function Dict_merge(xref, dictArray) {
  20456. var mergedDict = new Dict(xref);
  20457. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  20458. var dict = dictArray[i];
  20459. if (!isDict(dict)) {
  20460. continue;
  20461. }
  20462. for (var keyName in dict.map) {
  20463. if (mergedDict.map[keyName]) {
  20464. continue;
  20465. }
  20466. mergedDict.map[keyName] = dict.map[keyName];
  20467. }
  20468. }
  20469. return mergedDict;
  20470. };
  20471. return Dict;
  20472. }();
  20473. var Ref = function RefClosure() {
  20474. function Ref(num, gen) {
  20475. this.num = num;
  20476. this.gen = gen;
  20477. }
  20478. Ref.prototype = {
  20479. toString: function Ref_toString() {
  20480. var str = this.num + 'R';
  20481. if (this.gen !== 0) {
  20482. str += this.gen;
  20483. }
  20484. return str;
  20485. }
  20486. };
  20487. return Ref;
  20488. }();
  20489. var RefSet = function RefSetClosure() {
  20490. function RefSet() {
  20491. this.dict = Object.create(null);
  20492. }
  20493. RefSet.prototype = {
  20494. has: function RefSet_has(ref) {
  20495. return ref.toString() in this.dict;
  20496. },
  20497. put: function RefSet_put(ref) {
  20498. this.dict[ref.toString()] = true;
  20499. },
  20500. remove: function RefSet_remove(ref) {
  20501. delete this.dict[ref.toString()];
  20502. }
  20503. };
  20504. return RefSet;
  20505. }();
  20506. var RefSetCache = function RefSetCacheClosure() {
  20507. function RefSetCache() {
  20508. this.dict = Object.create(null);
  20509. }
  20510. RefSetCache.prototype = {
  20511. get: function RefSetCache_get(ref) {
  20512. return this.dict[ref.toString()];
  20513. },
  20514. has: function RefSetCache_has(ref) {
  20515. return ref.toString() in this.dict;
  20516. },
  20517. put: function RefSetCache_put(ref, obj) {
  20518. this.dict[ref.toString()] = obj;
  20519. },
  20520. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  20521. this.dict[ref.toString()] = this.get(aliasRef);
  20522. },
  20523. forEach: function RefSetCache_forEach(fn, thisArg) {
  20524. for (var i in this.dict) {
  20525. fn.call(thisArg, this.dict[i]);
  20526. }
  20527. },
  20528. clear: function RefSetCache_clear() {
  20529. this.dict = Object.create(null);
  20530. }
  20531. };
  20532. return RefSetCache;
  20533. }();
  20534. function isName(v, name) {
  20535. return v instanceof Name && (name === undefined || v.name === name);
  20536. }
  20537. function isCmd(v, cmd) {
  20538. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  20539. }
  20540. function isDict(v, type) {
  20541. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  20542. }
  20543. function isRef(v) {
  20544. return v instanceof Ref;
  20545. }
  20546. function isRefsEqual(v1, v2) {
  20547. return v1.num === v2.num && v1.gen === v2.gen;
  20548. }
  20549. function isStream(v) {
  20550. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  20551. }
  20552. exports.Cmd = Cmd;
  20553. exports.Dict = Dict;
  20554. exports.Name = Name;
  20555. exports.Ref = Ref;
  20556. exports.RefSet = RefSet;
  20557. exports.RefSetCache = RefSetCache;
  20558. exports.isCmd = isCmd;
  20559. exports.isDict = isDict;
  20560. exports.isName = isName;
  20561. exports.isRef = isRef;
  20562. exports.isRefsEqual = isRefsEqual;
  20563. exports.isStream = isStream;
  20564. }));
  20565. (function (root, factory) {
  20566. factory(root.pdfjsCoreStandardFonts = {}, root.pdfjsSharedUtil);
  20567. }(this, function (exports, sharedUtil) {
  20568. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  20569. var getStdFontMap = getLookupTableFactory(function (t) {
  20570. t['ArialNarrow'] = 'Helvetica';
  20571. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  20572. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  20573. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  20574. t['ArialBlack'] = 'Helvetica';
  20575. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  20576. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  20577. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  20578. t['Arial-Black'] = 'Helvetica';
  20579. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  20580. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  20581. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  20582. t['Arial'] = 'Helvetica';
  20583. t['Arial-Bold'] = 'Helvetica-Bold';
  20584. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  20585. t['Arial-Italic'] = 'Helvetica-Oblique';
  20586. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  20587. t['Arial-BoldMT'] = 'Helvetica-Bold';
  20588. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  20589. t['ArialMT'] = 'Helvetica';
  20590. t['Courier-Bold'] = 'Courier-Bold';
  20591. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  20592. t['Courier-Italic'] = 'Courier-Oblique';
  20593. t['CourierNew'] = 'Courier';
  20594. t['CourierNew-Bold'] = 'Courier-Bold';
  20595. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  20596. t['CourierNew-Italic'] = 'Courier-Oblique';
  20597. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  20598. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  20599. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  20600. t['CourierNewPSMT'] = 'Courier';
  20601. t['Helvetica'] = 'Helvetica';
  20602. t['Helvetica-Bold'] = 'Helvetica-Bold';
  20603. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  20604. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  20605. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  20606. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  20607. t['Symbol-Bold'] = 'Symbol';
  20608. t['Symbol-BoldItalic'] = 'Symbol';
  20609. t['Symbol-Italic'] = 'Symbol';
  20610. t['TimesNewRoman'] = 'Times-Roman';
  20611. t['TimesNewRoman-Bold'] = 'Times-Bold';
  20612. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  20613. t['TimesNewRoman-Italic'] = 'Times-Italic';
  20614. t['TimesNewRomanPS'] = 'Times-Roman';
  20615. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  20616. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  20617. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  20618. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  20619. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  20620. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  20621. t['TimesNewRomanPSMT'] = 'Times-Roman';
  20622. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  20623. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  20624. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  20625. });
  20626. var getNonStdFontMap = getLookupTableFactory(function (t) {
  20627. t['CenturyGothic'] = 'Helvetica';
  20628. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  20629. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  20630. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  20631. t['ComicSansMS'] = 'Comic Sans MS';
  20632. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  20633. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  20634. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  20635. t['LucidaConsole'] = 'Courier';
  20636. t['LucidaConsole-Bold'] = 'Courier-Bold';
  20637. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  20638. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  20639. t['MS-Gothic'] = 'MS Gothic';
  20640. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  20641. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  20642. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  20643. t['MS-Mincho'] = 'MS Mincho';
  20644. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  20645. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  20646. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  20647. t['MS-PGothic'] = 'MS PGothic';
  20648. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  20649. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  20650. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  20651. t['MS-PMincho'] = 'MS PMincho';
  20652. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  20653. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  20654. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  20655. t['NuptialScript'] = 'Times-Italic';
  20656. t['Wingdings'] = 'ZapfDingbats';
  20657. });
  20658. var getSerifFonts = getLookupTableFactory(function (t) {
  20659. t['Adobe Jenson'] = true;
  20660. t['Adobe Text'] = true;
  20661. t['Albertus'] = true;
  20662. t['Aldus'] = true;
  20663. t['Alexandria'] = true;
  20664. t['Algerian'] = true;
  20665. t['American Typewriter'] = true;
  20666. t['Antiqua'] = true;
  20667. t['Apex'] = true;
  20668. t['Arno'] = true;
  20669. t['Aster'] = true;
  20670. t['Aurora'] = true;
  20671. t['Baskerville'] = true;
  20672. t['Bell'] = true;
  20673. t['Bembo'] = true;
  20674. t['Bembo Schoolbook'] = true;
  20675. t['Benguiat'] = true;
  20676. t['Berkeley Old Style'] = true;
  20677. t['Bernhard Modern'] = true;
  20678. t['Berthold City'] = true;
  20679. t['Bodoni'] = true;
  20680. t['Bauer Bodoni'] = true;
  20681. t['Book Antiqua'] = true;
  20682. t['Bookman'] = true;
  20683. t['Bordeaux Roman'] = true;
  20684. t['Californian FB'] = true;
  20685. t['Calisto'] = true;
  20686. t['Calvert'] = true;
  20687. t['Capitals'] = true;
  20688. t['Cambria'] = true;
  20689. t['Cartier'] = true;
  20690. t['Caslon'] = true;
  20691. t['Catull'] = true;
  20692. t['Centaur'] = true;
  20693. t['Century Old Style'] = true;
  20694. t['Century Schoolbook'] = true;
  20695. t['Chaparral'] = true;
  20696. t['Charis SIL'] = true;
  20697. t['Cheltenham'] = true;
  20698. t['Cholla Slab'] = true;
  20699. t['Clarendon'] = true;
  20700. t['Clearface'] = true;
  20701. t['Cochin'] = true;
  20702. t['Colonna'] = true;
  20703. t['Computer Modern'] = true;
  20704. t['Concrete Roman'] = true;
  20705. t['Constantia'] = true;
  20706. t['Cooper Black'] = true;
  20707. t['Corona'] = true;
  20708. t['Ecotype'] = true;
  20709. t['Egyptienne'] = true;
  20710. t['Elephant'] = true;
  20711. t['Excelsior'] = true;
  20712. t['Fairfield'] = true;
  20713. t['FF Scala'] = true;
  20714. t['Folkard'] = true;
  20715. t['Footlight'] = true;
  20716. t['FreeSerif'] = true;
  20717. t['Friz Quadrata'] = true;
  20718. t['Garamond'] = true;
  20719. t['Gentium'] = true;
  20720. t['Georgia'] = true;
  20721. t['Gloucester'] = true;
  20722. t['Goudy Old Style'] = true;
  20723. t['Goudy Schoolbook'] = true;
  20724. t['Goudy Pro Font'] = true;
  20725. t['Granjon'] = true;
  20726. t['Guardian Egyptian'] = true;
  20727. t['Heather'] = true;
  20728. t['Hercules'] = true;
  20729. t['High Tower Text'] = true;
  20730. t['Hiroshige'] = true;
  20731. t['Hoefler Text'] = true;
  20732. t['Humana Serif'] = true;
  20733. t['Imprint'] = true;
  20734. t['Ionic No. 5'] = true;
  20735. t['Janson'] = true;
  20736. t['Joanna'] = true;
  20737. t['Korinna'] = true;
  20738. t['Lexicon'] = true;
  20739. t['Liberation Serif'] = true;
  20740. t['Linux Libertine'] = true;
  20741. t['Literaturnaya'] = true;
  20742. t['Lucida'] = true;
  20743. t['Lucida Bright'] = true;
  20744. t['Melior'] = true;
  20745. t['Memphis'] = true;
  20746. t['Miller'] = true;
  20747. t['Minion'] = true;
  20748. t['Modern'] = true;
  20749. t['Mona Lisa'] = true;
  20750. t['Mrs Eaves'] = true;
  20751. t['MS Serif'] = true;
  20752. t['Museo Slab'] = true;
  20753. t['New York'] = true;
  20754. t['Nimbus Roman'] = true;
  20755. t['NPS Rawlinson Roadway'] = true;
  20756. t['NuptialScript'] = true;
  20757. t['Palatino'] = true;
  20758. t['Perpetua'] = true;
  20759. t['Plantin'] = true;
  20760. t['Plantin Schoolbook'] = true;
  20761. t['Playbill'] = true;
  20762. t['Poor Richard'] = true;
  20763. t['Rawlinson Roadway'] = true;
  20764. t['Renault'] = true;
  20765. t['Requiem'] = true;
  20766. t['Rockwell'] = true;
  20767. t['Roman'] = true;
  20768. t['Rotis Serif'] = true;
  20769. t['Sabon'] = true;
  20770. t['Scala'] = true;
  20771. t['Seagull'] = true;
  20772. t['Sistina'] = true;
  20773. t['Souvenir'] = true;
  20774. t['STIX'] = true;
  20775. t['Stone Informal'] = true;
  20776. t['Stone Serif'] = true;
  20777. t['Sylfaen'] = true;
  20778. t['Times'] = true;
  20779. t['Trajan'] = true;
  20780. t['Trinité'] = true;
  20781. t['Trump Mediaeval'] = true;
  20782. t['Utopia'] = true;
  20783. t['Vale Type'] = true;
  20784. t['Bitstream Vera'] = true;
  20785. t['Vera Serif'] = true;
  20786. t['Versailles'] = true;
  20787. t['Wanted'] = true;
  20788. t['Weiss'] = true;
  20789. t['Wide Latin'] = true;
  20790. t['Windsor'] = true;
  20791. t['XITS'] = true;
  20792. });
  20793. var getSymbolsFonts = getLookupTableFactory(function (t) {
  20794. t['Dingbats'] = true;
  20795. t['Symbol'] = true;
  20796. t['ZapfDingbats'] = true;
  20797. });
  20798. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  20799. t[2] = 10;
  20800. t[3] = 32;
  20801. t[4] = 33;
  20802. t[5] = 34;
  20803. t[6] = 35;
  20804. t[7] = 36;
  20805. t[8] = 37;
  20806. t[9] = 38;
  20807. t[10] = 39;
  20808. t[11] = 40;
  20809. t[12] = 41;
  20810. t[13] = 42;
  20811. t[14] = 43;
  20812. t[15] = 44;
  20813. t[16] = 45;
  20814. t[17] = 46;
  20815. t[18] = 47;
  20816. t[19] = 48;
  20817. t[20] = 49;
  20818. t[21] = 50;
  20819. t[22] = 51;
  20820. t[23] = 52;
  20821. t[24] = 53;
  20822. t[25] = 54;
  20823. t[26] = 55;
  20824. t[27] = 56;
  20825. t[28] = 57;
  20826. t[29] = 58;
  20827. t[30] = 894;
  20828. t[31] = 60;
  20829. t[32] = 61;
  20830. t[33] = 62;
  20831. t[34] = 63;
  20832. t[35] = 64;
  20833. t[36] = 65;
  20834. t[37] = 66;
  20835. t[38] = 67;
  20836. t[39] = 68;
  20837. t[40] = 69;
  20838. t[41] = 70;
  20839. t[42] = 71;
  20840. t[43] = 72;
  20841. t[44] = 73;
  20842. t[45] = 74;
  20843. t[46] = 75;
  20844. t[47] = 76;
  20845. t[48] = 77;
  20846. t[49] = 78;
  20847. t[50] = 79;
  20848. t[51] = 80;
  20849. t[52] = 81;
  20850. t[53] = 82;
  20851. t[54] = 83;
  20852. t[55] = 84;
  20853. t[56] = 85;
  20854. t[57] = 86;
  20855. t[58] = 87;
  20856. t[59] = 88;
  20857. t[60] = 89;
  20858. t[61] = 90;
  20859. t[62] = 91;
  20860. t[63] = 92;
  20861. t[64] = 93;
  20862. t[65] = 94;
  20863. t[66] = 95;
  20864. t[67] = 96;
  20865. t[68] = 97;
  20866. t[69] = 98;
  20867. t[70] = 99;
  20868. t[71] = 100;
  20869. t[72] = 101;
  20870. t[73] = 102;
  20871. t[74] = 103;
  20872. t[75] = 104;
  20873. t[76] = 105;
  20874. t[77] = 106;
  20875. t[78] = 107;
  20876. t[79] = 108;
  20877. t[80] = 109;
  20878. t[81] = 110;
  20879. t[82] = 111;
  20880. t[83] = 112;
  20881. t[84] = 113;
  20882. t[85] = 114;
  20883. t[86] = 115;
  20884. t[87] = 116;
  20885. t[88] = 117;
  20886. t[89] = 118;
  20887. t[90] = 119;
  20888. t[91] = 120;
  20889. t[92] = 121;
  20890. t[93] = 122;
  20891. t[94] = 123;
  20892. t[95] = 124;
  20893. t[96] = 125;
  20894. t[97] = 126;
  20895. t[98] = 196;
  20896. t[99] = 197;
  20897. t[100] = 199;
  20898. t[101] = 201;
  20899. t[102] = 209;
  20900. t[103] = 214;
  20901. t[104] = 220;
  20902. t[105] = 225;
  20903. t[106] = 224;
  20904. t[107] = 226;
  20905. t[108] = 228;
  20906. t[109] = 227;
  20907. t[110] = 229;
  20908. t[111] = 231;
  20909. t[112] = 233;
  20910. t[113] = 232;
  20911. t[114] = 234;
  20912. t[115] = 235;
  20913. t[116] = 237;
  20914. t[117] = 236;
  20915. t[118] = 238;
  20916. t[119] = 239;
  20917. t[120] = 241;
  20918. t[121] = 243;
  20919. t[122] = 242;
  20920. t[123] = 244;
  20921. t[124] = 246;
  20922. t[125] = 245;
  20923. t[126] = 250;
  20924. t[127] = 249;
  20925. t[128] = 251;
  20926. t[129] = 252;
  20927. t[130] = 8224;
  20928. t[131] = 176;
  20929. t[132] = 162;
  20930. t[133] = 163;
  20931. t[134] = 167;
  20932. t[135] = 8226;
  20933. t[136] = 182;
  20934. t[137] = 223;
  20935. t[138] = 174;
  20936. t[139] = 169;
  20937. t[140] = 8482;
  20938. t[141] = 180;
  20939. t[142] = 168;
  20940. t[143] = 8800;
  20941. t[144] = 198;
  20942. t[145] = 216;
  20943. t[146] = 8734;
  20944. t[147] = 177;
  20945. t[148] = 8804;
  20946. t[149] = 8805;
  20947. t[150] = 165;
  20948. t[151] = 181;
  20949. t[152] = 8706;
  20950. t[153] = 8721;
  20951. t[154] = 8719;
  20952. t[156] = 8747;
  20953. t[157] = 170;
  20954. t[158] = 186;
  20955. t[159] = 8486;
  20956. t[160] = 230;
  20957. t[161] = 248;
  20958. t[162] = 191;
  20959. t[163] = 161;
  20960. t[164] = 172;
  20961. t[165] = 8730;
  20962. t[166] = 402;
  20963. t[167] = 8776;
  20964. t[168] = 8710;
  20965. t[169] = 171;
  20966. t[170] = 187;
  20967. t[171] = 8230;
  20968. t[210] = 218;
  20969. t[223] = 711;
  20970. t[224] = 321;
  20971. t[225] = 322;
  20972. t[227] = 353;
  20973. t[229] = 382;
  20974. t[234] = 253;
  20975. t[252] = 263;
  20976. t[253] = 268;
  20977. t[254] = 269;
  20978. t[258] = 258;
  20979. t[260] = 260;
  20980. t[261] = 261;
  20981. t[265] = 280;
  20982. t[266] = 281;
  20983. t[268] = 283;
  20984. t[269] = 313;
  20985. t[275] = 323;
  20986. t[276] = 324;
  20987. t[278] = 328;
  20988. t[284] = 345;
  20989. t[285] = 346;
  20990. t[286] = 347;
  20991. t[292] = 367;
  20992. t[295] = 377;
  20993. t[296] = 378;
  20994. t[298] = 380;
  20995. t[305] = 963;
  20996. t[306] = 964;
  20997. t[307] = 966;
  20998. t[308] = 8215;
  20999. t[309] = 8252;
  21000. t[310] = 8319;
  21001. t[311] = 8359;
  21002. t[312] = 8592;
  21003. t[313] = 8593;
  21004. t[337] = 9552;
  21005. t[493] = 1039;
  21006. t[494] = 1040;
  21007. t[705] = 1524;
  21008. t[706] = 8362;
  21009. t[710] = 64288;
  21010. t[711] = 64298;
  21011. t[759] = 1617;
  21012. t[761] = 1776;
  21013. t[763] = 1778;
  21014. t[775] = 1652;
  21015. t[777] = 1764;
  21016. t[778] = 1780;
  21017. t[779] = 1781;
  21018. t[780] = 1782;
  21019. t[782] = 771;
  21020. t[783] = 64726;
  21021. t[786] = 8363;
  21022. t[788] = 8532;
  21023. t[790] = 768;
  21024. t[791] = 769;
  21025. t[792] = 768;
  21026. t[795] = 803;
  21027. t[797] = 64336;
  21028. t[798] = 64337;
  21029. t[799] = 64342;
  21030. t[800] = 64343;
  21031. t[801] = 64344;
  21032. t[802] = 64345;
  21033. t[803] = 64362;
  21034. t[804] = 64363;
  21035. t[805] = 64364;
  21036. t[2424] = 7821;
  21037. t[2425] = 7822;
  21038. t[2426] = 7823;
  21039. t[2427] = 7824;
  21040. t[2428] = 7825;
  21041. t[2429] = 7826;
  21042. t[2430] = 7827;
  21043. t[2433] = 7682;
  21044. t[2678] = 8045;
  21045. t[2679] = 8046;
  21046. t[2830] = 1552;
  21047. t[2838] = 686;
  21048. t[2840] = 751;
  21049. t[2842] = 753;
  21050. t[2843] = 754;
  21051. t[2844] = 755;
  21052. t[2846] = 757;
  21053. t[2856] = 767;
  21054. t[2857] = 848;
  21055. t[2858] = 849;
  21056. t[2862] = 853;
  21057. t[2863] = 854;
  21058. t[2864] = 855;
  21059. t[2865] = 861;
  21060. t[2866] = 862;
  21061. t[2906] = 7460;
  21062. t[2908] = 7462;
  21063. t[2909] = 7463;
  21064. t[2910] = 7464;
  21065. t[2912] = 7466;
  21066. t[2913] = 7467;
  21067. t[2914] = 7468;
  21068. t[2916] = 7470;
  21069. t[2917] = 7471;
  21070. t[2918] = 7472;
  21071. t[2920] = 7474;
  21072. t[2921] = 7475;
  21073. t[2922] = 7476;
  21074. t[2924] = 7478;
  21075. t[2925] = 7479;
  21076. t[2926] = 7480;
  21077. t[2928] = 7482;
  21078. t[2929] = 7483;
  21079. t[2930] = 7484;
  21080. t[2932] = 7486;
  21081. t[2933] = 7487;
  21082. t[2934] = 7488;
  21083. t[2936] = 7490;
  21084. t[2937] = 7491;
  21085. t[2938] = 7492;
  21086. t[2940] = 7494;
  21087. t[2941] = 7495;
  21088. t[2942] = 7496;
  21089. t[2944] = 7498;
  21090. t[2946] = 7500;
  21091. t[2948] = 7502;
  21092. t[2950] = 7504;
  21093. t[2951] = 7505;
  21094. t[2952] = 7506;
  21095. t[2954] = 7508;
  21096. t[2955] = 7509;
  21097. t[2956] = 7510;
  21098. t[2958] = 7512;
  21099. t[2959] = 7513;
  21100. t[2960] = 7514;
  21101. t[2962] = 7516;
  21102. t[2963] = 7517;
  21103. t[2964] = 7518;
  21104. t[2966] = 7520;
  21105. t[2967] = 7521;
  21106. t[2968] = 7522;
  21107. t[2970] = 7524;
  21108. t[2971] = 7525;
  21109. t[2972] = 7526;
  21110. t[2974] = 7528;
  21111. t[2975] = 7529;
  21112. t[2976] = 7530;
  21113. t[2978] = 1537;
  21114. t[2979] = 1538;
  21115. t[2980] = 1539;
  21116. t[2982] = 1549;
  21117. t[2983] = 1551;
  21118. t[2984] = 1552;
  21119. t[2986] = 1554;
  21120. t[2987] = 1555;
  21121. t[2988] = 1556;
  21122. t[2990] = 1623;
  21123. t[2991] = 1624;
  21124. t[2995] = 1775;
  21125. t[2999] = 1791;
  21126. t[3002] = 64290;
  21127. t[3003] = 64291;
  21128. t[3004] = 64292;
  21129. t[3006] = 64294;
  21130. t[3007] = 64295;
  21131. t[3008] = 64296;
  21132. t[3011] = 1900;
  21133. t[3014] = 8223;
  21134. t[3015] = 8244;
  21135. t[3017] = 7532;
  21136. t[3018] = 7533;
  21137. t[3019] = 7534;
  21138. t[3075] = 7590;
  21139. t[3076] = 7591;
  21140. t[3079] = 7594;
  21141. t[3080] = 7595;
  21142. t[3083] = 7598;
  21143. t[3084] = 7599;
  21144. t[3087] = 7602;
  21145. t[3088] = 7603;
  21146. t[3091] = 7606;
  21147. t[3092] = 7607;
  21148. t[3095] = 7610;
  21149. t[3096] = 7611;
  21150. t[3099] = 7614;
  21151. t[3100] = 7615;
  21152. t[3103] = 7618;
  21153. t[3104] = 7619;
  21154. t[3107] = 8337;
  21155. t[3108] = 8338;
  21156. t[3116] = 1884;
  21157. t[3119] = 1885;
  21158. t[3120] = 1885;
  21159. t[3123] = 1886;
  21160. t[3124] = 1886;
  21161. t[3127] = 1887;
  21162. t[3128] = 1887;
  21163. t[3131] = 1888;
  21164. t[3132] = 1888;
  21165. t[3135] = 1889;
  21166. t[3136] = 1889;
  21167. t[3139] = 1890;
  21168. t[3140] = 1890;
  21169. t[3143] = 1891;
  21170. t[3144] = 1891;
  21171. t[3147] = 1892;
  21172. t[3148] = 1892;
  21173. t[3153] = 580;
  21174. t[3154] = 581;
  21175. t[3157] = 584;
  21176. t[3158] = 585;
  21177. t[3161] = 588;
  21178. t[3162] = 589;
  21179. t[3165] = 891;
  21180. t[3166] = 892;
  21181. t[3169] = 1274;
  21182. t[3170] = 1275;
  21183. t[3173] = 1278;
  21184. t[3174] = 1279;
  21185. t[3181] = 7622;
  21186. t[3182] = 7623;
  21187. t[3282] = 11799;
  21188. t[3316] = 578;
  21189. t[3379] = 42785;
  21190. t[3393] = 1159;
  21191. t[3416] = 8377;
  21192. });
  21193. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  21194. t[227] = 322;
  21195. t[264] = 261;
  21196. t[291] = 346;
  21197. });
  21198. exports.getStdFontMap = getStdFontMap;
  21199. exports.getNonStdFontMap = getNonStdFontMap;
  21200. exports.getSerifFonts = getSerifFonts;
  21201. exports.getSymbolsFonts = getSymbolsFonts;
  21202. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  21203. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  21204. }));
  21205. (function (root, factory) {
  21206. factory(root.pdfjsCoreUnicode = {}, root.pdfjsSharedUtil);
  21207. }(this, function (exports, sharedUtil) {
  21208. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  21209. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  21210. t[63721] = 0x00A9;
  21211. t[63193] = 0x00A9;
  21212. t[63720] = 0x00AE;
  21213. t[63194] = 0x00AE;
  21214. t[63722] = 0x2122;
  21215. t[63195] = 0x2122;
  21216. t[63729] = 0x23A7;
  21217. t[63730] = 0x23A8;
  21218. t[63731] = 0x23A9;
  21219. t[63740] = 0x23AB;
  21220. t[63741] = 0x23AC;
  21221. t[63742] = 0x23AD;
  21222. t[63726] = 0x23A1;
  21223. t[63727] = 0x23A2;
  21224. t[63728] = 0x23A3;
  21225. t[63737] = 0x23A4;
  21226. t[63738] = 0x23A5;
  21227. t[63739] = 0x23A6;
  21228. t[63723] = 0x239B;
  21229. t[63724] = 0x239C;
  21230. t[63725] = 0x239D;
  21231. t[63734] = 0x239E;
  21232. t[63735] = 0x239F;
  21233. t[63736] = 0x23A0;
  21234. });
  21235. function mapSpecialUnicodeValues(code) {
  21236. if (code >= 0xFFF0 && code <= 0xFFFF) {
  21237. return 0;
  21238. } else if (code >= 0xF600 && code <= 0xF8FF) {
  21239. return getSpecialPUASymbols()[code] || code;
  21240. }
  21241. return code;
  21242. }
  21243. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  21244. var unicode = glyphsUnicodeMap[name];
  21245. if (unicode !== undefined) {
  21246. return unicode;
  21247. }
  21248. if (!name) {
  21249. return -1;
  21250. }
  21251. if (name[0] === 'u') {
  21252. var nameLen = name.length, hexStr;
  21253. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  21254. hexStr = name.substr(3);
  21255. } else if (nameLen >= 5 && nameLen <= 7) {
  21256. hexStr = name.substr(1);
  21257. } else {
  21258. return -1;
  21259. }
  21260. if (hexStr === hexStr.toUpperCase()) {
  21261. unicode = parseInt(hexStr, 16);
  21262. if (unicode >= 0) {
  21263. return unicode;
  21264. }
  21265. }
  21266. }
  21267. return -1;
  21268. }
  21269. var UnicodeRanges = [
  21270. {
  21271. 'begin': 0x0000,
  21272. 'end': 0x007F
  21273. },
  21274. {
  21275. 'begin': 0x0080,
  21276. 'end': 0x00FF
  21277. },
  21278. {
  21279. 'begin': 0x0100,
  21280. 'end': 0x017F
  21281. },
  21282. {
  21283. 'begin': 0x0180,
  21284. 'end': 0x024F
  21285. },
  21286. {
  21287. 'begin': 0x0250,
  21288. 'end': 0x02AF
  21289. },
  21290. {
  21291. 'begin': 0x02B0,
  21292. 'end': 0x02FF
  21293. },
  21294. {
  21295. 'begin': 0x0300,
  21296. 'end': 0x036F
  21297. },
  21298. {
  21299. 'begin': 0x0370,
  21300. 'end': 0x03FF
  21301. },
  21302. {
  21303. 'begin': 0x2C80,
  21304. 'end': 0x2CFF
  21305. },
  21306. {
  21307. 'begin': 0x0400,
  21308. 'end': 0x04FF
  21309. },
  21310. {
  21311. 'begin': 0x0530,
  21312. 'end': 0x058F
  21313. },
  21314. {
  21315. 'begin': 0x0590,
  21316. 'end': 0x05FF
  21317. },
  21318. {
  21319. 'begin': 0xA500,
  21320. 'end': 0xA63F
  21321. },
  21322. {
  21323. 'begin': 0x0600,
  21324. 'end': 0x06FF
  21325. },
  21326. {
  21327. 'begin': 0x07C0,
  21328. 'end': 0x07FF
  21329. },
  21330. {
  21331. 'begin': 0x0900,
  21332. 'end': 0x097F
  21333. },
  21334. {
  21335. 'begin': 0x0980,
  21336. 'end': 0x09FF
  21337. },
  21338. {
  21339. 'begin': 0x0A00,
  21340. 'end': 0x0A7F
  21341. },
  21342. {
  21343. 'begin': 0x0A80,
  21344. 'end': 0x0AFF
  21345. },
  21346. {
  21347. 'begin': 0x0B00,
  21348. 'end': 0x0B7F
  21349. },
  21350. {
  21351. 'begin': 0x0B80,
  21352. 'end': 0x0BFF
  21353. },
  21354. {
  21355. 'begin': 0x0C00,
  21356. 'end': 0x0C7F
  21357. },
  21358. {
  21359. 'begin': 0x0C80,
  21360. 'end': 0x0CFF
  21361. },
  21362. {
  21363. 'begin': 0x0D00,
  21364. 'end': 0x0D7F
  21365. },
  21366. {
  21367. 'begin': 0x0E00,
  21368. 'end': 0x0E7F
  21369. },
  21370. {
  21371. 'begin': 0x0E80,
  21372. 'end': 0x0EFF
  21373. },
  21374. {
  21375. 'begin': 0x10A0,
  21376. 'end': 0x10FF
  21377. },
  21378. {
  21379. 'begin': 0x1B00,
  21380. 'end': 0x1B7F
  21381. },
  21382. {
  21383. 'begin': 0x1100,
  21384. 'end': 0x11FF
  21385. },
  21386. {
  21387. 'begin': 0x1E00,
  21388. 'end': 0x1EFF
  21389. },
  21390. {
  21391. 'begin': 0x1F00,
  21392. 'end': 0x1FFF
  21393. },
  21394. {
  21395. 'begin': 0x2000,
  21396. 'end': 0x206F
  21397. },
  21398. {
  21399. 'begin': 0x2070,
  21400. 'end': 0x209F
  21401. },
  21402. {
  21403. 'begin': 0x20A0,
  21404. 'end': 0x20CF
  21405. },
  21406. {
  21407. 'begin': 0x20D0,
  21408. 'end': 0x20FF
  21409. },
  21410. {
  21411. 'begin': 0x2100,
  21412. 'end': 0x214F
  21413. },
  21414. {
  21415. 'begin': 0x2150,
  21416. 'end': 0x218F
  21417. },
  21418. {
  21419. 'begin': 0x2190,
  21420. 'end': 0x21FF
  21421. },
  21422. {
  21423. 'begin': 0x2200,
  21424. 'end': 0x22FF
  21425. },
  21426. {
  21427. 'begin': 0x2300,
  21428. 'end': 0x23FF
  21429. },
  21430. {
  21431. 'begin': 0x2400,
  21432. 'end': 0x243F
  21433. },
  21434. {
  21435. 'begin': 0x2440,
  21436. 'end': 0x245F
  21437. },
  21438. {
  21439. 'begin': 0x2460,
  21440. 'end': 0x24FF
  21441. },
  21442. {
  21443. 'begin': 0x2500,
  21444. 'end': 0x257F
  21445. },
  21446. {
  21447. 'begin': 0x2580,
  21448. 'end': 0x259F
  21449. },
  21450. {
  21451. 'begin': 0x25A0,
  21452. 'end': 0x25FF
  21453. },
  21454. {
  21455. 'begin': 0x2600,
  21456. 'end': 0x26FF
  21457. },
  21458. {
  21459. 'begin': 0x2700,
  21460. 'end': 0x27BF
  21461. },
  21462. {
  21463. 'begin': 0x3000,
  21464. 'end': 0x303F
  21465. },
  21466. {
  21467. 'begin': 0x3040,
  21468. 'end': 0x309F
  21469. },
  21470. {
  21471. 'begin': 0x30A0,
  21472. 'end': 0x30FF
  21473. },
  21474. {
  21475. 'begin': 0x3100,
  21476. 'end': 0x312F
  21477. },
  21478. {
  21479. 'begin': 0x3130,
  21480. 'end': 0x318F
  21481. },
  21482. {
  21483. 'begin': 0xA840,
  21484. 'end': 0xA87F
  21485. },
  21486. {
  21487. 'begin': 0x3200,
  21488. 'end': 0x32FF
  21489. },
  21490. {
  21491. 'begin': 0x3300,
  21492. 'end': 0x33FF
  21493. },
  21494. {
  21495. 'begin': 0xAC00,
  21496. 'end': 0xD7AF
  21497. },
  21498. {
  21499. 'begin': 0xD800,
  21500. 'end': 0xDFFF
  21501. },
  21502. {
  21503. 'begin': 0x10900,
  21504. 'end': 0x1091F
  21505. },
  21506. {
  21507. 'begin': 0x4E00,
  21508. 'end': 0x9FFF
  21509. },
  21510. {
  21511. 'begin': 0xE000,
  21512. 'end': 0xF8FF
  21513. },
  21514. {
  21515. 'begin': 0x31C0,
  21516. 'end': 0x31EF
  21517. },
  21518. {
  21519. 'begin': 0xFB00,
  21520. 'end': 0xFB4F
  21521. },
  21522. {
  21523. 'begin': 0xFB50,
  21524. 'end': 0xFDFF
  21525. },
  21526. {
  21527. 'begin': 0xFE20,
  21528. 'end': 0xFE2F
  21529. },
  21530. {
  21531. 'begin': 0xFE10,
  21532. 'end': 0xFE1F
  21533. },
  21534. {
  21535. 'begin': 0xFE50,
  21536. 'end': 0xFE6F
  21537. },
  21538. {
  21539. 'begin': 0xFE70,
  21540. 'end': 0xFEFF
  21541. },
  21542. {
  21543. 'begin': 0xFF00,
  21544. 'end': 0xFFEF
  21545. },
  21546. {
  21547. 'begin': 0xFFF0,
  21548. 'end': 0xFFFF
  21549. },
  21550. {
  21551. 'begin': 0x0F00,
  21552. 'end': 0x0FFF
  21553. },
  21554. {
  21555. 'begin': 0x0700,
  21556. 'end': 0x074F
  21557. },
  21558. {
  21559. 'begin': 0x0780,
  21560. 'end': 0x07BF
  21561. },
  21562. {
  21563. 'begin': 0x0D80,
  21564. 'end': 0x0DFF
  21565. },
  21566. {
  21567. 'begin': 0x1000,
  21568. 'end': 0x109F
  21569. },
  21570. {
  21571. 'begin': 0x1200,
  21572. 'end': 0x137F
  21573. },
  21574. {
  21575. 'begin': 0x13A0,
  21576. 'end': 0x13FF
  21577. },
  21578. {
  21579. 'begin': 0x1400,
  21580. 'end': 0x167F
  21581. },
  21582. {
  21583. 'begin': 0x1680,
  21584. 'end': 0x169F
  21585. },
  21586. {
  21587. 'begin': 0x16A0,
  21588. 'end': 0x16FF
  21589. },
  21590. {
  21591. 'begin': 0x1780,
  21592. 'end': 0x17FF
  21593. },
  21594. {
  21595. 'begin': 0x1800,
  21596. 'end': 0x18AF
  21597. },
  21598. {
  21599. 'begin': 0x2800,
  21600. 'end': 0x28FF
  21601. },
  21602. {
  21603. 'begin': 0xA000,
  21604. 'end': 0xA48F
  21605. },
  21606. {
  21607. 'begin': 0x1700,
  21608. 'end': 0x171F
  21609. },
  21610. {
  21611. 'begin': 0x10300,
  21612. 'end': 0x1032F
  21613. },
  21614. {
  21615. 'begin': 0x10330,
  21616. 'end': 0x1034F
  21617. },
  21618. {
  21619. 'begin': 0x10400,
  21620. 'end': 0x1044F
  21621. },
  21622. {
  21623. 'begin': 0x1D000,
  21624. 'end': 0x1D0FF
  21625. },
  21626. {
  21627. 'begin': 0x1D400,
  21628. 'end': 0x1D7FF
  21629. },
  21630. {
  21631. 'begin': 0xFF000,
  21632. 'end': 0xFFFFD
  21633. },
  21634. {
  21635. 'begin': 0xFE00,
  21636. 'end': 0xFE0F
  21637. },
  21638. {
  21639. 'begin': 0xE0000,
  21640. 'end': 0xE007F
  21641. },
  21642. {
  21643. 'begin': 0x1900,
  21644. 'end': 0x194F
  21645. },
  21646. {
  21647. 'begin': 0x1950,
  21648. 'end': 0x197F
  21649. },
  21650. {
  21651. 'begin': 0x1980,
  21652. 'end': 0x19DF
  21653. },
  21654. {
  21655. 'begin': 0x1A00,
  21656. 'end': 0x1A1F
  21657. },
  21658. {
  21659. 'begin': 0x2C00,
  21660. 'end': 0x2C5F
  21661. },
  21662. {
  21663. 'begin': 0x2D30,
  21664. 'end': 0x2D7F
  21665. },
  21666. {
  21667. 'begin': 0x4DC0,
  21668. 'end': 0x4DFF
  21669. },
  21670. {
  21671. 'begin': 0xA800,
  21672. 'end': 0xA82F
  21673. },
  21674. {
  21675. 'begin': 0x10000,
  21676. 'end': 0x1007F
  21677. },
  21678. {
  21679. 'begin': 0x10140,
  21680. 'end': 0x1018F
  21681. },
  21682. {
  21683. 'begin': 0x10380,
  21684. 'end': 0x1039F
  21685. },
  21686. {
  21687. 'begin': 0x103A0,
  21688. 'end': 0x103DF
  21689. },
  21690. {
  21691. 'begin': 0x10450,
  21692. 'end': 0x1047F
  21693. },
  21694. {
  21695. 'begin': 0x10480,
  21696. 'end': 0x104AF
  21697. },
  21698. {
  21699. 'begin': 0x10800,
  21700. 'end': 0x1083F
  21701. },
  21702. {
  21703. 'begin': 0x10A00,
  21704. 'end': 0x10A5F
  21705. },
  21706. {
  21707. 'begin': 0x1D300,
  21708. 'end': 0x1D35F
  21709. },
  21710. {
  21711. 'begin': 0x12000,
  21712. 'end': 0x123FF
  21713. },
  21714. {
  21715. 'begin': 0x1D360,
  21716. 'end': 0x1D37F
  21717. },
  21718. {
  21719. 'begin': 0x1B80,
  21720. 'end': 0x1BBF
  21721. },
  21722. {
  21723. 'begin': 0x1C00,
  21724. 'end': 0x1C4F
  21725. },
  21726. {
  21727. 'begin': 0x1C50,
  21728. 'end': 0x1C7F
  21729. },
  21730. {
  21731. 'begin': 0xA880,
  21732. 'end': 0xA8DF
  21733. },
  21734. {
  21735. 'begin': 0xA900,
  21736. 'end': 0xA92F
  21737. },
  21738. {
  21739. 'begin': 0xA930,
  21740. 'end': 0xA95F
  21741. },
  21742. {
  21743. 'begin': 0xAA00,
  21744. 'end': 0xAA5F
  21745. },
  21746. {
  21747. 'begin': 0x10190,
  21748. 'end': 0x101CF
  21749. },
  21750. {
  21751. 'begin': 0x101D0,
  21752. 'end': 0x101FF
  21753. },
  21754. {
  21755. 'begin': 0x102A0,
  21756. 'end': 0x102DF
  21757. },
  21758. {
  21759. 'begin': 0x1F030,
  21760. 'end': 0x1F09F
  21761. }
  21762. ];
  21763. function getUnicodeRangeFor(value) {
  21764. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  21765. var range = UnicodeRanges[i];
  21766. if (value >= range.begin && value < range.end) {
  21767. return i;
  21768. }
  21769. }
  21770. return -1;
  21771. }
  21772. function isRTLRangeFor(value) {
  21773. var range = UnicodeRanges[13];
  21774. if (value >= range.begin && value < range.end) {
  21775. return true;
  21776. }
  21777. range = UnicodeRanges[11];
  21778. if (value >= range.begin && value < range.end) {
  21779. return true;
  21780. }
  21781. return false;
  21782. }
  21783. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  21784. t['\u00A8'] = '\u0020\u0308';
  21785. t['\u00AF'] = '\u0020\u0304';
  21786. t['\u00B4'] = '\u0020\u0301';
  21787. t['\u00B5'] = '\u03BC';
  21788. t['\u00B8'] = '\u0020\u0327';
  21789. t['\u0132'] = '\u0049\u004A';
  21790. t['\u0133'] = '\u0069\u006A';
  21791. t['\u013F'] = '\u004C\u00B7';
  21792. t['\u0140'] = '\u006C\u00B7';
  21793. t['\u0149'] = '\u02BC\u006E';
  21794. t['\u017F'] = '\u0073';
  21795. t['\u01C4'] = '\u0044\u017D';
  21796. t['\u01C5'] = '\u0044\u017E';
  21797. t['\u01C6'] = '\u0064\u017E';
  21798. t['\u01C7'] = '\u004C\u004A';
  21799. t['\u01C8'] = '\u004C\u006A';
  21800. t['\u01C9'] = '\u006C\u006A';
  21801. t['\u01CA'] = '\u004E\u004A';
  21802. t['\u01CB'] = '\u004E\u006A';
  21803. t['\u01CC'] = '\u006E\u006A';
  21804. t['\u01F1'] = '\u0044\u005A';
  21805. t['\u01F2'] = '\u0044\u007A';
  21806. t['\u01F3'] = '\u0064\u007A';
  21807. t['\u02D8'] = '\u0020\u0306';
  21808. t['\u02D9'] = '\u0020\u0307';
  21809. t['\u02DA'] = '\u0020\u030A';
  21810. t['\u02DB'] = '\u0020\u0328';
  21811. t['\u02DC'] = '\u0020\u0303';
  21812. t['\u02DD'] = '\u0020\u030B';
  21813. t['\u037A'] = '\u0020\u0345';
  21814. t['\u0384'] = '\u0020\u0301';
  21815. t['\u03D0'] = '\u03B2';
  21816. t['\u03D1'] = '\u03B8';
  21817. t['\u03D2'] = '\u03A5';
  21818. t['\u03D5'] = '\u03C6';
  21819. t['\u03D6'] = '\u03C0';
  21820. t['\u03F0'] = '\u03BA';
  21821. t['\u03F1'] = '\u03C1';
  21822. t['\u03F2'] = '\u03C2';
  21823. t['\u03F4'] = '\u0398';
  21824. t['\u03F5'] = '\u03B5';
  21825. t['\u03F9'] = '\u03A3';
  21826. t['\u0587'] = '\u0565\u0582';
  21827. t['\u0675'] = '\u0627\u0674';
  21828. t['\u0676'] = '\u0648\u0674';
  21829. t['\u0677'] = '\u06C7\u0674';
  21830. t['\u0678'] = '\u064A\u0674';
  21831. t['\u0E33'] = '\u0E4D\u0E32';
  21832. t['\u0EB3'] = '\u0ECD\u0EB2';
  21833. t['\u0EDC'] = '\u0EAB\u0E99';
  21834. t['\u0EDD'] = '\u0EAB\u0EA1';
  21835. t['\u0F77'] = '\u0FB2\u0F81';
  21836. t['\u0F79'] = '\u0FB3\u0F81';
  21837. t['\u1E9A'] = '\u0061\u02BE';
  21838. t['\u1FBD'] = '\u0020\u0313';
  21839. t['\u1FBF'] = '\u0020\u0313';
  21840. t['\u1FC0'] = '\u0020\u0342';
  21841. t['\u1FFE'] = '\u0020\u0314';
  21842. t['\u2002'] = '\u0020';
  21843. t['\u2003'] = '\u0020';
  21844. t['\u2004'] = '\u0020';
  21845. t['\u2005'] = '\u0020';
  21846. t['\u2006'] = '\u0020';
  21847. t['\u2008'] = '\u0020';
  21848. t['\u2009'] = '\u0020';
  21849. t['\u200A'] = '\u0020';
  21850. t['\u2017'] = '\u0020\u0333';
  21851. t['\u2024'] = '\u002E';
  21852. t['\u2025'] = '\u002E\u002E';
  21853. t['\u2026'] = '\u002E\u002E\u002E';
  21854. t['\u2033'] = '\u2032\u2032';
  21855. t['\u2034'] = '\u2032\u2032\u2032';
  21856. t['\u2036'] = '\u2035\u2035';
  21857. t['\u2037'] = '\u2035\u2035\u2035';
  21858. t['\u203C'] = '\u0021\u0021';
  21859. t['\u203E'] = '\u0020\u0305';
  21860. t['\u2047'] = '\u003F\u003F';
  21861. t['\u2048'] = '\u003F\u0021';
  21862. t['\u2049'] = '\u0021\u003F';
  21863. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  21864. t['\u205F'] = '\u0020';
  21865. t['\u20A8'] = '\u0052\u0073';
  21866. t['\u2100'] = '\u0061\u002F\u0063';
  21867. t['\u2101'] = '\u0061\u002F\u0073';
  21868. t['\u2103'] = '\u00B0\u0043';
  21869. t['\u2105'] = '\u0063\u002F\u006F';
  21870. t['\u2106'] = '\u0063\u002F\u0075';
  21871. t['\u2107'] = '\u0190';
  21872. t['\u2109'] = '\u00B0\u0046';
  21873. t['\u2116'] = '\u004E\u006F';
  21874. t['\u2121'] = '\u0054\u0045\u004C';
  21875. t['\u2135'] = '\u05D0';
  21876. t['\u2136'] = '\u05D1';
  21877. t['\u2137'] = '\u05D2';
  21878. t['\u2138'] = '\u05D3';
  21879. t['\u213B'] = '\u0046\u0041\u0058';
  21880. t['\u2160'] = '\u0049';
  21881. t['\u2161'] = '\u0049\u0049';
  21882. t['\u2162'] = '\u0049\u0049\u0049';
  21883. t['\u2163'] = '\u0049\u0056';
  21884. t['\u2164'] = '\u0056';
  21885. t['\u2165'] = '\u0056\u0049';
  21886. t['\u2166'] = '\u0056\u0049\u0049';
  21887. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  21888. t['\u2168'] = '\u0049\u0058';
  21889. t['\u2169'] = '\u0058';
  21890. t['\u216A'] = '\u0058\u0049';
  21891. t['\u216B'] = '\u0058\u0049\u0049';
  21892. t['\u216C'] = '\u004C';
  21893. t['\u216D'] = '\u0043';
  21894. t['\u216E'] = '\u0044';
  21895. t['\u216F'] = '\u004D';
  21896. t['\u2170'] = '\u0069';
  21897. t['\u2171'] = '\u0069\u0069';
  21898. t['\u2172'] = '\u0069\u0069\u0069';
  21899. t['\u2173'] = '\u0069\u0076';
  21900. t['\u2174'] = '\u0076';
  21901. t['\u2175'] = '\u0076\u0069';
  21902. t['\u2176'] = '\u0076\u0069\u0069';
  21903. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  21904. t['\u2178'] = '\u0069\u0078';
  21905. t['\u2179'] = '\u0078';
  21906. t['\u217A'] = '\u0078\u0069';
  21907. t['\u217B'] = '\u0078\u0069\u0069';
  21908. t['\u217C'] = '\u006C';
  21909. t['\u217D'] = '\u0063';
  21910. t['\u217E'] = '\u0064';
  21911. t['\u217F'] = '\u006D';
  21912. t['\u222C'] = '\u222B\u222B';
  21913. t['\u222D'] = '\u222B\u222B\u222B';
  21914. t['\u222F'] = '\u222E\u222E';
  21915. t['\u2230'] = '\u222E\u222E\u222E';
  21916. t['\u2474'] = '\u0028\u0031\u0029';
  21917. t['\u2475'] = '\u0028\u0032\u0029';
  21918. t['\u2476'] = '\u0028\u0033\u0029';
  21919. t['\u2477'] = '\u0028\u0034\u0029';
  21920. t['\u2478'] = '\u0028\u0035\u0029';
  21921. t['\u2479'] = '\u0028\u0036\u0029';
  21922. t['\u247A'] = '\u0028\u0037\u0029';
  21923. t['\u247B'] = '\u0028\u0038\u0029';
  21924. t['\u247C'] = '\u0028\u0039\u0029';
  21925. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  21926. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  21927. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  21928. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  21929. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  21930. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  21931. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  21932. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  21933. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  21934. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  21935. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  21936. t['\u2488'] = '\u0031\u002E';
  21937. t['\u2489'] = '\u0032\u002E';
  21938. t['\u248A'] = '\u0033\u002E';
  21939. t['\u248B'] = '\u0034\u002E';
  21940. t['\u248C'] = '\u0035\u002E';
  21941. t['\u248D'] = '\u0036\u002E';
  21942. t['\u248E'] = '\u0037\u002E';
  21943. t['\u248F'] = '\u0038\u002E';
  21944. t['\u2490'] = '\u0039\u002E';
  21945. t['\u2491'] = '\u0031\u0030\u002E';
  21946. t['\u2492'] = '\u0031\u0031\u002E';
  21947. t['\u2493'] = '\u0031\u0032\u002E';
  21948. t['\u2494'] = '\u0031\u0033\u002E';
  21949. t['\u2495'] = '\u0031\u0034\u002E';
  21950. t['\u2496'] = '\u0031\u0035\u002E';
  21951. t['\u2497'] = '\u0031\u0036\u002E';
  21952. t['\u2498'] = '\u0031\u0037\u002E';
  21953. t['\u2499'] = '\u0031\u0038\u002E';
  21954. t['\u249A'] = '\u0031\u0039\u002E';
  21955. t['\u249B'] = '\u0032\u0030\u002E';
  21956. t['\u249C'] = '\u0028\u0061\u0029';
  21957. t['\u249D'] = '\u0028\u0062\u0029';
  21958. t['\u249E'] = '\u0028\u0063\u0029';
  21959. t['\u249F'] = '\u0028\u0064\u0029';
  21960. t['\u24A0'] = '\u0028\u0065\u0029';
  21961. t['\u24A1'] = '\u0028\u0066\u0029';
  21962. t['\u24A2'] = '\u0028\u0067\u0029';
  21963. t['\u24A3'] = '\u0028\u0068\u0029';
  21964. t['\u24A4'] = '\u0028\u0069\u0029';
  21965. t['\u24A5'] = '\u0028\u006A\u0029';
  21966. t['\u24A6'] = '\u0028\u006B\u0029';
  21967. t['\u24A7'] = '\u0028\u006C\u0029';
  21968. t['\u24A8'] = '\u0028\u006D\u0029';
  21969. t['\u24A9'] = '\u0028\u006E\u0029';
  21970. t['\u24AA'] = '\u0028\u006F\u0029';
  21971. t['\u24AB'] = '\u0028\u0070\u0029';
  21972. t['\u24AC'] = '\u0028\u0071\u0029';
  21973. t['\u24AD'] = '\u0028\u0072\u0029';
  21974. t['\u24AE'] = '\u0028\u0073\u0029';
  21975. t['\u24AF'] = '\u0028\u0074\u0029';
  21976. t['\u24B0'] = '\u0028\u0075\u0029';
  21977. t['\u24B1'] = '\u0028\u0076\u0029';
  21978. t['\u24B2'] = '\u0028\u0077\u0029';
  21979. t['\u24B3'] = '\u0028\u0078\u0029';
  21980. t['\u24B4'] = '\u0028\u0079\u0029';
  21981. t['\u24B5'] = '\u0028\u007A\u0029';
  21982. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  21983. t['\u2A74'] = '\u003A\u003A\u003D';
  21984. t['\u2A75'] = '\u003D\u003D';
  21985. t['\u2A76'] = '\u003D\u003D\u003D';
  21986. t['\u2E9F'] = '\u6BCD';
  21987. t['\u2EF3'] = '\u9F9F';
  21988. t['\u2F00'] = '\u4E00';
  21989. t['\u2F01'] = '\u4E28';
  21990. t['\u2F02'] = '\u4E36';
  21991. t['\u2F03'] = '\u4E3F';
  21992. t['\u2F04'] = '\u4E59';
  21993. t['\u2F05'] = '\u4E85';
  21994. t['\u2F06'] = '\u4E8C';
  21995. t['\u2F07'] = '\u4EA0';
  21996. t['\u2F08'] = '\u4EBA';
  21997. t['\u2F09'] = '\u513F';
  21998. t['\u2F0A'] = '\u5165';
  21999. t['\u2F0B'] = '\u516B';
  22000. t['\u2F0C'] = '\u5182';
  22001. t['\u2F0D'] = '\u5196';
  22002. t['\u2F0E'] = '\u51AB';
  22003. t['\u2F0F'] = '\u51E0';
  22004. t['\u2F10'] = '\u51F5';
  22005. t['\u2F11'] = '\u5200';
  22006. t['\u2F12'] = '\u529B';
  22007. t['\u2F13'] = '\u52F9';
  22008. t['\u2F14'] = '\u5315';
  22009. t['\u2F15'] = '\u531A';
  22010. t['\u2F16'] = '\u5338';
  22011. t['\u2F17'] = '\u5341';
  22012. t['\u2F18'] = '\u535C';
  22013. t['\u2F19'] = '\u5369';
  22014. t['\u2F1A'] = '\u5382';
  22015. t['\u2F1B'] = '\u53B6';
  22016. t['\u2F1C'] = '\u53C8';
  22017. t['\u2F1D'] = '\u53E3';
  22018. t['\u2F1E'] = '\u56D7';
  22019. t['\u2F1F'] = '\u571F';
  22020. t['\u2F20'] = '\u58EB';
  22021. t['\u2F21'] = '\u5902';
  22022. t['\u2F22'] = '\u590A';
  22023. t['\u2F23'] = '\u5915';
  22024. t['\u2F24'] = '\u5927';
  22025. t['\u2F25'] = '\u5973';
  22026. t['\u2F26'] = '\u5B50';
  22027. t['\u2F27'] = '\u5B80';
  22028. t['\u2F28'] = '\u5BF8';
  22029. t['\u2F29'] = '\u5C0F';
  22030. t['\u2F2A'] = '\u5C22';
  22031. t['\u2F2B'] = '\u5C38';
  22032. t['\u2F2C'] = '\u5C6E';
  22033. t['\u2F2D'] = '\u5C71';
  22034. t['\u2F2E'] = '\u5DDB';
  22035. t['\u2F2F'] = '\u5DE5';
  22036. t['\u2F30'] = '\u5DF1';
  22037. t['\u2F31'] = '\u5DFE';
  22038. t['\u2F32'] = '\u5E72';
  22039. t['\u2F33'] = '\u5E7A';
  22040. t['\u2F34'] = '\u5E7F';
  22041. t['\u2F35'] = '\u5EF4';
  22042. t['\u2F36'] = '\u5EFE';
  22043. t['\u2F37'] = '\u5F0B';
  22044. t['\u2F38'] = '\u5F13';
  22045. t['\u2F39'] = '\u5F50';
  22046. t['\u2F3A'] = '\u5F61';
  22047. t['\u2F3B'] = '\u5F73';
  22048. t['\u2F3C'] = '\u5FC3';
  22049. t['\u2F3D'] = '\u6208';
  22050. t['\u2F3E'] = '\u6236';
  22051. t['\u2F3F'] = '\u624B';
  22052. t['\u2F40'] = '\u652F';
  22053. t['\u2F41'] = '\u6534';
  22054. t['\u2F42'] = '\u6587';
  22055. t['\u2F43'] = '\u6597';
  22056. t['\u2F44'] = '\u65A4';
  22057. t['\u2F45'] = '\u65B9';
  22058. t['\u2F46'] = '\u65E0';
  22059. t['\u2F47'] = '\u65E5';
  22060. t['\u2F48'] = '\u66F0';
  22061. t['\u2F49'] = '\u6708';
  22062. t['\u2F4A'] = '\u6728';
  22063. t['\u2F4B'] = '\u6B20';
  22064. t['\u2F4C'] = '\u6B62';
  22065. t['\u2F4D'] = '\u6B79';
  22066. t['\u2F4E'] = '\u6BB3';
  22067. t['\u2F4F'] = '\u6BCB';
  22068. t['\u2F50'] = '\u6BD4';
  22069. t['\u2F51'] = '\u6BDB';
  22070. t['\u2F52'] = '\u6C0F';
  22071. t['\u2F53'] = '\u6C14';
  22072. t['\u2F54'] = '\u6C34';
  22073. t['\u2F55'] = '\u706B';
  22074. t['\u2F56'] = '\u722A';
  22075. t['\u2F57'] = '\u7236';
  22076. t['\u2F58'] = '\u723B';
  22077. t['\u2F59'] = '\u723F';
  22078. t['\u2F5A'] = '\u7247';
  22079. t['\u2F5B'] = '\u7259';
  22080. t['\u2F5C'] = '\u725B';
  22081. t['\u2F5D'] = '\u72AC';
  22082. t['\u2F5E'] = '\u7384';
  22083. t['\u2F5F'] = '\u7389';
  22084. t['\u2F60'] = '\u74DC';
  22085. t['\u2F61'] = '\u74E6';
  22086. t['\u2F62'] = '\u7518';
  22087. t['\u2F63'] = '\u751F';
  22088. t['\u2F64'] = '\u7528';
  22089. t['\u2F65'] = '\u7530';
  22090. t['\u2F66'] = '\u758B';
  22091. t['\u2F67'] = '\u7592';
  22092. t['\u2F68'] = '\u7676';
  22093. t['\u2F69'] = '\u767D';
  22094. t['\u2F6A'] = '\u76AE';
  22095. t['\u2F6B'] = '\u76BF';
  22096. t['\u2F6C'] = '\u76EE';
  22097. t['\u2F6D'] = '\u77DB';
  22098. t['\u2F6E'] = '\u77E2';
  22099. t['\u2F6F'] = '\u77F3';
  22100. t['\u2F70'] = '\u793A';
  22101. t['\u2F71'] = '\u79B8';
  22102. t['\u2F72'] = '\u79BE';
  22103. t['\u2F73'] = '\u7A74';
  22104. t['\u2F74'] = '\u7ACB';
  22105. t['\u2F75'] = '\u7AF9';
  22106. t['\u2F76'] = '\u7C73';
  22107. t['\u2F77'] = '\u7CF8';
  22108. t['\u2F78'] = '\u7F36';
  22109. t['\u2F79'] = '\u7F51';
  22110. t['\u2F7A'] = '\u7F8A';
  22111. t['\u2F7B'] = '\u7FBD';
  22112. t['\u2F7C'] = '\u8001';
  22113. t['\u2F7D'] = '\u800C';
  22114. t['\u2F7E'] = '\u8012';
  22115. t['\u2F7F'] = '\u8033';
  22116. t['\u2F80'] = '\u807F';
  22117. t['\u2F81'] = '\u8089';
  22118. t['\u2F82'] = '\u81E3';
  22119. t['\u2F83'] = '\u81EA';
  22120. t['\u2F84'] = '\u81F3';
  22121. t['\u2F85'] = '\u81FC';
  22122. t['\u2F86'] = '\u820C';
  22123. t['\u2F87'] = '\u821B';
  22124. t['\u2F88'] = '\u821F';
  22125. t['\u2F89'] = '\u826E';
  22126. t['\u2F8A'] = '\u8272';
  22127. t['\u2F8B'] = '\u8278';
  22128. t['\u2F8C'] = '\u864D';
  22129. t['\u2F8D'] = '\u866B';
  22130. t['\u2F8E'] = '\u8840';
  22131. t['\u2F8F'] = '\u884C';
  22132. t['\u2F90'] = '\u8863';
  22133. t['\u2F91'] = '\u897E';
  22134. t['\u2F92'] = '\u898B';
  22135. t['\u2F93'] = '\u89D2';
  22136. t['\u2F94'] = '\u8A00';
  22137. t['\u2F95'] = '\u8C37';
  22138. t['\u2F96'] = '\u8C46';
  22139. t['\u2F97'] = '\u8C55';
  22140. t['\u2F98'] = '\u8C78';
  22141. t['\u2F99'] = '\u8C9D';
  22142. t['\u2F9A'] = '\u8D64';
  22143. t['\u2F9B'] = '\u8D70';
  22144. t['\u2F9C'] = '\u8DB3';
  22145. t['\u2F9D'] = '\u8EAB';
  22146. t['\u2F9E'] = '\u8ECA';
  22147. t['\u2F9F'] = '\u8F9B';
  22148. t['\u2FA0'] = '\u8FB0';
  22149. t['\u2FA1'] = '\u8FB5';
  22150. t['\u2FA2'] = '\u9091';
  22151. t['\u2FA3'] = '\u9149';
  22152. t['\u2FA4'] = '\u91C6';
  22153. t['\u2FA5'] = '\u91CC';
  22154. t['\u2FA6'] = '\u91D1';
  22155. t['\u2FA7'] = '\u9577';
  22156. t['\u2FA8'] = '\u9580';
  22157. t['\u2FA9'] = '\u961C';
  22158. t['\u2FAA'] = '\u96B6';
  22159. t['\u2FAB'] = '\u96B9';
  22160. t['\u2FAC'] = '\u96E8';
  22161. t['\u2FAD'] = '\u9751';
  22162. t['\u2FAE'] = '\u975E';
  22163. t['\u2FAF'] = '\u9762';
  22164. t['\u2FB0'] = '\u9769';
  22165. t['\u2FB1'] = '\u97CB';
  22166. t['\u2FB2'] = '\u97ED';
  22167. t['\u2FB3'] = '\u97F3';
  22168. t['\u2FB4'] = '\u9801';
  22169. t['\u2FB5'] = '\u98A8';
  22170. t['\u2FB6'] = '\u98DB';
  22171. t['\u2FB7'] = '\u98DF';
  22172. t['\u2FB8'] = '\u9996';
  22173. t['\u2FB9'] = '\u9999';
  22174. t['\u2FBA'] = '\u99AC';
  22175. t['\u2FBB'] = '\u9AA8';
  22176. t['\u2FBC'] = '\u9AD8';
  22177. t['\u2FBD'] = '\u9ADF';
  22178. t['\u2FBE'] = '\u9B25';
  22179. t['\u2FBF'] = '\u9B2F';
  22180. t['\u2FC0'] = '\u9B32';
  22181. t['\u2FC1'] = '\u9B3C';
  22182. t['\u2FC2'] = '\u9B5A';
  22183. t['\u2FC3'] = '\u9CE5';
  22184. t['\u2FC4'] = '\u9E75';
  22185. t['\u2FC5'] = '\u9E7F';
  22186. t['\u2FC6'] = '\u9EA5';
  22187. t['\u2FC7'] = '\u9EBB';
  22188. t['\u2FC8'] = '\u9EC3';
  22189. t['\u2FC9'] = '\u9ECD';
  22190. t['\u2FCA'] = '\u9ED1';
  22191. t['\u2FCB'] = '\u9EF9';
  22192. t['\u2FCC'] = '\u9EFD';
  22193. t['\u2FCD'] = '\u9F0E';
  22194. t['\u2FCE'] = '\u9F13';
  22195. t['\u2FCF'] = '\u9F20';
  22196. t['\u2FD0'] = '\u9F3B';
  22197. t['\u2FD1'] = '\u9F4A';
  22198. t['\u2FD2'] = '\u9F52';
  22199. t['\u2FD3'] = '\u9F8D';
  22200. t['\u2FD4'] = '\u9F9C';
  22201. t['\u2FD5'] = '\u9FA0';
  22202. t['\u3036'] = '\u3012';
  22203. t['\u3038'] = '\u5341';
  22204. t['\u3039'] = '\u5344';
  22205. t['\u303A'] = '\u5345';
  22206. t['\u309B'] = '\u0020\u3099';
  22207. t['\u309C'] = '\u0020\u309A';
  22208. t['\u3131'] = '\u1100';
  22209. t['\u3132'] = '\u1101';
  22210. t['\u3133'] = '\u11AA';
  22211. t['\u3134'] = '\u1102';
  22212. t['\u3135'] = '\u11AC';
  22213. t['\u3136'] = '\u11AD';
  22214. t['\u3137'] = '\u1103';
  22215. t['\u3138'] = '\u1104';
  22216. t['\u3139'] = '\u1105';
  22217. t['\u313A'] = '\u11B0';
  22218. t['\u313B'] = '\u11B1';
  22219. t['\u313C'] = '\u11B2';
  22220. t['\u313D'] = '\u11B3';
  22221. t['\u313E'] = '\u11B4';
  22222. t['\u313F'] = '\u11B5';
  22223. t['\u3140'] = '\u111A';
  22224. t['\u3141'] = '\u1106';
  22225. t['\u3142'] = '\u1107';
  22226. t['\u3143'] = '\u1108';
  22227. t['\u3144'] = '\u1121';
  22228. t['\u3145'] = '\u1109';
  22229. t['\u3146'] = '\u110A';
  22230. t['\u3147'] = '\u110B';
  22231. t['\u3148'] = '\u110C';
  22232. t['\u3149'] = '\u110D';
  22233. t['\u314A'] = '\u110E';
  22234. t['\u314B'] = '\u110F';
  22235. t['\u314C'] = '\u1110';
  22236. t['\u314D'] = '\u1111';
  22237. t['\u314E'] = '\u1112';
  22238. t['\u314F'] = '\u1161';
  22239. t['\u3150'] = '\u1162';
  22240. t['\u3151'] = '\u1163';
  22241. t['\u3152'] = '\u1164';
  22242. t['\u3153'] = '\u1165';
  22243. t['\u3154'] = '\u1166';
  22244. t['\u3155'] = '\u1167';
  22245. t['\u3156'] = '\u1168';
  22246. t['\u3157'] = '\u1169';
  22247. t['\u3158'] = '\u116A';
  22248. t['\u3159'] = '\u116B';
  22249. t['\u315A'] = '\u116C';
  22250. t['\u315B'] = '\u116D';
  22251. t['\u315C'] = '\u116E';
  22252. t['\u315D'] = '\u116F';
  22253. t['\u315E'] = '\u1170';
  22254. t['\u315F'] = '\u1171';
  22255. t['\u3160'] = '\u1172';
  22256. t['\u3161'] = '\u1173';
  22257. t['\u3162'] = '\u1174';
  22258. t['\u3163'] = '\u1175';
  22259. t['\u3164'] = '\u1160';
  22260. t['\u3165'] = '\u1114';
  22261. t['\u3166'] = '\u1115';
  22262. t['\u3167'] = '\u11C7';
  22263. t['\u3168'] = '\u11C8';
  22264. t['\u3169'] = '\u11CC';
  22265. t['\u316A'] = '\u11CE';
  22266. t['\u316B'] = '\u11D3';
  22267. t['\u316C'] = '\u11D7';
  22268. t['\u316D'] = '\u11D9';
  22269. t['\u316E'] = '\u111C';
  22270. t['\u316F'] = '\u11DD';
  22271. t['\u3170'] = '\u11DF';
  22272. t['\u3171'] = '\u111D';
  22273. t['\u3172'] = '\u111E';
  22274. t['\u3173'] = '\u1120';
  22275. t['\u3174'] = '\u1122';
  22276. t['\u3175'] = '\u1123';
  22277. t['\u3176'] = '\u1127';
  22278. t['\u3177'] = '\u1129';
  22279. t['\u3178'] = '\u112B';
  22280. t['\u3179'] = '\u112C';
  22281. t['\u317A'] = '\u112D';
  22282. t['\u317B'] = '\u112E';
  22283. t['\u317C'] = '\u112F';
  22284. t['\u317D'] = '\u1132';
  22285. t['\u317E'] = '\u1136';
  22286. t['\u317F'] = '\u1140';
  22287. t['\u3180'] = '\u1147';
  22288. t['\u3181'] = '\u114C';
  22289. t['\u3182'] = '\u11F1';
  22290. t['\u3183'] = '\u11F2';
  22291. t['\u3184'] = '\u1157';
  22292. t['\u3185'] = '\u1158';
  22293. t['\u3186'] = '\u1159';
  22294. t['\u3187'] = '\u1184';
  22295. t['\u3188'] = '\u1185';
  22296. t['\u3189'] = '\u1188';
  22297. t['\u318A'] = '\u1191';
  22298. t['\u318B'] = '\u1192';
  22299. t['\u318C'] = '\u1194';
  22300. t['\u318D'] = '\u119E';
  22301. t['\u318E'] = '\u11A1';
  22302. t['\u3200'] = '\u0028\u1100\u0029';
  22303. t['\u3201'] = '\u0028\u1102\u0029';
  22304. t['\u3202'] = '\u0028\u1103\u0029';
  22305. t['\u3203'] = '\u0028\u1105\u0029';
  22306. t['\u3204'] = '\u0028\u1106\u0029';
  22307. t['\u3205'] = '\u0028\u1107\u0029';
  22308. t['\u3206'] = '\u0028\u1109\u0029';
  22309. t['\u3207'] = '\u0028\u110B\u0029';
  22310. t['\u3208'] = '\u0028\u110C\u0029';
  22311. t['\u3209'] = '\u0028\u110E\u0029';
  22312. t['\u320A'] = '\u0028\u110F\u0029';
  22313. t['\u320B'] = '\u0028\u1110\u0029';
  22314. t['\u320C'] = '\u0028\u1111\u0029';
  22315. t['\u320D'] = '\u0028\u1112\u0029';
  22316. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  22317. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  22318. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  22319. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  22320. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  22321. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  22322. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  22323. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  22324. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  22325. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  22326. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  22327. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  22328. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  22329. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  22330. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  22331. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  22332. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  22333. t['\u3220'] = '\u0028\u4E00\u0029';
  22334. t['\u3221'] = '\u0028\u4E8C\u0029';
  22335. t['\u3222'] = '\u0028\u4E09\u0029';
  22336. t['\u3223'] = '\u0028\u56DB\u0029';
  22337. t['\u3224'] = '\u0028\u4E94\u0029';
  22338. t['\u3225'] = '\u0028\u516D\u0029';
  22339. t['\u3226'] = '\u0028\u4E03\u0029';
  22340. t['\u3227'] = '\u0028\u516B\u0029';
  22341. t['\u3228'] = '\u0028\u4E5D\u0029';
  22342. t['\u3229'] = '\u0028\u5341\u0029';
  22343. t['\u322A'] = '\u0028\u6708\u0029';
  22344. t['\u322B'] = '\u0028\u706B\u0029';
  22345. t['\u322C'] = '\u0028\u6C34\u0029';
  22346. t['\u322D'] = '\u0028\u6728\u0029';
  22347. t['\u322E'] = '\u0028\u91D1\u0029';
  22348. t['\u322F'] = '\u0028\u571F\u0029';
  22349. t['\u3230'] = '\u0028\u65E5\u0029';
  22350. t['\u3231'] = '\u0028\u682A\u0029';
  22351. t['\u3232'] = '\u0028\u6709\u0029';
  22352. t['\u3233'] = '\u0028\u793E\u0029';
  22353. t['\u3234'] = '\u0028\u540D\u0029';
  22354. t['\u3235'] = '\u0028\u7279\u0029';
  22355. t['\u3236'] = '\u0028\u8CA1\u0029';
  22356. t['\u3237'] = '\u0028\u795D\u0029';
  22357. t['\u3238'] = '\u0028\u52B4\u0029';
  22358. t['\u3239'] = '\u0028\u4EE3\u0029';
  22359. t['\u323A'] = '\u0028\u547C\u0029';
  22360. t['\u323B'] = '\u0028\u5B66\u0029';
  22361. t['\u323C'] = '\u0028\u76E3\u0029';
  22362. t['\u323D'] = '\u0028\u4F01\u0029';
  22363. t['\u323E'] = '\u0028\u8CC7\u0029';
  22364. t['\u323F'] = '\u0028\u5354\u0029';
  22365. t['\u3240'] = '\u0028\u796D\u0029';
  22366. t['\u3241'] = '\u0028\u4F11\u0029';
  22367. t['\u3242'] = '\u0028\u81EA\u0029';
  22368. t['\u3243'] = '\u0028\u81F3\u0029';
  22369. t['\u32C0'] = '\u0031\u6708';
  22370. t['\u32C1'] = '\u0032\u6708';
  22371. t['\u32C2'] = '\u0033\u6708';
  22372. t['\u32C3'] = '\u0034\u6708';
  22373. t['\u32C4'] = '\u0035\u6708';
  22374. t['\u32C5'] = '\u0036\u6708';
  22375. t['\u32C6'] = '\u0037\u6708';
  22376. t['\u32C7'] = '\u0038\u6708';
  22377. t['\u32C8'] = '\u0039\u6708';
  22378. t['\u32C9'] = '\u0031\u0030\u6708';
  22379. t['\u32CA'] = '\u0031\u0031\u6708';
  22380. t['\u32CB'] = '\u0031\u0032\u6708';
  22381. t['\u3358'] = '\u0030\u70B9';
  22382. t['\u3359'] = '\u0031\u70B9';
  22383. t['\u335A'] = '\u0032\u70B9';
  22384. t['\u335B'] = '\u0033\u70B9';
  22385. t['\u335C'] = '\u0034\u70B9';
  22386. t['\u335D'] = '\u0035\u70B9';
  22387. t['\u335E'] = '\u0036\u70B9';
  22388. t['\u335F'] = '\u0037\u70B9';
  22389. t['\u3360'] = '\u0038\u70B9';
  22390. t['\u3361'] = '\u0039\u70B9';
  22391. t['\u3362'] = '\u0031\u0030\u70B9';
  22392. t['\u3363'] = '\u0031\u0031\u70B9';
  22393. t['\u3364'] = '\u0031\u0032\u70B9';
  22394. t['\u3365'] = '\u0031\u0033\u70B9';
  22395. t['\u3366'] = '\u0031\u0034\u70B9';
  22396. t['\u3367'] = '\u0031\u0035\u70B9';
  22397. t['\u3368'] = '\u0031\u0036\u70B9';
  22398. t['\u3369'] = '\u0031\u0037\u70B9';
  22399. t['\u336A'] = '\u0031\u0038\u70B9';
  22400. t['\u336B'] = '\u0031\u0039\u70B9';
  22401. t['\u336C'] = '\u0032\u0030\u70B9';
  22402. t['\u336D'] = '\u0032\u0031\u70B9';
  22403. t['\u336E'] = '\u0032\u0032\u70B9';
  22404. t['\u336F'] = '\u0032\u0033\u70B9';
  22405. t['\u3370'] = '\u0032\u0034\u70B9';
  22406. t['\u33E0'] = '\u0031\u65E5';
  22407. t['\u33E1'] = '\u0032\u65E5';
  22408. t['\u33E2'] = '\u0033\u65E5';
  22409. t['\u33E3'] = '\u0034\u65E5';
  22410. t['\u33E4'] = '\u0035\u65E5';
  22411. t['\u33E5'] = '\u0036\u65E5';
  22412. t['\u33E6'] = '\u0037\u65E5';
  22413. t['\u33E7'] = '\u0038\u65E5';
  22414. t['\u33E8'] = '\u0039\u65E5';
  22415. t['\u33E9'] = '\u0031\u0030\u65E5';
  22416. t['\u33EA'] = '\u0031\u0031\u65E5';
  22417. t['\u33EB'] = '\u0031\u0032\u65E5';
  22418. t['\u33EC'] = '\u0031\u0033\u65E5';
  22419. t['\u33ED'] = '\u0031\u0034\u65E5';
  22420. t['\u33EE'] = '\u0031\u0035\u65E5';
  22421. t['\u33EF'] = '\u0031\u0036\u65E5';
  22422. t['\u33F0'] = '\u0031\u0037\u65E5';
  22423. t['\u33F1'] = '\u0031\u0038\u65E5';
  22424. t['\u33F2'] = '\u0031\u0039\u65E5';
  22425. t['\u33F3'] = '\u0032\u0030\u65E5';
  22426. t['\u33F4'] = '\u0032\u0031\u65E5';
  22427. t['\u33F5'] = '\u0032\u0032\u65E5';
  22428. t['\u33F6'] = '\u0032\u0033\u65E5';
  22429. t['\u33F7'] = '\u0032\u0034\u65E5';
  22430. t['\u33F8'] = '\u0032\u0035\u65E5';
  22431. t['\u33F9'] = '\u0032\u0036\u65E5';
  22432. t['\u33FA'] = '\u0032\u0037\u65E5';
  22433. t['\u33FB'] = '\u0032\u0038\u65E5';
  22434. t['\u33FC'] = '\u0032\u0039\u65E5';
  22435. t['\u33FD'] = '\u0033\u0030\u65E5';
  22436. t['\u33FE'] = '\u0033\u0031\u65E5';
  22437. t['\uFB00'] = '\u0066\u0066';
  22438. t['\uFB01'] = '\u0066\u0069';
  22439. t['\uFB02'] = '\u0066\u006C';
  22440. t['\uFB03'] = '\u0066\u0066\u0069';
  22441. t['\uFB04'] = '\u0066\u0066\u006C';
  22442. t['\uFB05'] = '\u017F\u0074';
  22443. t['\uFB06'] = '\u0073\u0074';
  22444. t['\uFB13'] = '\u0574\u0576';
  22445. t['\uFB14'] = '\u0574\u0565';
  22446. t['\uFB15'] = '\u0574\u056B';
  22447. t['\uFB16'] = '\u057E\u0576';
  22448. t['\uFB17'] = '\u0574\u056D';
  22449. t['\uFB4F'] = '\u05D0\u05DC';
  22450. t['\uFB50'] = '\u0671';
  22451. t['\uFB51'] = '\u0671';
  22452. t['\uFB52'] = '\u067B';
  22453. t['\uFB53'] = '\u067B';
  22454. t['\uFB54'] = '\u067B';
  22455. t['\uFB55'] = '\u067B';
  22456. t['\uFB56'] = '\u067E';
  22457. t['\uFB57'] = '\u067E';
  22458. t['\uFB58'] = '\u067E';
  22459. t['\uFB59'] = '\u067E';
  22460. t['\uFB5A'] = '\u0680';
  22461. t['\uFB5B'] = '\u0680';
  22462. t['\uFB5C'] = '\u0680';
  22463. t['\uFB5D'] = '\u0680';
  22464. t['\uFB5E'] = '\u067A';
  22465. t['\uFB5F'] = '\u067A';
  22466. t['\uFB60'] = '\u067A';
  22467. t['\uFB61'] = '\u067A';
  22468. t['\uFB62'] = '\u067F';
  22469. t['\uFB63'] = '\u067F';
  22470. t['\uFB64'] = '\u067F';
  22471. t['\uFB65'] = '\u067F';
  22472. t['\uFB66'] = '\u0679';
  22473. t['\uFB67'] = '\u0679';
  22474. t['\uFB68'] = '\u0679';
  22475. t['\uFB69'] = '\u0679';
  22476. t['\uFB6A'] = '\u06A4';
  22477. t['\uFB6B'] = '\u06A4';
  22478. t['\uFB6C'] = '\u06A4';
  22479. t['\uFB6D'] = '\u06A4';
  22480. t['\uFB6E'] = '\u06A6';
  22481. t['\uFB6F'] = '\u06A6';
  22482. t['\uFB70'] = '\u06A6';
  22483. t['\uFB71'] = '\u06A6';
  22484. t['\uFB72'] = '\u0684';
  22485. t['\uFB73'] = '\u0684';
  22486. t['\uFB74'] = '\u0684';
  22487. t['\uFB75'] = '\u0684';
  22488. t['\uFB76'] = '\u0683';
  22489. t['\uFB77'] = '\u0683';
  22490. t['\uFB78'] = '\u0683';
  22491. t['\uFB79'] = '\u0683';
  22492. t['\uFB7A'] = '\u0686';
  22493. t['\uFB7B'] = '\u0686';
  22494. t['\uFB7C'] = '\u0686';
  22495. t['\uFB7D'] = '\u0686';
  22496. t['\uFB7E'] = '\u0687';
  22497. t['\uFB7F'] = '\u0687';
  22498. t['\uFB80'] = '\u0687';
  22499. t['\uFB81'] = '\u0687';
  22500. t['\uFB82'] = '\u068D';
  22501. t['\uFB83'] = '\u068D';
  22502. t['\uFB84'] = '\u068C';
  22503. t['\uFB85'] = '\u068C';
  22504. t['\uFB86'] = '\u068E';
  22505. t['\uFB87'] = '\u068E';
  22506. t['\uFB88'] = '\u0688';
  22507. t['\uFB89'] = '\u0688';
  22508. t['\uFB8A'] = '\u0698';
  22509. t['\uFB8B'] = '\u0698';
  22510. t['\uFB8C'] = '\u0691';
  22511. t['\uFB8D'] = '\u0691';
  22512. t['\uFB8E'] = '\u06A9';
  22513. t['\uFB8F'] = '\u06A9';
  22514. t['\uFB90'] = '\u06A9';
  22515. t['\uFB91'] = '\u06A9';
  22516. t['\uFB92'] = '\u06AF';
  22517. t['\uFB93'] = '\u06AF';
  22518. t['\uFB94'] = '\u06AF';
  22519. t['\uFB95'] = '\u06AF';
  22520. t['\uFB96'] = '\u06B3';
  22521. t['\uFB97'] = '\u06B3';
  22522. t['\uFB98'] = '\u06B3';
  22523. t['\uFB99'] = '\u06B3';
  22524. t['\uFB9A'] = '\u06B1';
  22525. t['\uFB9B'] = '\u06B1';
  22526. t['\uFB9C'] = '\u06B1';
  22527. t['\uFB9D'] = '\u06B1';
  22528. t['\uFB9E'] = '\u06BA';
  22529. t['\uFB9F'] = '\u06BA';
  22530. t['\uFBA0'] = '\u06BB';
  22531. t['\uFBA1'] = '\u06BB';
  22532. t['\uFBA2'] = '\u06BB';
  22533. t['\uFBA3'] = '\u06BB';
  22534. t['\uFBA4'] = '\u06C0';
  22535. t['\uFBA5'] = '\u06C0';
  22536. t['\uFBA6'] = '\u06C1';
  22537. t['\uFBA7'] = '\u06C1';
  22538. t['\uFBA8'] = '\u06C1';
  22539. t['\uFBA9'] = '\u06C1';
  22540. t['\uFBAA'] = '\u06BE';
  22541. t['\uFBAB'] = '\u06BE';
  22542. t['\uFBAC'] = '\u06BE';
  22543. t['\uFBAD'] = '\u06BE';
  22544. t['\uFBAE'] = '\u06D2';
  22545. t['\uFBAF'] = '\u06D2';
  22546. t['\uFBB0'] = '\u06D3';
  22547. t['\uFBB1'] = '\u06D3';
  22548. t['\uFBD3'] = '\u06AD';
  22549. t['\uFBD4'] = '\u06AD';
  22550. t['\uFBD5'] = '\u06AD';
  22551. t['\uFBD6'] = '\u06AD';
  22552. t['\uFBD7'] = '\u06C7';
  22553. t['\uFBD8'] = '\u06C7';
  22554. t['\uFBD9'] = '\u06C6';
  22555. t['\uFBDA'] = '\u06C6';
  22556. t['\uFBDB'] = '\u06C8';
  22557. t['\uFBDC'] = '\u06C8';
  22558. t['\uFBDD'] = '\u0677';
  22559. t['\uFBDE'] = '\u06CB';
  22560. t['\uFBDF'] = '\u06CB';
  22561. t['\uFBE0'] = '\u06C5';
  22562. t['\uFBE1'] = '\u06C5';
  22563. t['\uFBE2'] = '\u06C9';
  22564. t['\uFBE3'] = '\u06C9';
  22565. t['\uFBE4'] = '\u06D0';
  22566. t['\uFBE5'] = '\u06D0';
  22567. t['\uFBE6'] = '\u06D0';
  22568. t['\uFBE7'] = '\u06D0';
  22569. t['\uFBE8'] = '\u0649';
  22570. t['\uFBE9'] = '\u0649';
  22571. t['\uFBEA'] = '\u0626\u0627';
  22572. t['\uFBEB'] = '\u0626\u0627';
  22573. t['\uFBEC'] = '\u0626\u06D5';
  22574. t['\uFBED'] = '\u0626\u06D5';
  22575. t['\uFBEE'] = '\u0626\u0648';
  22576. t['\uFBEF'] = '\u0626\u0648';
  22577. t['\uFBF0'] = '\u0626\u06C7';
  22578. t['\uFBF1'] = '\u0626\u06C7';
  22579. t['\uFBF2'] = '\u0626\u06C6';
  22580. t['\uFBF3'] = '\u0626\u06C6';
  22581. t['\uFBF4'] = '\u0626\u06C8';
  22582. t['\uFBF5'] = '\u0626\u06C8';
  22583. t['\uFBF6'] = '\u0626\u06D0';
  22584. t['\uFBF7'] = '\u0626\u06D0';
  22585. t['\uFBF8'] = '\u0626\u06D0';
  22586. t['\uFBF9'] = '\u0626\u0649';
  22587. t['\uFBFA'] = '\u0626\u0649';
  22588. t['\uFBFB'] = '\u0626\u0649';
  22589. t['\uFBFC'] = '\u06CC';
  22590. t['\uFBFD'] = '\u06CC';
  22591. t['\uFBFE'] = '\u06CC';
  22592. t['\uFBFF'] = '\u06CC';
  22593. t['\uFC00'] = '\u0626\u062C';
  22594. t['\uFC01'] = '\u0626\u062D';
  22595. t['\uFC02'] = '\u0626\u0645';
  22596. t['\uFC03'] = '\u0626\u0649';
  22597. t['\uFC04'] = '\u0626\u064A';
  22598. t['\uFC05'] = '\u0628\u062C';
  22599. t['\uFC06'] = '\u0628\u062D';
  22600. t['\uFC07'] = '\u0628\u062E';
  22601. t['\uFC08'] = '\u0628\u0645';
  22602. t['\uFC09'] = '\u0628\u0649';
  22603. t['\uFC0A'] = '\u0628\u064A';
  22604. t['\uFC0B'] = '\u062A\u062C';
  22605. t['\uFC0C'] = '\u062A\u062D';
  22606. t['\uFC0D'] = '\u062A\u062E';
  22607. t['\uFC0E'] = '\u062A\u0645';
  22608. t['\uFC0F'] = '\u062A\u0649';
  22609. t['\uFC10'] = '\u062A\u064A';
  22610. t['\uFC11'] = '\u062B\u062C';
  22611. t['\uFC12'] = '\u062B\u0645';
  22612. t['\uFC13'] = '\u062B\u0649';
  22613. t['\uFC14'] = '\u062B\u064A';
  22614. t['\uFC15'] = '\u062C\u062D';
  22615. t['\uFC16'] = '\u062C\u0645';
  22616. t['\uFC17'] = '\u062D\u062C';
  22617. t['\uFC18'] = '\u062D\u0645';
  22618. t['\uFC19'] = '\u062E\u062C';
  22619. t['\uFC1A'] = '\u062E\u062D';
  22620. t['\uFC1B'] = '\u062E\u0645';
  22621. t['\uFC1C'] = '\u0633\u062C';
  22622. t['\uFC1D'] = '\u0633\u062D';
  22623. t['\uFC1E'] = '\u0633\u062E';
  22624. t['\uFC1F'] = '\u0633\u0645';
  22625. t['\uFC20'] = '\u0635\u062D';
  22626. t['\uFC21'] = '\u0635\u0645';
  22627. t['\uFC22'] = '\u0636\u062C';
  22628. t['\uFC23'] = '\u0636\u062D';
  22629. t['\uFC24'] = '\u0636\u062E';
  22630. t['\uFC25'] = '\u0636\u0645';
  22631. t['\uFC26'] = '\u0637\u062D';
  22632. t['\uFC27'] = '\u0637\u0645';
  22633. t['\uFC28'] = '\u0638\u0645';
  22634. t['\uFC29'] = '\u0639\u062C';
  22635. t['\uFC2A'] = '\u0639\u0645';
  22636. t['\uFC2B'] = '\u063A\u062C';
  22637. t['\uFC2C'] = '\u063A\u0645';
  22638. t['\uFC2D'] = '\u0641\u062C';
  22639. t['\uFC2E'] = '\u0641\u062D';
  22640. t['\uFC2F'] = '\u0641\u062E';
  22641. t['\uFC30'] = '\u0641\u0645';
  22642. t['\uFC31'] = '\u0641\u0649';
  22643. t['\uFC32'] = '\u0641\u064A';
  22644. t['\uFC33'] = '\u0642\u062D';
  22645. t['\uFC34'] = '\u0642\u0645';
  22646. t['\uFC35'] = '\u0642\u0649';
  22647. t['\uFC36'] = '\u0642\u064A';
  22648. t['\uFC37'] = '\u0643\u0627';
  22649. t['\uFC38'] = '\u0643\u062C';
  22650. t['\uFC39'] = '\u0643\u062D';
  22651. t['\uFC3A'] = '\u0643\u062E';
  22652. t['\uFC3B'] = '\u0643\u0644';
  22653. t['\uFC3C'] = '\u0643\u0645';
  22654. t['\uFC3D'] = '\u0643\u0649';
  22655. t['\uFC3E'] = '\u0643\u064A';
  22656. t['\uFC3F'] = '\u0644\u062C';
  22657. t['\uFC40'] = '\u0644\u062D';
  22658. t['\uFC41'] = '\u0644\u062E';
  22659. t['\uFC42'] = '\u0644\u0645';
  22660. t['\uFC43'] = '\u0644\u0649';
  22661. t['\uFC44'] = '\u0644\u064A';
  22662. t['\uFC45'] = '\u0645\u062C';
  22663. t['\uFC46'] = '\u0645\u062D';
  22664. t['\uFC47'] = '\u0645\u062E';
  22665. t['\uFC48'] = '\u0645\u0645';
  22666. t['\uFC49'] = '\u0645\u0649';
  22667. t['\uFC4A'] = '\u0645\u064A';
  22668. t['\uFC4B'] = '\u0646\u062C';
  22669. t['\uFC4C'] = '\u0646\u062D';
  22670. t['\uFC4D'] = '\u0646\u062E';
  22671. t['\uFC4E'] = '\u0646\u0645';
  22672. t['\uFC4F'] = '\u0646\u0649';
  22673. t['\uFC50'] = '\u0646\u064A';
  22674. t['\uFC51'] = '\u0647\u062C';
  22675. t['\uFC52'] = '\u0647\u0645';
  22676. t['\uFC53'] = '\u0647\u0649';
  22677. t['\uFC54'] = '\u0647\u064A';
  22678. t['\uFC55'] = '\u064A\u062C';
  22679. t['\uFC56'] = '\u064A\u062D';
  22680. t['\uFC57'] = '\u064A\u062E';
  22681. t['\uFC58'] = '\u064A\u0645';
  22682. t['\uFC59'] = '\u064A\u0649';
  22683. t['\uFC5A'] = '\u064A\u064A';
  22684. t['\uFC5B'] = '\u0630\u0670';
  22685. t['\uFC5C'] = '\u0631\u0670';
  22686. t['\uFC5D'] = '\u0649\u0670';
  22687. t['\uFC5E'] = '\u0020\u064C\u0651';
  22688. t['\uFC5F'] = '\u0020\u064D\u0651';
  22689. t['\uFC60'] = '\u0020\u064E\u0651';
  22690. t['\uFC61'] = '\u0020\u064F\u0651';
  22691. t['\uFC62'] = '\u0020\u0650\u0651';
  22692. t['\uFC63'] = '\u0020\u0651\u0670';
  22693. t['\uFC64'] = '\u0626\u0631';
  22694. t['\uFC65'] = '\u0626\u0632';
  22695. t['\uFC66'] = '\u0626\u0645';
  22696. t['\uFC67'] = '\u0626\u0646';
  22697. t['\uFC68'] = '\u0626\u0649';
  22698. t['\uFC69'] = '\u0626\u064A';
  22699. t['\uFC6A'] = '\u0628\u0631';
  22700. t['\uFC6B'] = '\u0628\u0632';
  22701. t['\uFC6C'] = '\u0628\u0645';
  22702. t['\uFC6D'] = '\u0628\u0646';
  22703. t['\uFC6E'] = '\u0628\u0649';
  22704. t['\uFC6F'] = '\u0628\u064A';
  22705. t['\uFC70'] = '\u062A\u0631';
  22706. t['\uFC71'] = '\u062A\u0632';
  22707. t['\uFC72'] = '\u062A\u0645';
  22708. t['\uFC73'] = '\u062A\u0646';
  22709. t['\uFC74'] = '\u062A\u0649';
  22710. t['\uFC75'] = '\u062A\u064A';
  22711. t['\uFC76'] = '\u062B\u0631';
  22712. t['\uFC77'] = '\u062B\u0632';
  22713. t['\uFC78'] = '\u062B\u0645';
  22714. t['\uFC79'] = '\u062B\u0646';
  22715. t['\uFC7A'] = '\u062B\u0649';
  22716. t['\uFC7B'] = '\u062B\u064A';
  22717. t['\uFC7C'] = '\u0641\u0649';
  22718. t['\uFC7D'] = '\u0641\u064A';
  22719. t['\uFC7E'] = '\u0642\u0649';
  22720. t['\uFC7F'] = '\u0642\u064A';
  22721. t['\uFC80'] = '\u0643\u0627';
  22722. t['\uFC81'] = '\u0643\u0644';
  22723. t['\uFC82'] = '\u0643\u0645';
  22724. t['\uFC83'] = '\u0643\u0649';
  22725. t['\uFC84'] = '\u0643\u064A';
  22726. t['\uFC85'] = '\u0644\u0645';
  22727. t['\uFC86'] = '\u0644\u0649';
  22728. t['\uFC87'] = '\u0644\u064A';
  22729. t['\uFC88'] = '\u0645\u0627';
  22730. t['\uFC89'] = '\u0645\u0645';
  22731. t['\uFC8A'] = '\u0646\u0631';
  22732. t['\uFC8B'] = '\u0646\u0632';
  22733. t['\uFC8C'] = '\u0646\u0645';
  22734. t['\uFC8D'] = '\u0646\u0646';
  22735. t['\uFC8E'] = '\u0646\u0649';
  22736. t['\uFC8F'] = '\u0646\u064A';
  22737. t['\uFC90'] = '\u0649\u0670';
  22738. t['\uFC91'] = '\u064A\u0631';
  22739. t['\uFC92'] = '\u064A\u0632';
  22740. t['\uFC93'] = '\u064A\u0645';
  22741. t['\uFC94'] = '\u064A\u0646';
  22742. t['\uFC95'] = '\u064A\u0649';
  22743. t['\uFC96'] = '\u064A\u064A';
  22744. t['\uFC97'] = '\u0626\u062C';
  22745. t['\uFC98'] = '\u0626\u062D';
  22746. t['\uFC99'] = '\u0626\u062E';
  22747. t['\uFC9A'] = '\u0626\u0645';
  22748. t['\uFC9B'] = '\u0626\u0647';
  22749. t['\uFC9C'] = '\u0628\u062C';
  22750. t['\uFC9D'] = '\u0628\u062D';
  22751. t['\uFC9E'] = '\u0628\u062E';
  22752. t['\uFC9F'] = '\u0628\u0645';
  22753. t['\uFCA0'] = '\u0628\u0647';
  22754. t['\uFCA1'] = '\u062A\u062C';
  22755. t['\uFCA2'] = '\u062A\u062D';
  22756. t['\uFCA3'] = '\u062A\u062E';
  22757. t['\uFCA4'] = '\u062A\u0645';
  22758. t['\uFCA5'] = '\u062A\u0647';
  22759. t['\uFCA6'] = '\u062B\u0645';
  22760. t['\uFCA7'] = '\u062C\u062D';
  22761. t['\uFCA8'] = '\u062C\u0645';
  22762. t['\uFCA9'] = '\u062D\u062C';
  22763. t['\uFCAA'] = '\u062D\u0645';
  22764. t['\uFCAB'] = '\u062E\u062C';
  22765. t['\uFCAC'] = '\u062E\u0645';
  22766. t['\uFCAD'] = '\u0633\u062C';
  22767. t['\uFCAE'] = '\u0633\u062D';
  22768. t['\uFCAF'] = '\u0633\u062E';
  22769. t['\uFCB0'] = '\u0633\u0645';
  22770. t['\uFCB1'] = '\u0635\u062D';
  22771. t['\uFCB2'] = '\u0635\u062E';
  22772. t['\uFCB3'] = '\u0635\u0645';
  22773. t['\uFCB4'] = '\u0636\u062C';
  22774. t['\uFCB5'] = '\u0636\u062D';
  22775. t['\uFCB6'] = '\u0636\u062E';
  22776. t['\uFCB7'] = '\u0636\u0645';
  22777. t['\uFCB8'] = '\u0637\u062D';
  22778. t['\uFCB9'] = '\u0638\u0645';
  22779. t['\uFCBA'] = '\u0639\u062C';
  22780. t['\uFCBB'] = '\u0639\u0645';
  22781. t['\uFCBC'] = '\u063A\u062C';
  22782. t['\uFCBD'] = '\u063A\u0645';
  22783. t['\uFCBE'] = '\u0641\u062C';
  22784. t['\uFCBF'] = '\u0641\u062D';
  22785. t['\uFCC0'] = '\u0641\u062E';
  22786. t['\uFCC1'] = '\u0641\u0645';
  22787. t['\uFCC2'] = '\u0642\u062D';
  22788. t['\uFCC3'] = '\u0642\u0645';
  22789. t['\uFCC4'] = '\u0643\u062C';
  22790. t['\uFCC5'] = '\u0643\u062D';
  22791. t['\uFCC6'] = '\u0643\u062E';
  22792. t['\uFCC7'] = '\u0643\u0644';
  22793. t['\uFCC8'] = '\u0643\u0645';
  22794. t['\uFCC9'] = '\u0644\u062C';
  22795. t['\uFCCA'] = '\u0644\u062D';
  22796. t['\uFCCB'] = '\u0644\u062E';
  22797. t['\uFCCC'] = '\u0644\u0645';
  22798. t['\uFCCD'] = '\u0644\u0647';
  22799. t['\uFCCE'] = '\u0645\u062C';
  22800. t['\uFCCF'] = '\u0645\u062D';
  22801. t['\uFCD0'] = '\u0645\u062E';
  22802. t['\uFCD1'] = '\u0645\u0645';
  22803. t['\uFCD2'] = '\u0646\u062C';
  22804. t['\uFCD3'] = '\u0646\u062D';
  22805. t['\uFCD4'] = '\u0646\u062E';
  22806. t['\uFCD5'] = '\u0646\u0645';
  22807. t['\uFCD6'] = '\u0646\u0647';
  22808. t['\uFCD7'] = '\u0647\u062C';
  22809. t['\uFCD8'] = '\u0647\u0645';
  22810. t['\uFCD9'] = '\u0647\u0670';
  22811. t['\uFCDA'] = '\u064A\u062C';
  22812. t['\uFCDB'] = '\u064A\u062D';
  22813. t['\uFCDC'] = '\u064A\u062E';
  22814. t['\uFCDD'] = '\u064A\u0645';
  22815. t['\uFCDE'] = '\u064A\u0647';
  22816. t['\uFCDF'] = '\u0626\u0645';
  22817. t['\uFCE0'] = '\u0626\u0647';
  22818. t['\uFCE1'] = '\u0628\u0645';
  22819. t['\uFCE2'] = '\u0628\u0647';
  22820. t['\uFCE3'] = '\u062A\u0645';
  22821. t['\uFCE4'] = '\u062A\u0647';
  22822. t['\uFCE5'] = '\u062B\u0645';
  22823. t['\uFCE6'] = '\u062B\u0647';
  22824. t['\uFCE7'] = '\u0633\u0645';
  22825. t['\uFCE8'] = '\u0633\u0647';
  22826. t['\uFCE9'] = '\u0634\u0645';
  22827. t['\uFCEA'] = '\u0634\u0647';
  22828. t['\uFCEB'] = '\u0643\u0644';
  22829. t['\uFCEC'] = '\u0643\u0645';
  22830. t['\uFCED'] = '\u0644\u0645';
  22831. t['\uFCEE'] = '\u0646\u0645';
  22832. t['\uFCEF'] = '\u0646\u0647';
  22833. t['\uFCF0'] = '\u064A\u0645';
  22834. t['\uFCF1'] = '\u064A\u0647';
  22835. t['\uFCF2'] = '\u0640\u064E\u0651';
  22836. t['\uFCF3'] = '\u0640\u064F\u0651';
  22837. t['\uFCF4'] = '\u0640\u0650\u0651';
  22838. t['\uFCF5'] = '\u0637\u0649';
  22839. t['\uFCF6'] = '\u0637\u064A';
  22840. t['\uFCF7'] = '\u0639\u0649';
  22841. t['\uFCF8'] = '\u0639\u064A';
  22842. t['\uFCF9'] = '\u063A\u0649';
  22843. t['\uFCFA'] = '\u063A\u064A';
  22844. t['\uFCFB'] = '\u0633\u0649';
  22845. t['\uFCFC'] = '\u0633\u064A';
  22846. t['\uFCFD'] = '\u0634\u0649';
  22847. t['\uFCFE'] = '\u0634\u064A';
  22848. t['\uFCFF'] = '\u062D\u0649';
  22849. t['\uFD00'] = '\u062D\u064A';
  22850. t['\uFD01'] = '\u062C\u0649';
  22851. t['\uFD02'] = '\u062C\u064A';
  22852. t['\uFD03'] = '\u062E\u0649';
  22853. t['\uFD04'] = '\u062E\u064A';
  22854. t['\uFD05'] = '\u0635\u0649';
  22855. t['\uFD06'] = '\u0635\u064A';
  22856. t['\uFD07'] = '\u0636\u0649';
  22857. t['\uFD08'] = '\u0636\u064A';
  22858. t['\uFD09'] = '\u0634\u062C';
  22859. t['\uFD0A'] = '\u0634\u062D';
  22860. t['\uFD0B'] = '\u0634\u062E';
  22861. t['\uFD0C'] = '\u0634\u0645';
  22862. t['\uFD0D'] = '\u0634\u0631';
  22863. t['\uFD0E'] = '\u0633\u0631';
  22864. t['\uFD0F'] = '\u0635\u0631';
  22865. t['\uFD10'] = '\u0636\u0631';
  22866. t['\uFD11'] = '\u0637\u0649';
  22867. t['\uFD12'] = '\u0637\u064A';
  22868. t['\uFD13'] = '\u0639\u0649';
  22869. t['\uFD14'] = '\u0639\u064A';
  22870. t['\uFD15'] = '\u063A\u0649';
  22871. t['\uFD16'] = '\u063A\u064A';
  22872. t['\uFD17'] = '\u0633\u0649';
  22873. t['\uFD18'] = '\u0633\u064A';
  22874. t['\uFD19'] = '\u0634\u0649';
  22875. t['\uFD1A'] = '\u0634\u064A';
  22876. t['\uFD1B'] = '\u062D\u0649';
  22877. t['\uFD1C'] = '\u062D\u064A';
  22878. t['\uFD1D'] = '\u062C\u0649';
  22879. t['\uFD1E'] = '\u062C\u064A';
  22880. t['\uFD1F'] = '\u062E\u0649';
  22881. t['\uFD20'] = '\u062E\u064A';
  22882. t['\uFD21'] = '\u0635\u0649';
  22883. t['\uFD22'] = '\u0635\u064A';
  22884. t['\uFD23'] = '\u0636\u0649';
  22885. t['\uFD24'] = '\u0636\u064A';
  22886. t['\uFD25'] = '\u0634\u062C';
  22887. t['\uFD26'] = '\u0634\u062D';
  22888. t['\uFD27'] = '\u0634\u062E';
  22889. t['\uFD28'] = '\u0634\u0645';
  22890. t['\uFD29'] = '\u0634\u0631';
  22891. t['\uFD2A'] = '\u0633\u0631';
  22892. t['\uFD2B'] = '\u0635\u0631';
  22893. t['\uFD2C'] = '\u0636\u0631';
  22894. t['\uFD2D'] = '\u0634\u062C';
  22895. t['\uFD2E'] = '\u0634\u062D';
  22896. t['\uFD2F'] = '\u0634\u062E';
  22897. t['\uFD30'] = '\u0634\u0645';
  22898. t['\uFD31'] = '\u0633\u0647';
  22899. t['\uFD32'] = '\u0634\u0647';
  22900. t['\uFD33'] = '\u0637\u0645';
  22901. t['\uFD34'] = '\u0633\u062C';
  22902. t['\uFD35'] = '\u0633\u062D';
  22903. t['\uFD36'] = '\u0633\u062E';
  22904. t['\uFD37'] = '\u0634\u062C';
  22905. t['\uFD38'] = '\u0634\u062D';
  22906. t['\uFD39'] = '\u0634\u062E';
  22907. t['\uFD3A'] = '\u0637\u0645';
  22908. t['\uFD3B'] = '\u0638\u0645';
  22909. t['\uFD3C'] = '\u0627\u064B';
  22910. t['\uFD3D'] = '\u0627\u064B';
  22911. t['\uFD50'] = '\u062A\u062C\u0645';
  22912. t['\uFD51'] = '\u062A\u062D\u062C';
  22913. t['\uFD52'] = '\u062A\u062D\u062C';
  22914. t['\uFD53'] = '\u062A\u062D\u0645';
  22915. t['\uFD54'] = '\u062A\u062E\u0645';
  22916. t['\uFD55'] = '\u062A\u0645\u062C';
  22917. t['\uFD56'] = '\u062A\u0645\u062D';
  22918. t['\uFD57'] = '\u062A\u0645\u062E';
  22919. t['\uFD58'] = '\u062C\u0645\u062D';
  22920. t['\uFD59'] = '\u062C\u0645\u062D';
  22921. t['\uFD5A'] = '\u062D\u0645\u064A';
  22922. t['\uFD5B'] = '\u062D\u0645\u0649';
  22923. t['\uFD5C'] = '\u0633\u062D\u062C';
  22924. t['\uFD5D'] = '\u0633\u062C\u062D';
  22925. t['\uFD5E'] = '\u0633\u062C\u0649';
  22926. t['\uFD5F'] = '\u0633\u0645\u062D';
  22927. t['\uFD60'] = '\u0633\u0645\u062D';
  22928. t['\uFD61'] = '\u0633\u0645\u062C';
  22929. t['\uFD62'] = '\u0633\u0645\u0645';
  22930. t['\uFD63'] = '\u0633\u0645\u0645';
  22931. t['\uFD64'] = '\u0635\u062D\u062D';
  22932. t['\uFD65'] = '\u0635\u062D\u062D';
  22933. t['\uFD66'] = '\u0635\u0645\u0645';
  22934. t['\uFD67'] = '\u0634\u062D\u0645';
  22935. t['\uFD68'] = '\u0634\u062D\u0645';
  22936. t['\uFD69'] = '\u0634\u062C\u064A';
  22937. t['\uFD6A'] = '\u0634\u0645\u062E';
  22938. t['\uFD6B'] = '\u0634\u0645\u062E';
  22939. t['\uFD6C'] = '\u0634\u0645\u0645';
  22940. t['\uFD6D'] = '\u0634\u0645\u0645';
  22941. t['\uFD6E'] = '\u0636\u062D\u0649';
  22942. t['\uFD6F'] = '\u0636\u062E\u0645';
  22943. t['\uFD70'] = '\u0636\u062E\u0645';
  22944. t['\uFD71'] = '\u0637\u0645\u062D';
  22945. t['\uFD72'] = '\u0637\u0645\u062D';
  22946. t['\uFD73'] = '\u0637\u0645\u0645';
  22947. t['\uFD74'] = '\u0637\u0645\u064A';
  22948. t['\uFD75'] = '\u0639\u062C\u0645';
  22949. t['\uFD76'] = '\u0639\u0645\u0645';
  22950. t['\uFD77'] = '\u0639\u0645\u0645';
  22951. t['\uFD78'] = '\u0639\u0645\u0649';
  22952. t['\uFD79'] = '\u063A\u0645\u0645';
  22953. t['\uFD7A'] = '\u063A\u0645\u064A';
  22954. t['\uFD7B'] = '\u063A\u0645\u0649';
  22955. t['\uFD7C'] = '\u0641\u062E\u0645';
  22956. t['\uFD7D'] = '\u0641\u062E\u0645';
  22957. t['\uFD7E'] = '\u0642\u0645\u062D';
  22958. t['\uFD7F'] = '\u0642\u0645\u0645';
  22959. t['\uFD80'] = '\u0644\u062D\u0645';
  22960. t['\uFD81'] = '\u0644\u062D\u064A';
  22961. t['\uFD82'] = '\u0644\u062D\u0649';
  22962. t['\uFD83'] = '\u0644\u062C\u062C';
  22963. t['\uFD84'] = '\u0644\u062C\u062C';
  22964. t['\uFD85'] = '\u0644\u062E\u0645';
  22965. t['\uFD86'] = '\u0644\u062E\u0645';
  22966. t['\uFD87'] = '\u0644\u0645\u062D';
  22967. t['\uFD88'] = '\u0644\u0645\u062D';
  22968. t['\uFD89'] = '\u0645\u062D\u062C';
  22969. t['\uFD8A'] = '\u0645\u062D\u0645';
  22970. t['\uFD8B'] = '\u0645\u062D\u064A';
  22971. t['\uFD8C'] = '\u0645\u062C\u062D';
  22972. t['\uFD8D'] = '\u0645\u062C\u0645';
  22973. t['\uFD8E'] = '\u0645\u062E\u062C';
  22974. t['\uFD8F'] = '\u0645\u062E\u0645';
  22975. t['\uFD92'] = '\u0645\u062C\u062E';
  22976. t['\uFD93'] = '\u0647\u0645\u062C';
  22977. t['\uFD94'] = '\u0647\u0645\u0645';
  22978. t['\uFD95'] = '\u0646\u062D\u0645';
  22979. t['\uFD96'] = '\u0646\u062D\u0649';
  22980. t['\uFD97'] = '\u0646\u062C\u0645';
  22981. t['\uFD98'] = '\u0646\u062C\u0645';
  22982. t['\uFD99'] = '\u0646\u062C\u0649';
  22983. t['\uFD9A'] = '\u0646\u0645\u064A';
  22984. t['\uFD9B'] = '\u0646\u0645\u0649';
  22985. t['\uFD9C'] = '\u064A\u0645\u0645';
  22986. t['\uFD9D'] = '\u064A\u0645\u0645';
  22987. t['\uFD9E'] = '\u0628\u062E\u064A';
  22988. t['\uFD9F'] = '\u062A\u062C\u064A';
  22989. t['\uFDA0'] = '\u062A\u062C\u0649';
  22990. t['\uFDA1'] = '\u062A\u062E\u064A';
  22991. t['\uFDA2'] = '\u062A\u062E\u0649';
  22992. t['\uFDA3'] = '\u062A\u0645\u064A';
  22993. t['\uFDA4'] = '\u062A\u0645\u0649';
  22994. t['\uFDA5'] = '\u062C\u0645\u064A';
  22995. t['\uFDA6'] = '\u062C\u062D\u0649';
  22996. t['\uFDA7'] = '\u062C\u0645\u0649';
  22997. t['\uFDA8'] = '\u0633\u062E\u0649';
  22998. t['\uFDA9'] = '\u0635\u062D\u064A';
  22999. t['\uFDAA'] = '\u0634\u062D\u064A';
  23000. t['\uFDAB'] = '\u0636\u062D\u064A';
  23001. t['\uFDAC'] = '\u0644\u062C\u064A';
  23002. t['\uFDAD'] = '\u0644\u0645\u064A';
  23003. t['\uFDAE'] = '\u064A\u062D\u064A';
  23004. t['\uFDAF'] = '\u064A\u062C\u064A';
  23005. t['\uFDB0'] = '\u064A\u0645\u064A';
  23006. t['\uFDB1'] = '\u0645\u0645\u064A';
  23007. t['\uFDB2'] = '\u0642\u0645\u064A';
  23008. t['\uFDB3'] = '\u0646\u062D\u064A';
  23009. t['\uFDB4'] = '\u0642\u0645\u062D';
  23010. t['\uFDB5'] = '\u0644\u062D\u0645';
  23011. t['\uFDB6'] = '\u0639\u0645\u064A';
  23012. t['\uFDB7'] = '\u0643\u0645\u064A';
  23013. t['\uFDB8'] = '\u0646\u062C\u062D';
  23014. t['\uFDB9'] = '\u0645\u062E\u064A';
  23015. t['\uFDBA'] = '\u0644\u062C\u0645';
  23016. t['\uFDBB'] = '\u0643\u0645\u0645';
  23017. t['\uFDBC'] = '\u0644\u062C\u0645';
  23018. t['\uFDBD'] = '\u0646\u062C\u062D';
  23019. t['\uFDBE'] = '\u062C\u062D\u064A';
  23020. t['\uFDBF'] = '\u062D\u062C\u064A';
  23021. t['\uFDC0'] = '\u0645\u062C\u064A';
  23022. t['\uFDC1'] = '\u0641\u0645\u064A';
  23023. t['\uFDC2'] = '\u0628\u062D\u064A';
  23024. t['\uFDC3'] = '\u0643\u0645\u0645';
  23025. t['\uFDC4'] = '\u0639\u062C\u0645';
  23026. t['\uFDC5'] = '\u0635\u0645\u0645';
  23027. t['\uFDC6'] = '\u0633\u062E\u064A';
  23028. t['\uFDC7'] = '\u0646\u062C\u064A';
  23029. t['\uFE49'] = '\u203E';
  23030. t['\uFE4A'] = '\u203E';
  23031. t['\uFE4B'] = '\u203E';
  23032. t['\uFE4C'] = '\u203E';
  23033. t['\uFE4D'] = '\u005F';
  23034. t['\uFE4E'] = '\u005F';
  23035. t['\uFE4F'] = '\u005F';
  23036. t['\uFE80'] = '\u0621';
  23037. t['\uFE81'] = '\u0622';
  23038. t['\uFE82'] = '\u0622';
  23039. t['\uFE83'] = '\u0623';
  23040. t['\uFE84'] = '\u0623';
  23041. t['\uFE85'] = '\u0624';
  23042. t['\uFE86'] = '\u0624';
  23043. t['\uFE87'] = '\u0625';
  23044. t['\uFE88'] = '\u0625';
  23045. t['\uFE89'] = '\u0626';
  23046. t['\uFE8A'] = '\u0626';
  23047. t['\uFE8B'] = '\u0626';
  23048. t['\uFE8C'] = '\u0626';
  23049. t['\uFE8D'] = '\u0627';
  23050. t['\uFE8E'] = '\u0627';
  23051. t['\uFE8F'] = '\u0628';
  23052. t['\uFE90'] = '\u0628';
  23053. t['\uFE91'] = '\u0628';
  23054. t['\uFE92'] = '\u0628';
  23055. t['\uFE93'] = '\u0629';
  23056. t['\uFE94'] = '\u0629';
  23057. t['\uFE95'] = '\u062A';
  23058. t['\uFE96'] = '\u062A';
  23059. t['\uFE97'] = '\u062A';
  23060. t['\uFE98'] = '\u062A';
  23061. t['\uFE99'] = '\u062B';
  23062. t['\uFE9A'] = '\u062B';
  23063. t['\uFE9B'] = '\u062B';
  23064. t['\uFE9C'] = '\u062B';
  23065. t['\uFE9D'] = '\u062C';
  23066. t['\uFE9E'] = '\u062C';
  23067. t['\uFE9F'] = '\u062C';
  23068. t['\uFEA0'] = '\u062C';
  23069. t['\uFEA1'] = '\u062D';
  23070. t['\uFEA2'] = '\u062D';
  23071. t['\uFEA3'] = '\u062D';
  23072. t['\uFEA4'] = '\u062D';
  23073. t['\uFEA5'] = '\u062E';
  23074. t['\uFEA6'] = '\u062E';
  23075. t['\uFEA7'] = '\u062E';
  23076. t['\uFEA8'] = '\u062E';
  23077. t['\uFEA9'] = '\u062F';
  23078. t['\uFEAA'] = '\u062F';
  23079. t['\uFEAB'] = '\u0630';
  23080. t['\uFEAC'] = '\u0630';
  23081. t['\uFEAD'] = '\u0631';
  23082. t['\uFEAE'] = '\u0631';
  23083. t['\uFEAF'] = '\u0632';
  23084. t['\uFEB0'] = '\u0632';
  23085. t['\uFEB1'] = '\u0633';
  23086. t['\uFEB2'] = '\u0633';
  23087. t['\uFEB3'] = '\u0633';
  23088. t['\uFEB4'] = '\u0633';
  23089. t['\uFEB5'] = '\u0634';
  23090. t['\uFEB6'] = '\u0634';
  23091. t['\uFEB7'] = '\u0634';
  23092. t['\uFEB8'] = '\u0634';
  23093. t['\uFEB9'] = '\u0635';
  23094. t['\uFEBA'] = '\u0635';
  23095. t['\uFEBB'] = '\u0635';
  23096. t['\uFEBC'] = '\u0635';
  23097. t['\uFEBD'] = '\u0636';
  23098. t['\uFEBE'] = '\u0636';
  23099. t['\uFEBF'] = '\u0636';
  23100. t['\uFEC0'] = '\u0636';
  23101. t['\uFEC1'] = '\u0637';
  23102. t['\uFEC2'] = '\u0637';
  23103. t['\uFEC3'] = '\u0637';
  23104. t['\uFEC4'] = '\u0637';
  23105. t['\uFEC5'] = '\u0638';
  23106. t['\uFEC6'] = '\u0638';
  23107. t['\uFEC7'] = '\u0638';
  23108. t['\uFEC8'] = '\u0638';
  23109. t['\uFEC9'] = '\u0639';
  23110. t['\uFECA'] = '\u0639';
  23111. t['\uFECB'] = '\u0639';
  23112. t['\uFECC'] = '\u0639';
  23113. t['\uFECD'] = '\u063A';
  23114. t['\uFECE'] = '\u063A';
  23115. t['\uFECF'] = '\u063A';
  23116. t['\uFED0'] = '\u063A';
  23117. t['\uFED1'] = '\u0641';
  23118. t['\uFED2'] = '\u0641';
  23119. t['\uFED3'] = '\u0641';
  23120. t['\uFED4'] = '\u0641';
  23121. t['\uFED5'] = '\u0642';
  23122. t['\uFED6'] = '\u0642';
  23123. t['\uFED7'] = '\u0642';
  23124. t['\uFED8'] = '\u0642';
  23125. t['\uFED9'] = '\u0643';
  23126. t['\uFEDA'] = '\u0643';
  23127. t['\uFEDB'] = '\u0643';
  23128. t['\uFEDC'] = '\u0643';
  23129. t['\uFEDD'] = '\u0644';
  23130. t['\uFEDE'] = '\u0644';
  23131. t['\uFEDF'] = '\u0644';
  23132. t['\uFEE0'] = '\u0644';
  23133. t['\uFEE1'] = '\u0645';
  23134. t['\uFEE2'] = '\u0645';
  23135. t['\uFEE3'] = '\u0645';
  23136. t['\uFEE4'] = '\u0645';
  23137. t['\uFEE5'] = '\u0646';
  23138. t['\uFEE6'] = '\u0646';
  23139. t['\uFEE7'] = '\u0646';
  23140. t['\uFEE8'] = '\u0646';
  23141. t['\uFEE9'] = '\u0647';
  23142. t['\uFEEA'] = '\u0647';
  23143. t['\uFEEB'] = '\u0647';
  23144. t['\uFEEC'] = '\u0647';
  23145. t['\uFEED'] = '\u0648';
  23146. t['\uFEEE'] = '\u0648';
  23147. t['\uFEEF'] = '\u0649';
  23148. t['\uFEF0'] = '\u0649';
  23149. t['\uFEF1'] = '\u064A';
  23150. t['\uFEF2'] = '\u064A';
  23151. t['\uFEF3'] = '\u064A';
  23152. t['\uFEF4'] = '\u064A';
  23153. t['\uFEF5'] = '\u0644\u0622';
  23154. t['\uFEF6'] = '\u0644\u0622';
  23155. t['\uFEF7'] = '\u0644\u0623';
  23156. t['\uFEF8'] = '\u0644\u0623';
  23157. t['\uFEF9'] = '\u0644\u0625';
  23158. t['\uFEFA'] = '\u0644\u0625';
  23159. t['\uFEFB'] = '\u0644\u0627';
  23160. t['\uFEFC'] = '\u0644\u0627';
  23161. });
  23162. function reverseIfRtl(chars) {
  23163. var charsLength = chars.length;
  23164. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  23165. return chars;
  23166. }
  23167. var s = '';
  23168. for (var ii = charsLength - 1; ii >= 0; ii--) {
  23169. s += chars[ii];
  23170. }
  23171. return s;
  23172. }
  23173. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  23174. exports.reverseIfRtl = reverseIfRtl;
  23175. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  23176. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  23177. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  23178. }));
  23179. (function (root, factory) {
  23180. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  23181. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  23182. var Util = sharedUtil.Util;
  23183. var error = sharedUtil.error;
  23184. var info = sharedUtil.info;
  23185. var isInt = sharedUtil.isInt;
  23186. var isArray = sharedUtil.isArray;
  23187. var createObjectURL = sharedUtil.createObjectURL;
  23188. var shadow = sharedUtil.shadow;
  23189. var warn = sharedUtil.warn;
  23190. var isSpace = sharedUtil.isSpace;
  23191. var Dict = corePrimitives.Dict;
  23192. var isDict = corePrimitives.isDict;
  23193. var isStream = corePrimitives.isStream;
  23194. var Jbig2Image = coreJbig2.Jbig2Image;
  23195. var JpegImage = coreJpg.JpegImage;
  23196. var JpxImage = coreJpx.JpxImage;
  23197. var Stream = function StreamClosure() {
  23198. function Stream(arrayBuffer, start, length, dict) {
  23199. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  23200. this.start = start || 0;
  23201. this.pos = this.start;
  23202. this.end = start + length || this.bytes.length;
  23203. this.dict = dict;
  23204. }
  23205. Stream.prototype = {
  23206. get length() {
  23207. return this.end - this.start;
  23208. },
  23209. get isEmpty() {
  23210. return this.length === 0;
  23211. },
  23212. getByte: function Stream_getByte() {
  23213. if (this.pos >= this.end) {
  23214. return -1;
  23215. }
  23216. return this.bytes[this.pos++];
  23217. },
  23218. getUint16: function Stream_getUint16() {
  23219. var b0 = this.getByte();
  23220. var b1 = this.getByte();
  23221. if (b0 === -1 || b1 === -1) {
  23222. return -1;
  23223. }
  23224. return (b0 << 8) + b1;
  23225. },
  23226. getInt32: function Stream_getInt32() {
  23227. var b0 = this.getByte();
  23228. var b1 = this.getByte();
  23229. var b2 = this.getByte();
  23230. var b3 = this.getByte();
  23231. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  23232. },
  23233. getBytes: function Stream_getBytes(length) {
  23234. var bytes = this.bytes;
  23235. var pos = this.pos;
  23236. var strEnd = this.end;
  23237. if (!length) {
  23238. return bytes.subarray(pos, strEnd);
  23239. }
  23240. var end = pos + length;
  23241. if (end > strEnd) {
  23242. end = strEnd;
  23243. }
  23244. this.pos = end;
  23245. return bytes.subarray(pos, end);
  23246. },
  23247. peekByte: function Stream_peekByte() {
  23248. var peekedByte = this.getByte();
  23249. this.pos--;
  23250. return peekedByte;
  23251. },
  23252. peekBytes: function Stream_peekBytes(length) {
  23253. var bytes = this.getBytes(length);
  23254. this.pos -= bytes.length;
  23255. return bytes;
  23256. },
  23257. skip: function Stream_skip(n) {
  23258. if (!n) {
  23259. n = 1;
  23260. }
  23261. this.pos += n;
  23262. },
  23263. reset: function Stream_reset() {
  23264. this.pos = this.start;
  23265. },
  23266. moveStart: function Stream_moveStart() {
  23267. this.start = this.pos;
  23268. },
  23269. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  23270. return new Stream(this.bytes.buffer, start, length, dict);
  23271. },
  23272. isStream: true
  23273. };
  23274. return Stream;
  23275. }();
  23276. var StringStream = function StringStreamClosure() {
  23277. function StringStream(str) {
  23278. var length = str.length;
  23279. var bytes = new Uint8Array(length);
  23280. for (var n = 0; n < length; ++n) {
  23281. bytes[n] = str.charCodeAt(n);
  23282. }
  23283. Stream.call(this, bytes);
  23284. }
  23285. StringStream.prototype = Stream.prototype;
  23286. return StringStream;
  23287. }();
  23288. var DecodeStream = function DecodeStreamClosure() {
  23289. var emptyBuffer = new Uint8Array(0);
  23290. function DecodeStream(maybeMinBufferLength) {
  23291. this.pos = 0;
  23292. this.bufferLength = 0;
  23293. this.eof = false;
  23294. this.buffer = emptyBuffer;
  23295. this.minBufferLength = 512;
  23296. if (maybeMinBufferLength) {
  23297. while (this.minBufferLength < maybeMinBufferLength) {
  23298. this.minBufferLength *= 2;
  23299. }
  23300. }
  23301. }
  23302. DecodeStream.prototype = {
  23303. get isEmpty() {
  23304. while (!this.eof && this.bufferLength === 0) {
  23305. this.readBlock();
  23306. }
  23307. return this.bufferLength === 0;
  23308. },
  23309. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  23310. var buffer = this.buffer;
  23311. if (requested <= buffer.byteLength) {
  23312. return buffer;
  23313. }
  23314. var size = this.minBufferLength;
  23315. while (size < requested) {
  23316. size *= 2;
  23317. }
  23318. var buffer2 = new Uint8Array(size);
  23319. buffer2.set(buffer);
  23320. return this.buffer = buffer2;
  23321. },
  23322. getByte: function DecodeStream_getByte() {
  23323. var pos = this.pos;
  23324. while (this.bufferLength <= pos) {
  23325. if (this.eof) {
  23326. return -1;
  23327. }
  23328. this.readBlock();
  23329. }
  23330. return this.buffer[this.pos++];
  23331. },
  23332. getUint16: function DecodeStream_getUint16() {
  23333. var b0 = this.getByte();
  23334. var b1 = this.getByte();
  23335. if (b0 === -1 || b1 === -1) {
  23336. return -1;
  23337. }
  23338. return (b0 << 8) + b1;
  23339. },
  23340. getInt32: function DecodeStream_getInt32() {
  23341. var b0 = this.getByte();
  23342. var b1 = this.getByte();
  23343. var b2 = this.getByte();
  23344. var b3 = this.getByte();
  23345. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  23346. },
  23347. getBytes: function DecodeStream_getBytes(length) {
  23348. var end, pos = this.pos;
  23349. if (length) {
  23350. this.ensureBuffer(pos + length);
  23351. end = pos + length;
  23352. while (!this.eof && this.bufferLength < end) {
  23353. this.readBlock();
  23354. }
  23355. var bufEnd = this.bufferLength;
  23356. if (end > bufEnd) {
  23357. end = bufEnd;
  23358. }
  23359. } else {
  23360. while (!this.eof) {
  23361. this.readBlock();
  23362. }
  23363. end = this.bufferLength;
  23364. }
  23365. this.pos = end;
  23366. return this.buffer.subarray(pos, end);
  23367. },
  23368. peekByte: function DecodeStream_peekByte() {
  23369. var peekedByte = this.getByte();
  23370. this.pos--;
  23371. return peekedByte;
  23372. },
  23373. peekBytes: function DecodeStream_peekBytes(length) {
  23374. var bytes = this.getBytes(length);
  23375. this.pos -= bytes.length;
  23376. return bytes;
  23377. },
  23378. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  23379. var end = start + length;
  23380. while (this.bufferLength <= end && !this.eof) {
  23381. this.readBlock();
  23382. }
  23383. return new Stream(this.buffer, start, length, dict);
  23384. },
  23385. skip: function DecodeStream_skip(n) {
  23386. if (!n) {
  23387. n = 1;
  23388. }
  23389. this.pos += n;
  23390. },
  23391. reset: function DecodeStream_reset() {
  23392. this.pos = 0;
  23393. },
  23394. getBaseStreams: function DecodeStream_getBaseStreams() {
  23395. if (this.str && this.str.getBaseStreams) {
  23396. return this.str.getBaseStreams();
  23397. }
  23398. return [];
  23399. }
  23400. };
  23401. return DecodeStream;
  23402. }();
  23403. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  23404. function StreamsSequenceStream(streams) {
  23405. this.streams = streams;
  23406. DecodeStream.call(this, null);
  23407. }
  23408. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  23409. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  23410. var streams = this.streams;
  23411. if (streams.length === 0) {
  23412. this.eof = true;
  23413. return;
  23414. }
  23415. var stream = streams.shift();
  23416. var chunk = stream.getBytes();
  23417. var bufferLength = this.bufferLength;
  23418. var newLength = bufferLength + chunk.length;
  23419. var buffer = this.ensureBuffer(newLength);
  23420. buffer.set(chunk, bufferLength);
  23421. this.bufferLength = newLength;
  23422. };
  23423. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  23424. var baseStreams = [];
  23425. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  23426. var stream = this.streams[i];
  23427. if (stream.getBaseStreams) {
  23428. Util.appendToArray(baseStreams, stream.getBaseStreams());
  23429. }
  23430. }
  23431. return baseStreams;
  23432. };
  23433. return StreamsSequenceStream;
  23434. }();
  23435. var FlateStream = function FlateStreamClosure() {
  23436. var codeLenCodeMap = new Int32Array([
  23437. 16,
  23438. 17,
  23439. 18,
  23440. 0,
  23441. 8,
  23442. 7,
  23443. 9,
  23444. 6,
  23445. 10,
  23446. 5,
  23447. 11,
  23448. 4,
  23449. 12,
  23450. 3,
  23451. 13,
  23452. 2,
  23453. 14,
  23454. 1,
  23455. 15
  23456. ]);
  23457. var lengthDecode = new Int32Array([
  23458. 0x00003,
  23459. 0x00004,
  23460. 0x00005,
  23461. 0x00006,
  23462. 0x00007,
  23463. 0x00008,
  23464. 0x00009,
  23465. 0x0000a,
  23466. 0x1000b,
  23467. 0x1000d,
  23468. 0x1000f,
  23469. 0x10011,
  23470. 0x20013,
  23471. 0x20017,
  23472. 0x2001b,
  23473. 0x2001f,
  23474. 0x30023,
  23475. 0x3002b,
  23476. 0x30033,
  23477. 0x3003b,
  23478. 0x40043,
  23479. 0x40053,
  23480. 0x40063,
  23481. 0x40073,
  23482. 0x50083,
  23483. 0x500a3,
  23484. 0x500c3,
  23485. 0x500e3,
  23486. 0x00102,
  23487. 0x00102,
  23488. 0x00102
  23489. ]);
  23490. var distDecode = new Int32Array([
  23491. 0x00001,
  23492. 0x00002,
  23493. 0x00003,
  23494. 0x00004,
  23495. 0x10005,
  23496. 0x10007,
  23497. 0x20009,
  23498. 0x2000d,
  23499. 0x30011,
  23500. 0x30019,
  23501. 0x40021,
  23502. 0x40031,
  23503. 0x50041,
  23504. 0x50061,
  23505. 0x60081,
  23506. 0x600c1,
  23507. 0x70101,
  23508. 0x70181,
  23509. 0x80201,
  23510. 0x80301,
  23511. 0x90401,
  23512. 0x90601,
  23513. 0xa0801,
  23514. 0xa0c01,
  23515. 0xb1001,
  23516. 0xb1801,
  23517. 0xc2001,
  23518. 0xc3001,
  23519. 0xd4001,
  23520. 0xd6001
  23521. ]);
  23522. var fixedLitCodeTab = [
  23523. new Int32Array([
  23524. 0x70100,
  23525. 0x80050,
  23526. 0x80010,
  23527. 0x80118,
  23528. 0x70110,
  23529. 0x80070,
  23530. 0x80030,
  23531. 0x900c0,
  23532. 0x70108,
  23533. 0x80060,
  23534. 0x80020,
  23535. 0x900a0,
  23536. 0x80000,
  23537. 0x80080,
  23538. 0x80040,
  23539. 0x900e0,
  23540. 0x70104,
  23541. 0x80058,
  23542. 0x80018,
  23543. 0x90090,
  23544. 0x70114,
  23545. 0x80078,
  23546. 0x80038,
  23547. 0x900d0,
  23548. 0x7010c,
  23549. 0x80068,
  23550. 0x80028,
  23551. 0x900b0,
  23552. 0x80008,
  23553. 0x80088,
  23554. 0x80048,
  23555. 0x900f0,
  23556. 0x70102,
  23557. 0x80054,
  23558. 0x80014,
  23559. 0x8011c,
  23560. 0x70112,
  23561. 0x80074,
  23562. 0x80034,
  23563. 0x900c8,
  23564. 0x7010a,
  23565. 0x80064,
  23566. 0x80024,
  23567. 0x900a8,
  23568. 0x80004,
  23569. 0x80084,
  23570. 0x80044,
  23571. 0x900e8,
  23572. 0x70106,
  23573. 0x8005c,
  23574. 0x8001c,
  23575. 0x90098,
  23576. 0x70116,
  23577. 0x8007c,
  23578. 0x8003c,
  23579. 0x900d8,
  23580. 0x7010e,
  23581. 0x8006c,
  23582. 0x8002c,
  23583. 0x900b8,
  23584. 0x8000c,
  23585. 0x8008c,
  23586. 0x8004c,
  23587. 0x900f8,
  23588. 0x70101,
  23589. 0x80052,
  23590. 0x80012,
  23591. 0x8011a,
  23592. 0x70111,
  23593. 0x80072,
  23594. 0x80032,
  23595. 0x900c4,
  23596. 0x70109,
  23597. 0x80062,
  23598. 0x80022,
  23599. 0x900a4,
  23600. 0x80002,
  23601. 0x80082,
  23602. 0x80042,
  23603. 0x900e4,
  23604. 0x70105,
  23605. 0x8005a,
  23606. 0x8001a,
  23607. 0x90094,
  23608. 0x70115,
  23609. 0x8007a,
  23610. 0x8003a,
  23611. 0x900d4,
  23612. 0x7010d,
  23613. 0x8006a,
  23614. 0x8002a,
  23615. 0x900b4,
  23616. 0x8000a,
  23617. 0x8008a,
  23618. 0x8004a,
  23619. 0x900f4,
  23620. 0x70103,
  23621. 0x80056,
  23622. 0x80016,
  23623. 0x8011e,
  23624. 0x70113,
  23625. 0x80076,
  23626. 0x80036,
  23627. 0x900cc,
  23628. 0x7010b,
  23629. 0x80066,
  23630. 0x80026,
  23631. 0x900ac,
  23632. 0x80006,
  23633. 0x80086,
  23634. 0x80046,
  23635. 0x900ec,
  23636. 0x70107,
  23637. 0x8005e,
  23638. 0x8001e,
  23639. 0x9009c,
  23640. 0x70117,
  23641. 0x8007e,
  23642. 0x8003e,
  23643. 0x900dc,
  23644. 0x7010f,
  23645. 0x8006e,
  23646. 0x8002e,
  23647. 0x900bc,
  23648. 0x8000e,
  23649. 0x8008e,
  23650. 0x8004e,
  23651. 0x900fc,
  23652. 0x70100,
  23653. 0x80051,
  23654. 0x80011,
  23655. 0x80119,
  23656. 0x70110,
  23657. 0x80071,
  23658. 0x80031,
  23659. 0x900c2,
  23660. 0x70108,
  23661. 0x80061,
  23662. 0x80021,
  23663. 0x900a2,
  23664. 0x80001,
  23665. 0x80081,
  23666. 0x80041,
  23667. 0x900e2,
  23668. 0x70104,
  23669. 0x80059,
  23670. 0x80019,
  23671. 0x90092,
  23672. 0x70114,
  23673. 0x80079,
  23674. 0x80039,
  23675. 0x900d2,
  23676. 0x7010c,
  23677. 0x80069,
  23678. 0x80029,
  23679. 0x900b2,
  23680. 0x80009,
  23681. 0x80089,
  23682. 0x80049,
  23683. 0x900f2,
  23684. 0x70102,
  23685. 0x80055,
  23686. 0x80015,
  23687. 0x8011d,
  23688. 0x70112,
  23689. 0x80075,
  23690. 0x80035,
  23691. 0x900ca,
  23692. 0x7010a,
  23693. 0x80065,
  23694. 0x80025,
  23695. 0x900aa,
  23696. 0x80005,
  23697. 0x80085,
  23698. 0x80045,
  23699. 0x900ea,
  23700. 0x70106,
  23701. 0x8005d,
  23702. 0x8001d,
  23703. 0x9009a,
  23704. 0x70116,
  23705. 0x8007d,
  23706. 0x8003d,
  23707. 0x900da,
  23708. 0x7010e,
  23709. 0x8006d,
  23710. 0x8002d,
  23711. 0x900ba,
  23712. 0x8000d,
  23713. 0x8008d,
  23714. 0x8004d,
  23715. 0x900fa,
  23716. 0x70101,
  23717. 0x80053,
  23718. 0x80013,
  23719. 0x8011b,
  23720. 0x70111,
  23721. 0x80073,
  23722. 0x80033,
  23723. 0x900c6,
  23724. 0x70109,
  23725. 0x80063,
  23726. 0x80023,
  23727. 0x900a6,
  23728. 0x80003,
  23729. 0x80083,
  23730. 0x80043,
  23731. 0x900e6,
  23732. 0x70105,
  23733. 0x8005b,
  23734. 0x8001b,
  23735. 0x90096,
  23736. 0x70115,
  23737. 0x8007b,
  23738. 0x8003b,
  23739. 0x900d6,
  23740. 0x7010d,
  23741. 0x8006b,
  23742. 0x8002b,
  23743. 0x900b6,
  23744. 0x8000b,
  23745. 0x8008b,
  23746. 0x8004b,
  23747. 0x900f6,
  23748. 0x70103,
  23749. 0x80057,
  23750. 0x80017,
  23751. 0x8011f,
  23752. 0x70113,
  23753. 0x80077,
  23754. 0x80037,
  23755. 0x900ce,
  23756. 0x7010b,
  23757. 0x80067,
  23758. 0x80027,
  23759. 0x900ae,
  23760. 0x80007,
  23761. 0x80087,
  23762. 0x80047,
  23763. 0x900ee,
  23764. 0x70107,
  23765. 0x8005f,
  23766. 0x8001f,
  23767. 0x9009e,
  23768. 0x70117,
  23769. 0x8007f,
  23770. 0x8003f,
  23771. 0x900de,
  23772. 0x7010f,
  23773. 0x8006f,
  23774. 0x8002f,
  23775. 0x900be,
  23776. 0x8000f,
  23777. 0x8008f,
  23778. 0x8004f,
  23779. 0x900fe,
  23780. 0x70100,
  23781. 0x80050,
  23782. 0x80010,
  23783. 0x80118,
  23784. 0x70110,
  23785. 0x80070,
  23786. 0x80030,
  23787. 0x900c1,
  23788. 0x70108,
  23789. 0x80060,
  23790. 0x80020,
  23791. 0x900a1,
  23792. 0x80000,
  23793. 0x80080,
  23794. 0x80040,
  23795. 0x900e1,
  23796. 0x70104,
  23797. 0x80058,
  23798. 0x80018,
  23799. 0x90091,
  23800. 0x70114,
  23801. 0x80078,
  23802. 0x80038,
  23803. 0x900d1,
  23804. 0x7010c,
  23805. 0x80068,
  23806. 0x80028,
  23807. 0x900b1,
  23808. 0x80008,
  23809. 0x80088,
  23810. 0x80048,
  23811. 0x900f1,
  23812. 0x70102,
  23813. 0x80054,
  23814. 0x80014,
  23815. 0x8011c,
  23816. 0x70112,
  23817. 0x80074,
  23818. 0x80034,
  23819. 0x900c9,
  23820. 0x7010a,
  23821. 0x80064,
  23822. 0x80024,
  23823. 0x900a9,
  23824. 0x80004,
  23825. 0x80084,
  23826. 0x80044,
  23827. 0x900e9,
  23828. 0x70106,
  23829. 0x8005c,
  23830. 0x8001c,
  23831. 0x90099,
  23832. 0x70116,
  23833. 0x8007c,
  23834. 0x8003c,
  23835. 0x900d9,
  23836. 0x7010e,
  23837. 0x8006c,
  23838. 0x8002c,
  23839. 0x900b9,
  23840. 0x8000c,
  23841. 0x8008c,
  23842. 0x8004c,
  23843. 0x900f9,
  23844. 0x70101,
  23845. 0x80052,
  23846. 0x80012,
  23847. 0x8011a,
  23848. 0x70111,
  23849. 0x80072,
  23850. 0x80032,
  23851. 0x900c5,
  23852. 0x70109,
  23853. 0x80062,
  23854. 0x80022,
  23855. 0x900a5,
  23856. 0x80002,
  23857. 0x80082,
  23858. 0x80042,
  23859. 0x900e5,
  23860. 0x70105,
  23861. 0x8005a,
  23862. 0x8001a,
  23863. 0x90095,
  23864. 0x70115,
  23865. 0x8007a,
  23866. 0x8003a,
  23867. 0x900d5,
  23868. 0x7010d,
  23869. 0x8006a,
  23870. 0x8002a,
  23871. 0x900b5,
  23872. 0x8000a,
  23873. 0x8008a,
  23874. 0x8004a,
  23875. 0x900f5,
  23876. 0x70103,
  23877. 0x80056,
  23878. 0x80016,
  23879. 0x8011e,
  23880. 0x70113,
  23881. 0x80076,
  23882. 0x80036,
  23883. 0x900cd,
  23884. 0x7010b,
  23885. 0x80066,
  23886. 0x80026,
  23887. 0x900ad,
  23888. 0x80006,
  23889. 0x80086,
  23890. 0x80046,
  23891. 0x900ed,
  23892. 0x70107,
  23893. 0x8005e,
  23894. 0x8001e,
  23895. 0x9009d,
  23896. 0x70117,
  23897. 0x8007e,
  23898. 0x8003e,
  23899. 0x900dd,
  23900. 0x7010f,
  23901. 0x8006e,
  23902. 0x8002e,
  23903. 0x900bd,
  23904. 0x8000e,
  23905. 0x8008e,
  23906. 0x8004e,
  23907. 0x900fd,
  23908. 0x70100,
  23909. 0x80051,
  23910. 0x80011,
  23911. 0x80119,
  23912. 0x70110,
  23913. 0x80071,
  23914. 0x80031,
  23915. 0x900c3,
  23916. 0x70108,
  23917. 0x80061,
  23918. 0x80021,
  23919. 0x900a3,
  23920. 0x80001,
  23921. 0x80081,
  23922. 0x80041,
  23923. 0x900e3,
  23924. 0x70104,
  23925. 0x80059,
  23926. 0x80019,
  23927. 0x90093,
  23928. 0x70114,
  23929. 0x80079,
  23930. 0x80039,
  23931. 0x900d3,
  23932. 0x7010c,
  23933. 0x80069,
  23934. 0x80029,
  23935. 0x900b3,
  23936. 0x80009,
  23937. 0x80089,
  23938. 0x80049,
  23939. 0x900f3,
  23940. 0x70102,
  23941. 0x80055,
  23942. 0x80015,
  23943. 0x8011d,
  23944. 0x70112,
  23945. 0x80075,
  23946. 0x80035,
  23947. 0x900cb,
  23948. 0x7010a,
  23949. 0x80065,
  23950. 0x80025,
  23951. 0x900ab,
  23952. 0x80005,
  23953. 0x80085,
  23954. 0x80045,
  23955. 0x900eb,
  23956. 0x70106,
  23957. 0x8005d,
  23958. 0x8001d,
  23959. 0x9009b,
  23960. 0x70116,
  23961. 0x8007d,
  23962. 0x8003d,
  23963. 0x900db,
  23964. 0x7010e,
  23965. 0x8006d,
  23966. 0x8002d,
  23967. 0x900bb,
  23968. 0x8000d,
  23969. 0x8008d,
  23970. 0x8004d,
  23971. 0x900fb,
  23972. 0x70101,
  23973. 0x80053,
  23974. 0x80013,
  23975. 0x8011b,
  23976. 0x70111,
  23977. 0x80073,
  23978. 0x80033,
  23979. 0x900c7,
  23980. 0x70109,
  23981. 0x80063,
  23982. 0x80023,
  23983. 0x900a7,
  23984. 0x80003,
  23985. 0x80083,
  23986. 0x80043,
  23987. 0x900e7,
  23988. 0x70105,
  23989. 0x8005b,
  23990. 0x8001b,
  23991. 0x90097,
  23992. 0x70115,
  23993. 0x8007b,
  23994. 0x8003b,
  23995. 0x900d7,
  23996. 0x7010d,
  23997. 0x8006b,
  23998. 0x8002b,
  23999. 0x900b7,
  24000. 0x8000b,
  24001. 0x8008b,
  24002. 0x8004b,
  24003. 0x900f7,
  24004. 0x70103,
  24005. 0x80057,
  24006. 0x80017,
  24007. 0x8011f,
  24008. 0x70113,
  24009. 0x80077,
  24010. 0x80037,
  24011. 0x900cf,
  24012. 0x7010b,
  24013. 0x80067,
  24014. 0x80027,
  24015. 0x900af,
  24016. 0x80007,
  24017. 0x80087,
  24018. 0x80047,
  24019. 0x900ef,
  24020. 0x70107,
  24021. 0x8005f,
  24022. 0x8001f,
  24023. 0x9009f,
  24024. 0x70117,
  24025. 0x8007f,
  24026. 0x8003f,
  24027. 0x900df,
  24028. 0x7010f,
  24029. 0x8006f,
  24030. 0x8002f,
  24031. 0x900bf,
  24032. 0x8000f,
  24033. 0x8008f,
  24034. 0x8004f,
  24035. 0x900ff
  24036. ]),
  24037. 9
  24038. ];
  24039. var fixedDistCodeTab = [
  24040. new Int32Array([
  24041. 0x50000,
  24042. 0x50010,
  24043. 0x50008,
  24044. 0x50018,
  24045. 0x50004,
  24046. 0x50014,
  24047. 0x5000c,
  24048. 0x5001c,
  24049. 0x50002,
  24050. 0x50012,
  24051. 0x5000a,
  24052. 0x5001a,
  24053. 0x50006,
  24054. 0x50016,
  24055. 0x5000e,
  24056. 0x00000,
  24057. 0x50001,
  24058. 0x50011,
  24059. 0x50009,
  24060. 0x50019,
  24061. 0x50005,
  24062. 0x50015,
  24063. 0x5000d,
  24064. 0x5001d,
  24065. 0x50003,
  24066. 0x50013,
  24067. 0x5000b,
  24068. 0x5001b,
  24069. 0x50007,
  24070. 0x50017,
  24071. 0x5000f,
  24072. 0x00000
  24073. ]),
  24074. 5
  24075. ];
  24076. function FlateStream(str, maybeLength) {
  24077. this.str = str;
  24078. this.dict = str.dict;
  24079. var cmf = str.getByte();
  24080. var flg = str.getByte();
  24081. if (cmf === -1 || flg === -1) {
  24082. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  24083. }
  24084. if ((cmf & 0x0f) !== 0x08) {
  24085. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  24086. }
  24087. if (((cmf << 8) + flg) % 31 !== 0) {
  24088. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  24089. }
  24090. if (flg & 0x20) {
  24091. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  24092. }
  24093. this.codeSize = 0;
  24094. this.codeBuf = 0;
  24095. DecodeStream.call(this, maybeLength);
  24096. }
  24097. FlateStream.prototype = Object.create(DecodeStream.prototype);
  24098. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  24099. var str = this.str;
  24100. var codeSize = this.codeSize;
  24101. var codeBuf = this.codeBuf;
  24102. var b;
  24103. while (codeSize < bits) {
  24104. if ((b = str.getByte()) === -1) {
  24105. error('Bad encoding in flate stream');
  24106. }
  24107. codeBuf |= b << codeSize;
  24108. codeSize += 8;
  24109. }
  24110. b = codeBuf & (1 << bits) - 1;
  24111. this.codeBuf = codeBuf >> bits;
  24112. this.codeSize = codeSize -= bits;
  24113. return b;
  24114. };
  24115. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  24116. var str = this.str;
  24117. var codes = table[0];
  24118. var maxLen = table[1];
  24119. var codeSize = this.codeSize;
  24120. var codeBuf = this.codeBuf;
  24121. var b;
  24122. while (codeSize < maxLen) {
  24123. if ((b = str.getByte()) === -1) {
  24124. break;
  24125. }
  24126. codeBuf |= b << codeSize;
  24127. codeSize += 8;
  24128. }
  24129. var code = codes[codeBuf & (1 << maxLen) - 1];
  24130. var codeLen = code >> 16;
  24131. var codeVal = code & 0xffff;
  24132. if (codeLen < 1 || codeSize < codeLen) {
  24133. error('Bad encoding in flate stream');
  24134. }
  24135. this.codeBuf = codeBuf >> codeLen;
  24136. this.codeSize = codeSize - codeLen;
  24137. return codeVal;
  24138. };
  24139. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  24140. var n = lengths.length;
  24141. var maxLen = 0;
  24142. var i;
  24143. for (i = 0; i < n; ++i) {
  24144. if (lengths[i] > maxLen) {
  24145. maxLen = lengths[i];
  24146. }
  24147. }
  24148. var size = 1 << maxLen;
  24149. var codes = new Int32Array(size);
  24150. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  24151. for (var val = 0; val < n; ++val) {
  24152. if (lengths[val] === len) {
  24153. var code2 = 0;
  24154. var t = code;
  24155. for (i = 0; i < len; ++i) {
  24156. code2 = code2 << 1 | t & 1;
  24157. t >>= 1;
  24158. }
  24159. for (i = code2; i < size; i += skip) {
  24160. codes[i] = len << 16 | val;
  24161. }
  24162. ++code;
  24163. }
  24164. }
  24165. }
  24166. return [
  24167. codes,
  24168. maxLen
  24169. ];
  24170. };
  24171. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  24172. var buffer, len;
  24173. var str = this.str;
  24174. var hdr = this.getBits(3);
  24175. if (hdr & 1) {
  24176. this.eof = true;
  24177. }
  24178. hdr >>= 1;
  24179. if (hdr === 0) {
  24180. var b;
  24181. if ((b = str.getByte()) === -1) {
  24182. error('Bad block header in flate stream');
  24183. }
  24184. var blockLen = b;
  24185. if ((b = str.getByte()) === -1) {
  24186. error('Bad block header in flate stream');
  24187. }
  24188. blockLen |= b << 8;
  24189. if ((b = str.getByte()) === -1) {
  24190. error('Bad block header in flate stream');
  24191. }
  24192. var check = b;
  24193. if ((b = str.getByte()) === -1) {
  24194. error('Bad block header in flate stream');
  24195. }
  24196. check |= b << 8;
  24197. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  24198. error('Bad uncompressed block length in flate stream');
  24199. }
  24200. this.codeBuf = 0;
  24201. this.codeSize = 0;
  24202. var bufferLength = this.bufferLength;
  24203. buffer = this.ensureBuffer(bufferLength + blockLen);
  24204. var end = bufferLength + blockLen;
  24205. this.bufferLength = end;
  24206. if (blockLen === 0) {
  24207. if (str.peekByte() === -1) {
  24208. this.eof = true;
  24209. }
  24210. } else {
  24211. for (var n = bufferLength; n < end; ++n) {
  24212. if ((b = str.getByte()) === -1) {
  24213. this.eof = true;
  24214. break;
  24215. }
  24216. buffer[n] = b;
  24217. }
  24218. }
  24219. return;
  24220. }
  24221. var litCodeTable;
  24222. var distCodeTable;
  24223. if (hdr === 1) {
  24224. litCodeTable = fixedLitCodeTab;
  24225. distCodeTable = fixedDistCodeTab;
  24226. } else if (hdr === 2) {
  24227. var numLitCodes = this.getBits(5) + 257;
  24228. var numDistCodes = this.getBits(5) + 1;
  24229. var numCodeLenCodes = this.getBits(4) + 4;
  24230. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  24231. var i;
  24232. for (i = 0; i < numCodeLenCodes; ++i) {
  24233. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  24234. }
  24235. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  24236. len = 0;
  24237. i = 0;
  24238. var codes = numLitCodes + numDistCodes;
  24239. var codeLengths = new Uint8Array(codes);
  24240. var bitsLength, bitsOffset, what;
  24241. while (i < codes) {
  24242. var code = this.getCode(codeLenCodeTab);
  24243. if (code === 16) {
  24244. bitsLength = 2;
  24245. bitsOffset = 3;
  24246. what = len;
  24247. } else if (code === 17) {
  24248. bitsLength = 3;
  24249. bitsOffset = 3;
  24250. what = len = 0;
  24251. } else if (code === 18) {
  24252. bitsLength = 7;
  24253. bitsOffset = 11;
  24254. what = len = 0;
  24255. } else {
  24256. codeLengths[i++] = len = code;
  24257. continue;
  24258. }
  24259. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  24260. while (repeatLength-- > 0) {
  24261. codeLengths[i++] = what;
  24262. }
  24263. }
  24264. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  24265. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  24266. } else {
  24267. error('Unknown block type in flate stream');
  24268. }
  24269. buffer = this.buffer;
  24270. var limit = buffer ? buffer.length : 0;
  24271. var pos = this.bufferLength;
  24272. while (true) {
  24273. var code1 = this.getCode(litCodeTable);
  24274. if (code1 < 256) {
  24275. if (pos + 1 >= limit) {
  24276. buffer = this.ensureBuffer(pos + 1);
  24277. limit = buffer.length;
  24278. }
  24279. buffer[pos++] = code1;
  24280. continue;
  24281. }
  24282. if (code1 === 256) {
  24283. this.bufferLength = pos;
  24284. return;
  24285. }
  24286. code1 -= 257;
  24287. code1 = lengthDecode[code1];
  24288. var code2 = code1 >> 16;
  24289. if (code2 > 0) {
  24290. code2 = this.getBits(code2);
  24291. }
  24292. len = (code1 & 0xffff) + code2;
  24293. code1 = this.getCode(distCodeTable);
  24294. code1 = distDecode[code1];
  24295. code2 = code1 >> 16;
  24296. if (code2 > 0) {
  24297. code2 = this.getBits(code2);
  24298. }
  24299. var dist = (code1 & 0xffff) + code2;
  24300. if (pos + len >= limit) {
  24301. buffer = this.ensureBuffer(pos + len);
  24302. limit = buffer.length;
  24303. }
  24304. for (var k = 0; k < len; ++k, ++pos) {
  24305. buffer[pos] = buffer[pos - dist];
  24306. }
  24307. }
  24308. };
  24309. return FlateStream;
  24310. }();
  24311. var PredictorStream = function PredictorStreamClosure() {
  24312. function PredictorStream(str, maybeLength, params) {
  24313. if (!isDict(params)) {
  24314. return str;
  24315. }
  24316. var predictor = this.predictor = params.get('Predictor') || 1;
  24317. if (predictor <= 1) {
  24318. return str;
  24319. }
  24320. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  24321. error('Unsupported predictor: ' + predictor);
  24322. }
  24323. if (predictor === 2) {
  24324. this.readBlock = this.readBlockTiff;
  24325. } else {
  24326. this.readBlock = this.readBlockPng;
  24327. }
  24328. this.str = str;
  24329. this.dict = str.dict;
  24330. var colors = this.colors = params.get('Colors') || 1;
  24331. var bits = this.bits = params.get('BitsPerComponent') || 8;
  24332. var columns = this.columns = params.get('Columns') || 1;
  24333. this.pixBytes = colors * bits + 7 >> 3;
  24334. this.rowBytes = columns * colors * bits + 7 >> 3;
  24335. DecodeStream.call(this, maybeLength);
  24336. return this;
  24337. }
  24338. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  24339. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  24340. var rowBytes = this.rowBytes;
  24341. var bufferLength = this.bufferLength;
  24342. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  24343. var bits = this.bits;
  24344. var colors = this.colors;
  24345. var rawBytes = this.str.getBytes(rowBytes);
  24346. this.eof = !rawBytes.length;
  24347. if (this.eof) {
  24348. return;
  24349. }
  24350. var inbuf = 0, outbuf = 0;
  24351. var inbits = 0, outbits = 0;
  24352. var pos = bufferLength;
  24353. var i;
  24354. if (bits === 1) {
  24355. for (i = 0; i < rowBytes; ++i) {
  24356. var c = rawBytes[i];
  24357. inbuf = inbuf << 8 | c;
  24358. buffer[pos++] = (c ^ inbuf >> colors) & 0xFF;
  24359. inbuf &= 0xFFFF;
  24360. }
  24361. } else if (bits === 8) {
  24362. for (i = 0; i < colors; ++i) {
  24363. buffer[pos++] = rawBytes[i];
  24364. }
  24365. for (; i < rowBytes; ++i) {
  24366. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  24367. pos++;
  24368. }
  24369. } else {
  24370. var compArray = new Uint8Array(colors + 1);
  24371. var bitMask = (1 << bits) - 1;
  24372. var j = 0, k = bufferLength;
  24373. var columns = this.columns;
  24374. for (i = 0; i < columns; ++i) {
  24375. for (var kk = 0; kk < colors; ++kk) {
  24376. if (inbits < bits) {
  24377. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  24378. inbits += 8;
  24379. }
  24380. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  24381. inbits -= bits;
  24382. outbuf = outbuf << bits | compArray[kk];
  24383. outbits += bits;
  24384. if (outbits >= 8) {
  24385. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  24386. outbits -= 8;
  24387. }
  24388. }
  24389. }
  24390. if (outbits > 0) {
  24391. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  24392. }
  24393. }
  24394. this.bufferLength += rowBytes;
  24395. };
  24396. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  24397. var rowBytes = this.rowBytes;
  24398. var pixBytes = this.pixBytes;
  24399. var predictor = this.str.getByte();
  24400. var rawBytes = this.str.getBytes(rowBytes);
  24401. this.eof = !rawBytes.length;
  24402. if (this.eof) {
  24403. return;
  24404. }
  24405. var bufferLength = this.bufferLength;
  24406. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  24407. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  24408. if (prevRow.length === 0) {
  24409. prevRow = new Uint8Array(rowBytes);
  24410. }
  24411. var i, j = bufferLength, up, c;
  24412. switch (predictor) {
  24413. case 0:
  24414. for (i = 0; i < rowBytes; ++i) {
  24415. buffer[j++] = rawBytes[i];
  24416. }
  24417. break;
  24418. case 1:
  24419. for (i = 0; i < pixBytes; ++i) {
  24420. buffer[j++] = rawBytes[i];
  24421. }
  24422. for (; i < rowBytes; ++i) {
  24423. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  24424. j++;
  24425. }
  24426. break;
  24427. case 2:
  24428. for (i = 0; i < rowBytes; ++i) {
  24429. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  24430. }
  24431. break;
  24432. case 3:
  24433. for (i = 0; i < pixBytes; ++i) {
  24434. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  24435. }
  24436. for (; i < rowBytes; ++i) {
  24437. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  24438. j++;
  24439. }
  24440. break;
  24441. case 4:
  24442. for (i = 0; i < pixBytes; ++i) {
  24443. up = prevRow[i];
  24444. c = rawBytes[i];
  24445. buffer[j++] = up + c;
  24446. }
  24447. for (; i < rowBytes; ++i) {
  24448. up = prevRow[i];
  24449. var upLeft = prevRow[i - pixBytes];
  24450. var left = buffer[j - pixBytes];
  24451. var p = left + up - upLeft;
  24452. var pa = p - left;
  24453. if (pa < 0) {
  24454. pa = -pa;
  24455. }
  24456. var pb = p - up;
  24457. if (pb < 0) {
  24458. pb = -pb;
  24459. }
  24460. var pc = p - upLeft;
  24461. if (pc < 0) {
  24462. pc = -pc;
  24463. }
  24464. c = rawBytes[i];
  24465. if (pa <= pb && pa <= pc) {
  24466. buffer[j++] = left + c;
  24467. } else if (pb <= pc) {
  24468. buffer[j++] = up + c;
  24469. } else {
  24470. buffer[j++] = upLeft + c;
  24471. }
  24472. }
  24473. break;
  24474. default:
  24475. error('Unsupported predictor: ' + predictor);
  24476. }
  24477. this.bufferLength += rowBytes;
  24478. };
  24479. return PredictorStream;
  24480. }();
  24481. var JpegStream = function JpegStreamClosure() {
  24482. function JpegStream(stream, maybeLength, dict, params) {
  24483. var ch;
  24484. while ((ch = stream.getByte()) !== -1) {
  24485. if (ch === 0xFF) {
  24486. stream.skip(-1);
  24487. break;
  24488. }
  24489. }
  24490. this.stream = stream;
  24491. this.maybeLength = maybeLength;
  24492. this.dict = dict;
  24493. this.params = params;
  24494. DecodeStream.call(this, maybeLength);
  24495. }
  24496. JpegStream.prototype = Object.create(DecodeStream.prototype);
  24497. Object.defineProperty(JpegStream.prototype, 'bytes', {
  24498. get: function JpegStream_bytes() {
  24499. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  24500. },
  24501. configurable: true
  24502. });
  24503. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  24504. if (this.bufferLength) {
  24505. return;
  24506. }
  24507. var jpegImage = new JpegImage();
  24508. var decodeArr = this.dict.getArray('Decode', 'D');
  24509. if (this.forceRGB && isArray(decodeArr)) {
  24510. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  24511. var decodeArrLength = decodeArr.length;
  24512. var transform = new Int32Array(decodeArrLength);
  24513. var transformNeeded = false;
  24514. var maxValue = (1 << bitsPerComponent) - 1;
  24515. for (var i = 0; i < decodeArrLength; i += 2) {
  24516. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  24517. transform[i + 1] = decodeArr[i] * maxValue | 0;
  24518. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  24519. transformNeeded = true;
  24520. }
  24521. }
  24522. if (transformNeeded) {
  24523. jpegImage.decodeTransform = transform;
  24524. }
  24525. }
  24526. if (isDict(this.params)) {
  24527. var colorTransform = this.params.get('ColorTransform');
  24528. if (isInt(colorTransform)) {
  24529. jpegImage.colorTransform = colorTransform;
  24530. }
  24531. }
  24532. jpegImage.parse(this.bytes);
  24533. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  24534. this.buffer = data;
  24535. this.bufferLength = data.length;
  24536. this.eof = true;
  24537. };
  24538. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  24539. this.ensureBuffer();
  24540. return this.buffer;
  24541. };
  24542. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  24543. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  24544. };
  24545. return JpegStream;
  24546. }();
  24547. var JpxStream = function JpxStreamClosure() {
  24548. function JpxStream(stream, maybeLength, dict, params) {
  24549. this.stream = stream;
  24550. this.maybeLength = maybeLength;
  24551. this.dict = dict;
  24552. this.params = params;
  24553. DecodeStream.call(this, maybeLength);
  24554. }
  24555. JpxStream.prototype = Object.create(DecodeStream.prototype);
  24556. Object.defineProperty(JpxStream.prototype, 'bytes', {
  24557. get: function JpxStream_bytes() {
  24558. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  24559. },
  24560. configurable: true
  24561. });
  24562. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  24563. if (this.bufferLength) {
  24564. return;
  24565. }
  24566. var jpxImage = new JpxImage();
  24567. jpxImage.parse(this.bytes);
  24568. var width = jpxImage.width;
  24569. var height = jpxImage.height;
  24570. var componentsCount = jpxImage.componentsCount;
  24571. var tileCount = jpxImage.tiles.length;
  24572. if (tileCount === 1) {
  24573. this.buffer = jpxImage.tiles[0].items;
  24574. } else {
  24575. var data = new Uint8Array(width * height * componentsCount);
  24576. for (var k = 0; k < tileCount; k++) {
  24577. var tileComponents = jpxImage.tiles[k];
  24578. var tileWidth = tileComponents.width;
  24579. var tileHeight = tileComponents.height;
  24580. var tileLeft = tileComponents.left;
  24581. var tileTop = tileComponents.top;
  24582. var src = tileComponents.items;
  24583. var srcPosition = 0;
  24584. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  24585. var imgRowSize = width * componentsCount;
  24586. var tileRowSize = tileWidth * componentsCount;
  24587. for (var j = 0; j < tileHeight; j++) {
  24588. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  24589. data.set(rowBytes, dataPosition);
  24590. srcPosition += tileRowSize;
  24591. dataPosition += imgRowSize;
  24592. }
  24593. }
  24594. this.buffer = data;
  24595. }
  24596. this.bufferLength = this.buffer.length;
  24597. this.eof = true;
  24598. };
  24599. return JpxStream;
  24600. }();
  24601. var Jbig2Stream = function Jbig2StreamClosure() {
  24602. function Jbig2Stream(stream, maybeLength, dict, params) {
  24603. this.stream = stream;
  24604. this.maybeLength = maybeLength;
  24605. this.dict = dict;
  24606. this.params = params;
  24607. DecodeStream.call(this, maybeLength);
  24608. }
  24609. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  24610. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  24611. get: function Jbig2Stream_bytes() {
  24612. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  24613. },
  24614. configurable: true
  24615. });
  24616. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  24617. if (this.bufferLength) {
  24618. return;
  24619. }
  24620. var jbig2Image = new Jbig2Image();
  24621. var chunks = [];
  24622. if (isDict(this.params)) {
  24623. var globalsStream = this.params.get('JBIG2Globals');
  24624. if (isStream(globalsStream)) {
  24625. var globals = globalsStream.getBytes();
  24626. chunks.push({
  24627. data: globals,
  24628. start: 0,
  24629. end: globals.length
  24630. });
  24631. }
  24632. }
  24633. chunks.push({
  24634. data: this.bytes,
  24635. start: 0,
  24636. end: this.bytes.length
  24637. });
  24638. var data = jbig2Image.parseChunks(chunks);
  24639. var dataLength = data.length;
  24640. for (var i = 0; i < dataLength; i++) {
  24641. data[i] ^= 0xFF;
  24642. }
  24643. this.buffer = data;
  24644. this.bufferLength = dataLength;
  24645. this.eof = true;
  24646. };
  24647. return Jbig2Stream;
  24648. }();
  24649. var DecryptStream = function DecryptStreamClosure() {
  24650. function DecryptStream(str, maybeLength, decrypt) {
  24651. this.str = str;
  24652. this.dict = str.dict;
  24653. this.decrypt = decrypt;
  24654. this.nextChunk = null;
  24655. this.initialized = false;
  24656. DecodeStream.call(this, maybeLength);
  24657. }
  24658. var chunkSize = 512;
  24659. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  24660. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  24661. var chunk;
  24662. if (this.initialized) {
  24663. chunk = this.nextChunk;
  24664. } else {
  24665. chunk = this.str.getBytes(chunkSize);
  24666. this.initialized = true;
  24667. }
  24668. if (!chunk || chunk.length === 0) {
  24669. this.eof = true;
  24670. return;
  24671. }
  24672. this.nextChunk = this.str.getBytes(chunkSize);
  24673. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  24674. var decrypt = this.decrypt;
  24675. chunk = decrypt(chunk, !hasMoreData);
  24676. var bufferLength = this.bufferLength;
  24677. var i, n = chunk.length;
  24678. var buffer = this.ensureBuffer(bufferLength + n);
  24679. for (i = 0; i < n; i++) {
  24680. buffer[bufferLength++] = chunk[i];
  24681. }
  24682. this.bufferLength = bufferLength;
  24683. };
  24684. return DecryptStream;
  24685. }();
  24686. var Ascii85Stream = function Ascii85StreamClosure() {
  24687. function Ascii85Stream(str, maybeLength) {
  24688. this.str = str;
  24689. this.dict = str.dict;
  24690. this.input = new Uint8Array(5);
  24691. if (maybeLength) {
  24692. maybeLength = 0.8 * maybeLength;
  24693. }
  24694. DecodeStream.call(this, maybeLength);
  24695. }
  24696. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  24697. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  24698. var TILDA_CHAR = 0x7E;
  24699. var Z_LOWER_CHAR = 0x7A;
  24700. var EOF = -1;
  24701. var str = this.str;
  24702. var c = str.getByte();
  24703. while (isSpace(c)) {
  24704. c = str.getByte();
  24705. }
  24706. if (c === EOF || c === TILDA_CHAR) {
  24707. this.eof = true;
  24708. return;
  24709. }
  24710. var bufferLength = this.bufferLength, buffer;
  24711. var i;
  24712. if (c === Z_LOWER_CHAR) {
  24713. buffer = this.ensureBuffer(bufferLength + 4);
  24714. for (i = 0; i < 4; ++i) {
  24715. buffer[bufferLength + i] = 0;
  24716. }
  24717. this.bufferLength += 4;
  24718. } else {
  24719. var input = this.input;
  24720. input[0] = c;
  24721. for (i = 1; i < 5; ++i) {
  24722. c = str.getByte();
  24723. while (isSpace(c)) {
  24724. c = str.getByte();
  24725. }
  24726. input[i] = c;
  24727. if (c === EOF || c === TILDA_CHAR) {
  24728. break;
  24729. }
  24730. }
  24731. buffer = this.ensureBuffer(bufferLength + i - 1);
  24732. this.bufferLength += i - 1;
  24733. if (i < 5) {
  24734. for (; i < 5; ++i) {
  24735. input[i] = 0x21 + 84;
  24736. }
  24737. this.eof = true;
  24738. }
  24739. var t = 0;
  24740. for (i = 0; i < 5; ++i) {
  24741. t = t * 85 + (input[i] - 0x21);
  24742. }
  24743. for (i = 3; i >= 0; --i) {
  24744. buffer[bufferLength + i] = t & 0xFF;
  24745. t >>= 8;
  24746. }
  24747. }
  24748. };
  24749. return Ascii85Stream;
  24750. }();
  24751. var AsciiHexStream = function AsciiHexStreamClosure() {
  24752. function AsciiHexStream(str, maybeLength) {
  24753. this.str = str;
  24754. this.dict = str.dict;
  24755. this.firstDigit = -1;
  24756. if (maybeLength) {
  24757. maybeLength = 0.5 * maybeLength;
  24758. }
  24759. DecodeStream.call(this, maybeLength);
  24760. }
  24761. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  24762. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  24763. var UPSTREAM_BLOCK_SIZE = 8000;
  24764. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  24765. if (!bytes.length) {
  24766. this.eof = true;
  24767. return;
  24768. }
  24769. var maxDecodeLength = bytes.length + 1 >> 1;
  24770. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  24771. var bufferLength = this.bufferLength;
  24772. var firstDigit = this.firstDigit;
  24773. for (var i = 0, ii = bytes.length; i < ii; i++) {
  24774. var ch = bytes[i], digit;
  24775. if (ch >= 0x30 && ch <= 0x39) {
  24776. digit = ch & 0x0F;
  24777. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  24778. digit = (ch & 0x0F) + 9;
  24779. } else if (ch === 0x3E) {
  24780. this.eof = true;
  24781. break;
  24782. } else {
  24783. continue;
  24784. }
  24785. if (firstDigit < 0) {
  24786. firstDigit = digit;
  24787. } else {
  24788. buffer[bufferLength++] = firstDigit << 4 | digit;
  24789. firstDigit = -1;
  24790. }
  24791. }
  24792. if (firstDigit >= 0 && this.eof) {
  24793. buffer[bufferLength++] = firstDigit << 4;
  24794. firstDigit = -1;
  24795. }
  24796. this.firstDigit = firstDigit;
  24797. this.bufferLength = bufferLength;
  24798. };
  24799. return AsciiHexStream;
  24800. }();
  24801. var RunLengthStream = function RunLengthStreamClosure() {
  24802. function RunLengthStream(str, maybeLength) {
  24803. this.str = str;
  24804. this.dict = str.dict;
  24805. DecodeStream.call(this, maybeLength);
  24806. }
  24807. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  24808. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  24809. var repeatHeader = this.str.getBytes(2);
  24810. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  24811. this.eof = true;
  24812. return;
  24813. }
  24814. var buffer;
  24815. var bufferLength = this.bufferLength;
  24816. var n = repeatHeader[0];
  24817. if (n < 128) {
  24818. buffer = this.ensureBuffer(bufferLength + n + 1);
  24819. buffer[bufferLength++] = repeatHeader[1];
  24820. if (n > 0) {
  24821. var source = this.str.getBytes(n);
  24822. buffer.set(source, bufferLength);
  24823. bufferLength += n;
  24824. }
  24825. } else {
  24826. n = 257 - n;
  24827. var b = repeatHeader[1];
  24828. buffer = this.ensureBuffer(bufferLength + n + 1);
  24829. for (var i = 0; i < n; i++) {
  24830. buffer[bufferLength++] = b;
  24831. }
  24832. }
  24833. this.bufferLength = bufferLength;
  24834. };
  24835. return RunLengthStream;
  24836. }();
  24837. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  24838. var ccittEOL = -2;
  24839. var ccittEOF = -1;
  24840. var twoDimPass = 0;
  24841. var twoDimHoriz = 1;
  24842. var twoDimVert0 = 2;
  24843. var twoDimVertR1 = 3;
  24844. var twoDimVertL1 = 4;
  24845. var twoDimVertR2 = 5;
  24846. var twoDimVertL2 = 6;
  24847. var twoDimVertR3 = 7;
  24848. var twoDimVertL3 = 8;
  24849. var twoDimTable = [
  24850. [
  24851. -1,
  24852. -1
  24853. ],
  24854. [
  24855. -1,
  24856. -1
  24857. ],
  24858. [
  24859. 7,
  24860. twoDimVertL3
  24861. ],
  24862. [
  24863. 7,
  24864. twoDimVertR3
  24865. ],
  24866. [
  24867. 6,
  24868. twoDimVertL2
  24869. ],
  24870. [
  24871. 6,
  24872. twoDimVertL2
  24873. ],
  24874. [
  24875. 6,
  24876. twoDimVertR2
  24877. ],
  24878. [
  24879. 6,
  24880. twoDimVertR2
  24881. ],
  24882. [
  24883. 4,
  24884. twoDimPass
  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. 3,
  24916. twoDimHoriz
  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. twoDimVertL1
  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. twoDimVertR1
  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. 1,
  25108. twoDimVert0
  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. var whiteTable1 = [
  25364. [
  25365. -1,
  25366. -1
  25367. ],
  25368. [
  25369. 12,
  25370. ccittEOL
  25371. ],
  25372. [
  25373. -1,
  25374. -1
  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. 11,
  25430. 1792
  25431. ],
  25432. [
  25433. 11,
  25434. 1792
  25435. ],
  25436. [
  25437. 12,
  25438. 1984
  25439. ],
  25440. [
  25441. 12,
  25442. 2048
  25443. ],
  25444. [
  25445. 12,
  25446. 2112
  25447. ],
  25448. [
  25449. 12,
  25450. 2176
  25451. ],
  25452. [
  25453. 12,
  25454. 2240
  25455. ],
  25456. [
  25457. 12,
  25458. 2304
  25459. ],
  25460. [
  25461. 11,
  25462. 1856
  25463. ],
  25464. [
  25465. 11,
  25466. 1856
  25467. ],
  25468. [
  25469. 11,
  25470. 1920
  25471. ],
  25472. [
  25473. 11,
  25474. 1920
  25475. ],
  25476. [
  25477. 12,
  25478. 2368
  25479. ],
  25480. [
  25481. 12,
  25482. 2432
  25483. ],
  25484. [
  25485. 12,
  25486. 2496
  25487. ],
  25488. [
  25489. 12,
  25490. 2560
  25491. ]
  25492. ];
  25493. var whiteTable2 = [
  25494. [
  25495. -1,
  25496. -1
  25497. ],
  25498. [
  25499. -1,
  25500. -1
  25501. ],
  25502. [
  25503. -1,
  25504. -1
  25505. ],
  25506. [
  25507. -1,
  25508. -1
  25509. ],
  25510. [
  25511. 8,
  25512. 29
  25513. ],
  25514. [
  25515. 8,
  25516. 29
  25517. ],
  25518. [
  25519. 8,
  25520. 30
  25521. ],
  25522. [
  25523. 8,
  25524. 30
  25525. ],
  25526. [
  25527. 8,
  25528. 45
  25529. ],
  25530. [
  25531. 8,
  25532. 45
  25533. ],
  25534. [
  25535. 8,
  25536. 46
  25537. ],
  25538. [
  25539. 8,
  25540. 46
  25541. ],
  25542. [
  25543. 7,
  25544. 22
  25545. ],
  25546. [
  25547. 7,
  25548. 22
  25549. ],
  25550. [
  25551. 7,
  25552. 22
  25553. ],
  25554. [
  25555. 7,
  25556. 22
  25557. ],
  25558. [
  25559. 7,
  25560. 23
  25561. ],
  25562. [
  25563. 7,
  25564. 23
  25565. ],
  25566. [
  25567. 7,
  25568. 23
  25569. ],
  25570. [
  25571. 7,
  25572. 23
  25573. ],
  25574. [
  25575. 8,
  25576. 47
  25577. ],
  25578. [
  25579. 8,
  25580. 47
  25581. ],
  25582. [
  25583. 8,
  25584. 48
  25585. ],
  25586. [
  25587. 8,
  25588. 48
  25589. ],
  25590. [
  25591. 6,
  25592. 13
  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. 7,
  25624. 20
  25625. ],
  25626. [
  25627. 7,
  25628. 20
  25629. ],
  25630. [
  25631. 7,
  25632. 20
  25633. ],
  25634. [
  25635. 7,
  25636. 20
  25637. ],
  25638. [
  25639. 8,
  25640. 33
  25641. ],
  25642. [
  25643. 8,
  25644. 33
  25645. ],
  25646. [
  25647. 8,
  25648. 34
  25649. ],
  25650. [
  25651. 8,
  25652. 34
  25653. ],
  25654. [
  25655. 8,
  25656. 35
  25657. ],
  25658. [
  25659. 8,
  25660. 35
  25661. ],
  25662. [
  25663. 8,
  25664. 36
  25665. ],
  25666. [
  25667. 8,
  25668. 36
  25669. ],
  25670. [
  25671. 8,
  25672. 37
  25673. ],
  25674. [
  25675. 8,
  25676. 37
  25677. ],
  25678. [
  25679. 8,
  25680. 38
  25681. ],
  25682. [
  25683. 8,
  25684. 38
  25685. ],
  25686. [
  25687. 7,
  25688. 19
  25689. ],
  25690. [
  25691. 7,
  25692. 19
  25693. ],
  25694. [
  25695. 7,
  25696. 19
  25697. ],
  25698. [
  25699. 7,
  25700. 19
  25701. ],
  25702. [
  25703. 8,
  25704. 31
  25705. ],
  25706. [
  25707. 8,
  25708. 31
  25709. ],
  25710. [
  25711. 8,
  25712. 32
  25713. ],
  25714. [
  25715. 8,
  25716. 32
  25717. ],
  25718. [
  25719. 6,
  25720. 1
  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. 12
  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. 8,
  25784. 53
  25785. ],
  25786. [
  25787. 8,
  25788. 53
  25789. ],
  25790. [
  25791. 8,
  25792. 54
  25793. ],
  25794. [
  25795. 8,
  25796. 54
  25797. ],
  25798. [
  25799. 7,
  25800. 26
  25801. ],
  25802. [
  25803. 7,
  25804. 26
  25805. ],
  25806. [
  25807. 7,
  25808. 26
  25809. ],
  25810. [
  25811. 7,
  25812. 26
  25813. ],
  25814. [
  25815. 8,
  25816. 39
  25817. ],
  25818. [
  25819. 8,
  25820. 39
  25821. ],
  25822. [
  25823. 8,
  25824. 40
  25825. ],
  25826. [
  25827. 8,
  25828. 40
  25829. ],
  25830. [
  25831. 8,
  25832. 41
  25833. ],
  25834. [
  25835. 8,
  25836. 41
  25837. ],
  25838. [
  25839. 8,
  25840. 42
  25841. ],
  25842. [
  25843. 8,
  25844. 42
  25845. ],
  25846. [
  25847. 8,
  25848. 43
  25849. ],
  25850. [
  25851. 8,
  25852. 43
  25853. ],
  25854. [
  25855. 8,
  25856. 44
  25857. ],
  25858. [
  25859. 8,
  25860. 44
  25861. ],
  25862. [
  25863. 7,
  25864. 21
  25865. ],
  25866. [
  25867. 7,
  25868. 21
  25869. ],
  25870. [
  25871. 7,
  25872. 21
  25873. ],
  25874. [
  25875. 7,
  25876. 21
  25877. ],
  25878. [
  25879. 7,
  25880. 28
  25881. ],
  25882. [
  25883. 7,
  25884. 28
  25885. ],
  25886. [
  25887. 7,
  25888. 28
  25889. ],
  25890. [
  25891. 7,
  25892. 28
  25893. ],
  25894. [
  25895. 8,
  25896. 61
  25897. ],
  25898. [
  25899. 8,
  25900. 61
  25901. ],
  25902. [
  25903. 8,
  25904. 62
  25905. ],
  25906. [
  25907. 8,
  25908. 62
  25909. ],
  25910. [
  25911. 8,
  25912. 63
  25913. ],
  25914. [
  25915. 8,
  25916. 63
  25917. ],
  25918. [
  25919. 8,
  25920. 0
  25921. ],
  25922. [
  25923. 8,
  25924. 0
  25925. ],
  25926. [
  25927. 8,
  25928. 320
  25929. ],
  25930. [
  25931. 8,
  25932. 320
  25933. ],
  25934. [
  25935. 8,
  25936. 384
  25937. ],
  25938. [
  25939. 8,
  25940. 384
  25941. ],
  25942. [
  25943. 5,
  25944. 10
  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. 11
  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. 7,
  26072. 27
  26073. ],
  26074. [
  26075. 7,
  26076. 27
  26077. ],
  26078. [
  26079. 7,
  26080. 27
  26081. ],
  26082. [
  26083. 7,
  26084. 27
  26085. ],
  26086. [
  26087. 8,
  26088. 59
  26089. ],
  26090. [
  26091. 8,
  26092. 59
  26093. ],
  26094. [
  26095. 8,
  26096. 60
  26097. ],
  26098. [
  26099. 8,
  26100. 60
  26101. ],
  26102. [
  26103. 9,
  26104. 1472
  26105. ],
  26106. [
  26107. 9,
  26108. 1536
  26109. ],
  26110. [
  26111. 9,
  26112. 1600
  26113. ],
  26114. [
  26115. 9,
  26116. 1728
  26117. ],
  26118. [
  26119. 7,
  26120. 18
  26121. ],
  26122. [
  26123. 7,
  26124. 18
  26125. ],
  26126. [
  26127. 7,
  26128. 18
  26129. ],
  26130. [
  26131. 7,
  26132. 18
  26133. ],
  26134. [
  26135. 7,
  26136. 24
  26137. ],
  26138. [
  26139. 7,
  26140. 24
  26141. ],
  26142. [
  26143. 7,
  26144. 24
  26145. ],
  26146. [
  26147. 7,
  26148. 24
  26149. ],
  26150. [
  26151. 8,
  26152. 49
  26153. ],
  26154. [
  26155. 8,
  26156. 49
  26157. ],
  26158. [
  26159. 8,
  26160. 50
  26161. ],
  26162. [
  26163. 8,
  26164. 50
  26165. ],
  26166. [
  26167. 8,
  26168. 51
  26169. ],
  26170. [
  26171. 8,
  26172. 51
  26173. ],
  26174. [
  26175. 8,
  26176. 52
  26177. ],
  26178. [
  26179. 8,
  26180. 52
  26181. ],
  26182. [
  26183. 7,
  26184. 25
  26185. ],
  26186. [
  26187. 7,
  26188. 25
  26189. ],
  26190. [
  26191. 7,
  26192. 25
  26193. ],
  26194. [
  26195. 7,
  26196. 25
  26197. ],
  26198. [
  26199. 8,
  26200. 55
  26201. ],
  26202. [
  26203. 8,
  26204. 55
  26205. ],
  26206. [
  26207. 8,
  26208. 56
  26209. ],
  26210. [
  26211. 8,
  26212. 56
  26213. ],
  26214. [
  26215. 8,
  26216. 57
  26217. ],
  26218. [
  26219. 8,
  26220. 57
  26221. ],
  26222. [
  26223. 8,
  26224. 58
  26225. ],
  26226. [
  26227. 8,
  26228. 58
  26229. ],
  26230. [
  26231. 6,
  26232. 192
  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. 1664
  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. 8,
  26296. 448
  26297. ],
  26298. [
  26299. 8,
  26300. 448
  26301. ],
  26302. [
  26303. 8,
  26304. 512
  26305. ],
  26306. [
  26307. 8,
  26308. 512
  26309. ],
  26310. [
  26311. 9,
  26312. 704
  26313. ],
  26314. [
  26315. 9,
  26316. 768
  26317. ],
  26318. [
  26319. 8,
  26320. 640
  26321. ],
  26322. [
  26323. 8,
  26324. 640
  26325. ],
  26326. [
  26327. 8,
  26328. 576
  26329. ],
  26330. [
  26331. 8,
  26332. 576
  26333. ],
  26334. [
  26335. 9,
  26336. 832
  26337. ],
  26338. [
  26339. 9,
  26340. 896
  26341. ],
  26342. [
  26343. 9,
  26344. 960
  26345. ],
  26346. [
  26347. 9,
  26348. 1024
  26349. ],
  26350. [
  26351. 9,
  26352. 1088
  26353. ],
  26354. [
  26355. 9,
  26356. 1152
  26357. ],
  26358. [
  26359. 9,
  26360. 1216
  26361. ],
  26362. [
  26363. 9,
  26364. 1280
  26365. ],
  26366. [
  26367. 9,
  26368. 1344
  26369. ],
  26370. [
  26371. 9,
  26372. 1408
  26373. ],
  26374. [
  26375. 7,
  26376. 256
  26377. ],
  26378. [
  26379. 7,
  26380. 256
  26381. ],
  26382. [
  26383. 7,
  26384. 256
  26385. ],
  26386. [
  26387. 7,
  26388. 256
  26389. ],
  26390. [
  26391. 4,
  26392. 2
  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. 3
  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. 5,
  26648. 128
  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. 8
  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. 9
  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. 6,
  26840. 16
  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. 17
  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. 4,
  26904. 4
  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. 5
  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. 6,
  27160. 14
  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. 15
  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. 5,
  27224. 64
  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. 4,
  27288. 6
  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. 7
  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. var blackTable1 = [
  27544. [
  27545. -1,
  27546. -1
  27547. ],
  27548. [
  27549. -1,
  27550. -1
  27551. ],
  27552. [
  27553. 12,
  27554. ccittEOL
  27555. ],
  27556. [
  27557. 12,
  27558. ccittEOL
  27559. ],
  27560. [
  27561. -1,
  27562. -1
  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. 11,
  27674. 1792
  27675. ],
  27676. [
  27677. 11,
  27678. 1792
  27679. ],
  27680. [
  27681. 11,
  27682. 1792
  27683. ],
  27684. [
  27685. 11,
  27686. 1792
  27687. ],
  27688. [
  27689. 12,
  27690. 1984
  27691. ],
  27692. [
  27693. 12,
  27694. 1984
  27695. ],
  27696. [
  27697. 12,
  27698. 2048
  27699. ],
  27700. [
  27701. 12,
  27702. 2048
  27703. ],
  27704. [
  27705. 12,
  27706. 2112
  27707. ],
  27708. [
  27709. 12,
  27710. 2112
  27711. ],
  27712. [
  27713. 12,
  27714. 2176
  27715. ],
  27716. [
  27717. 12,
  27718. 2176
  27719. ],
  27720. [
  27721. 12,
  27722. 2240
  27723. ],
  27724. [
  27725. 12,
  27726. 2240
  27727. ],
  27728. [
  27729. 12,
  27730. 2304
  27731. ],
  27732. [
  27733. 12,
  27734. 2304
  27735. ],
  27736. [
  27737. 11,
  27738. 1856
  27739. ],
  27740. [
  27741. 11,
  27742. 1856
  27743. ],
  27744. [
  27745. 11,
  27746. 1856
  27747. ],
  27748. [
  27749. 11,
  27750. 1856
  27751. ],
  27752. [
  27753. 11,
  27754. 1920
  27755. ],
  27756. [
  27757. 11,
  27758. 1920
  27759. ],
  27760. [
  27761. 11,
  27762. 1920
  27763. ],
  27764. [
  27765. 11,
  27766. 1920
  27767. ],
  27768. [
  27769. 12,
  27770. 2368
  27771. ],
  27772. [
  27773. 12,
  27774. 2368
  27775. ],
  27776. [
  27777. 12,
  27778. 2432
  27779. ],
  27780. [
  27781. 12,
  27782. 2432
  27783. ],
  27784. [
  27785. 12,
  27786. 2496
  27787. ],
  27788. [
  27789. 12,
  27790. 2496
  27791. ],
  27792. [
  27793. 12,
  27794. 2560
  27795. ],
  27796. [
  27797. 12,
  27798. 2560
  27799. ],
  27800. [
  27801. 10,
  27802. 18
  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. 12,
  27834. 52
  27835. ],
  27836. [
  27837. 12,
  27838. 52
  27839. ],
  27840. [
  27841. 13,
  27842. 640
  27843. ],
  27844. [
  27845. 13,
  27846. 704
  27847. ],
  27848. [
  27849. 13,
  27850. 768
  27851. ],
  27852. [
  27853. 13,
  27854. 832
  27855. ],
  27856. [
  27857. 12,
  27858. 55
  27859. ],
  27860. [
  27861. 12,
  27862. 55
  27863. ],
  27864. [
  27865. 12,
  27866. 56
  27867. ],
  27868. [
  27869. 12,
  27870. 56
  27871. ],
  27872. [
  27873. 13,
  27874. 1280
  27875. ],
  27876. [
  27877. 13,
  27878. 1344
  27879. ],
  27880. [
  27881. 13,
  27882. 1408
  27883. ],
  27884. [
  27885. 13,
  27886. 1472
  27887. ],
  27888. [
  27889. 12,
  27890. 59
  27891. ],
  27892. [
  27893. 12,
  27894. 59
  27895. ],
  27896. [
  27897. 12,
  27898. 60
  27899. ],
  27900. [
  27901. 12,
  27902. 60
  27903. ],
  27904. [
  27905. 13,
  27906. 1536
  27907. ],
  27908. [
  27909. 13,
  27910. 1600
  27911. ],
  27912. [
  27913. 11,
  27914. 24
  27915. ],
  27916. [
  27917. 11,
  27918. 24
  27919. ],
  27920. [
  27921. 11,
  27922. 24
  27923. ],
  27924. [
  27925. 11,
  27926. 24
  27927. ],
  27928. [
  27929. 11,
  27930. 25
  27931. ],
  27932. [
  27933. 11,
  27934. 25
  27935. ],
  27936. [
  27937. 11,
  27938. 25
  27939. ],
  27940. [
  27941. 11,
  27942. 25
  27943. ],
  27944. [
  27945. 13,
  27946. 1664
  27947. ],
  27948. [
  27949. 13,
  27950. 1728
  27951. ],
  27952. [
  27953. 12,
  27954. 320
  27955. ],
  27956. [
  27957. 12,
  27958. 320
  27959. ],
  27960. [
  27961. 12,
  27962. 384
  27963. ],
  27964. [
  27965. 12,
  27966. 384
  27967. ],
  27968. [
  27969. 12,
  27970. 448
  27971. ],
  27972. [
  27973. 12,
  27974. 448
  27975. ],
  27976. [
  27977. 13,
  27978. 512
  27979. ],
  27980. [
  27981. 13,
  27982. 576
  27983. ],
  27984. [
  27985. 12,
  27986. 53
  27987. ],
  27988. [
  27989. 12,
  27990. 53
  27991. ],
  27992. [
  27993. 12,
  27994. 54
  27995. ],
  27996. [
  27997. 12,
  27998. 54
  27999. ],
  28000. [
  28001. 13,
  28002. 896
  28003. ],
  28004. [
  28005. 13,
  28006. 960
  28007. ],
  28008. [
  28009. 13,
  28010. 1024
  28011. ],
  28012. [
  28013. 13,
  28014. 1088
  28015. ],
  28016. [
  28017. 13,
  28018. 1152
  28019. ],
  28020. [
  28021. 13,
  28022. 1216
  28023. ],
  28024. [
  28025. 10,
  28026. 64
  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. var blackTable2 = [
  28058. [
  28059. 8,
  28060. 13
  28061. ],
  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. 11,
  28124. 23
  28125. ],
  28126. [
  28127. 11,
  28128. 23
  28129. ],
  28130. [
  28131. 12,
  28132. 50
  28133. ],
  28134. [
  28135. 12,
  28136. 51
  28137. ],
  28138. [
  28139. 12,
  28140. 44
  28141. ],
  28142. [
  28143. 12,
  28144. 45
  28145. ],
  28146. [
  28147. 12,
  28148. 46
  28149. ],
  28150. [
  28151. 12,
  28152. 47
  28153. ],
  28154. [
  28155. 12,
  28156. 57
  28157. ],
  28158. [
  28159. 12,
  28160. 58
  28161. ],
  28162. [
  28163. 12,
  28164. 61
  28165. ],
  28166. [
  28167. 12,
  28168. 256
  28169. ],
  28170. [
  28171. 10,
  28172. 16
  28173. ],
  28174. [
  28175. 10,
  28176. 16
  28177. ],
  28178. [
  28179. 10,
  28180. 16
  28181. ],
  28182. [
  28183. 10,
  28184. 16
  28185. ],
  28186. [
  28187. 10,
  28188. 17
  28189. ],
  28190. [
  28191. 10,
  28192. 17
  28193. ],
  28194. [
  28195. 10,
  28196. 17
  28197. ],
  28198. [
  28199. 10,
  28200. 17
  28201. ],
  28202. [
  28203. 12,
  28204. 48
  28205. ],
  28206. [
  28207. 12,
  28208. 49
  28209. ],
  28210. [
  28211. 12,
  28212. 62
  28213. ],
  28214. [
  28215. 12,
  28216. 63
  28217. ],
  28218. [
  28219. 12,
  28220. 30
  28221. ],
  28222. [
  28223. 12,
  28224. 31
  28225. ],
  28226. [
  28227. 12,
  28228. 32
  28229. ],
  28230. [
  28231. 12,
  28232. 33
  28233. ],
  28234. [
  28235. 12,
  28236. 40
  28237. ],
  28238. [
  28239. 12,
  28240. 41
  28241. ],
  28242. [
  28243. 11,
  28244. 22
  28245. ],
  28246. [
  28247. 11,
  28248. 22
  28249. ],
  28250. [
  28251. 8,
  28252. 14
  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. 7,
  28316. 10
  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. 11
  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. 9,
  28572. 15
  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. 12,
  28604. 128
  28605. ],
  28606. [
  28607. 12,
  28608. 192
  28609. ],
  28610. [
  28611. 12,
  28612. 26
  28613. ],
  28614. [
  28615. 12,
  28616. 27
  28617. ],
  28618. [
  28619. 12,
  28620. 28
  28621. ],
  28622. [
  28623. 12,
  28624. 29
  28625. ],
  28626. [
  28627. 11,
  28628. 19
  28629. ],
  28630. [
  28631. 11,
  28632. 19
  28633. ],
  28634. [
  28635. 11,
  28636. 20
  28637. ],
  28638. [
  28639. 11,
  28640. 20
  28641. ],
  28642. [
  28643. 12,
  28644. 34
  28645. ],
  28646. [
  28647. 12,
  28648. 35
  28649. ],
  28650. [
  28651. 12,
  28652. 36
  28653. ],
  28654. [
  28655. 12,
  28656. 37
  28657. ],
  28658. [
  28659. 12,
  28660. 38
  28661. ],
  28662. [
  28663. 12,
  28664. 39
  28665. ],
  28666. [
  28667. 11,
  28668. 21
  28669. ],
  28670. [
  28671. 11,
  28672. 21
  28673. ],
  28674. [
  28675. 12,
  28676. 42
  28677. ],
  28678. [
  28679. 12,
  28680. 43
  28681. ],
  28682. [
  28683. 10,
  28684. 0
  28685. ],
  28686. [
  28687. 10,
  28688. 0
  28689. ],
  28690. [
  28691. 10,
  28692. 0
  28693. ],
  28694. [
  28695. 10,
  28696. 0
  28697. ],
  28698. [
  28699. 7,
  28700. 12
  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. var blackTable3 = [
  28828. [
  28829. -1,
  28830. -1
  28831. ],
  28832. [
  28833. -1,
  28834. -1
  28835. ],
  28836. [
  28837. -1,
  28838. -1
  28839. ],
  28840. [
  28841. -1,
  28842. -1
  28843. ],
  28844. [
  28845. 6,
  28846. 9
  28847. ],
  28848. [
  28849. 6,
  28850. 8
  28851. ],
  28852. [
  28853. 5,
  28854. 7
  28855. ],
  28856. [
  28857. 5,
  28858. 7
  28859. ],
  28860. [
  28861. 4,
  28862. 6
  28863. ],
  28864. [
  28865. 4,
  28866. 6
  28867. ],
  28868. [
  28869. 4,
  28870. 6
  28871. ],
  28872. [
  28873. 4,
  28874. 6
  28875. ],
  28876. [
  28877. 4,
  28878. 5
  28879. ],
  28880. [
  28881. 4,
  28882. 5
  28883. ],
  28884. [
  28885. 4,
  28886. 5
  28887. ],
  28888. [
  28889. 4,
  28890. 5
  28891. ],
  28892. [
  28893. 3,
  28894. 1
  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. 4
  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. 2,
  28958. 3
  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. 2
  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. function CCITTFaxStream(str, maybeLength, params) {
  29086. this.str = str;
  29087. this.dict = str.dict;
  29088. params = params || Dict.empty;
  29089. this.encoding = params.get('K') || 0;
  29090. this.eoline = params.get('EndOfLine') || false;
  29091. this.byteAlign = params.get('EncodedByteAlign') || false;
  29092. this.columns = params.get('Columns') || 1728;
  29093. this.rows = params.get('Rows') || 0;
  29094. var eoblock = params.get('EndOfBlock');
  29095. if (eoblock === null || eoblock === undefined) {
  29096. eoblock = true;
  29097. }
  29098. this.eoblock = eoblock;
  29099. this.black = params.get('BlackIs1') || false;
  29100. this.codingLine = new Uint32Array(this.columns + 1);
  29101. this.refLine = new Uint32Array(this.columns + 2);
  29102. this.codingLine[0] = this.columns;
  29103. this.codingPos = 0;
  29104. this.row = 0;
  29105. this.nextLine2D = this.encoding < 0;
  29106. this.inputBits = 0;
  29107. this.inputBuf = 0;
  29108. this.outputBits = 0;
  29109. var code1;
  29110. while ((code1 = this.lookBits(12)) === 0) {
  29111. this.eatBits(1);
  29112. }
  29113. if (code1 === 1) {
  29114. this.eatBits(12);
  29115. }
  29116. if (this.encoding > 0) {
  29117. this.nextLine2D = !this.lookBits(1);
  29118. this.eatBits(1);
  29119. }
  29120. DecodeStream.call(this, maybeLength);
  29121. }
  29122. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  29123. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  29124. while (!this.eof) {
  29125. var c = this.lookChar();
  29126. this.ensureBuffer(this.bufferLength + 1);
  29127. this.buffer[this.bufferLength++] = c;
  29128. }
  29129. };
  29130. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  29131. var codingLine = this.codingLine;
  29132. var codingPos = this.codingPos;
  29133. if (a1 > codingLine[codingPos]) {
  29134. if (a1 > this.columns) {
  29135. info('row is wrong length');
  29136. this.err = true;
  29137. a1 = this.columns;
  29138. }
  29139. if (codingPos & 1 ^ blackPixels) {
  29140. ++codingPos;
  29141. }
  29142. codingLine[codingPos] = a1;
  29143. }
  29144. this.codingPos = codingPos;
  29145. };
  29146. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  29147. var codingLine = this.codingLine;
  29148. var codingPos = this.codingPos;
  29149. if (a1 > codingLine[codingPos]) {
  29150. if (a1 > this.columns) {
  29151. info('row is wrong length');
  29152. this.err = true;
  29153. a1 = this.columns;
  29154. }
  29155. if (codingPos & 1 ^ blackPixels) {
  29156. ++codingPos;
  29157. }
  29158. codingLine[codingPos] = a1;
  29159. } else if (a1 < codingLine[codingPos]) {
  29160. if (a1 < 0) {
  29161. info('invalid code');
  29162. this.err = true;
  29163. a1 = 0;
  29164. }
  29165. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  29166. --codingPos;
  29167. }
  29168. codingLine[codingPos] = a1;
  29169. }
  29170. this.codingPos = codingPos;
  29171. };
  29172. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  29173. var refLine = this.refLine;
  29174. var codingLine = this.codingLine;
  29175. var columns = this.columns;
  29176. var refPos, blackPixels, bits, i;
  29177. if (this.outputBits === 0) {
  29178. if (this.eof) {
  29179. return null;
  29180. }
  29181. this.err = false;
  29182. var code1, code2, code3;
  29183. if (this.nextLine2D) {
  29184. for (i = 0; codingLine[i] < columns; ++i) {
  29185. refLine[i] = codingLine[i];
  29186. }
  29187. refLine[i++] = columns;
  29188. refLine[i] = columns;
  29189. codingLine[0] = 0;
  29190. this.codingPos = 0;
  29191. refPos = 0;
  29192. blackPixels = 0;
  29193. while (codingLine[this.codingPos] < columns) {
  29194. code1 = this.getTwoDimCode();
  29195. switch (code1) {
  29196. case twoDimPass:
  29197. this.addPixels(refLine[refPos + 1], blackPixels);
  29198. if (refLine[refPos + 1] < columns) {
  29199. refPos += 2;
  29200. }
  29201. break;
  29202. case twoDimHoriz:
  29203. code1 = code2 = 0;
  29204. if (blackPixels) {
  29205. do {
  29206. code1 += code3 = this.getBlackCode();
  29207. } while (code3 >= 64);
  29208. do {
  29209. code2 += code3 = this.getWhiteCode();
  29210. } while (code3 >= 64);
  29211. } else {
  29212. do {
  29213. code1 += code3 = this.getWhiteCode();
  29214. } while (code3 >= 64);
  29215. do {
  29216. code2 += code3 = this.getBlackCode();
  29217. } while (code3 >= 64);
  29218. }
  29219. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  29220. if (codingLine[this.codingPos] < columns) {
  29221. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  29222. }
  29223. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29224. refPos += 2;
  29225. }
  29226. break;
  29227. case twoDimVertR3:
  29228. this.addPixels(refLine[refPos] + 3, blackPixels);
  29229. blackPixels ^= 1;
  29230. if (codingLine[this.codingPos] < columns) {
  29231. ++refPos;
  29232. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29233. refPos += 2;
  29234. }
  29235. }
  29236. break;
  29237. case twoDimVertR2:
  29238. this.addPixels(refLine[refPos] + 2, blackPixels);
  29239. blackPixels ^= 1;
  29240. if (codingLine[this.codingPos] < columns) {
  29241. ++refPos;
  29242. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29243. refPos += 2;
  29244. }
  29245. }
  29246. break;
  29247. case twoDimVertR1:
  29248. this.addPixels(refLine[refPos] + 1, blackPixels);
  29249. blackPixels ^= 1;
  29250. if (codingLine[this.codingPos] < columns) {
  29251. ++refPos;
  29252. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29253. refPos += 2;
  29254. }
  29255. }
  29256. break;
  29257. case twoDimVert0:
  29258. this.addPixels(refLine[refPos], blackPixels);
  29259. blackPixels ^= 1;
  29260. if (codingLine[this.codingPos] < columns) {
  29261. ++refPos;
  29262. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29263. refPos += 2;
  29264. }
  29265. }
  29266. break;
  29267. case twoDimVertL3:
  29268. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  29269. blackPixels ^= 1;
  29270. if (codingLine[this.codingPos] < columns) {
  29271. if (refPos > 0) {
  29272. --refPos;
  29273. } else {
  29274. ++refPos;
  29275. }
  29276. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29277. refPos += 2;
  29278. }
  29279. }
  29280. break;
  29281. case twoDimVertL2:
  29282. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  29283. blackPixels ^= 1;
  29284. if (codingLine[this.codingPos] < columns) {
  29285. if (refPos > 0) {
  29286. --refPos;
  29287. } else {
  29288. ++refPos;
  29289. }
  29290. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29291. refPos += 2;
  29292. }
  29293. }
  29294. break;
  29295. case twoDimVertL1:
  29296. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  29297. blackPixels ^= 1;
  29298. if (codingLine[this.codingPos] < columns) {
  29299. if (refPos > 0) {
  29300. --refPos;
  29301. } else {
  29302. ++refPos;
  29303. }
  29304. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  29305. refPos += 2;
  29306. }
  29307. }
  29308. break;
  29309. case ccittEOF:
  29310. this.addPixels(columns, 0);
  29311. this.eof = true;
  29312. break;
  29313. default:
  29314. info('bad 2d code');
  29315. this.addPixels(columns, 0);
  29316. this.err = true;
  29317. }
  29318. }
  29319. } else {
  29320. codingLine[0] = 0;
  29321. this.codingPos = 0;
  29322. blackPixels = 0;
  29323. while (codingLine[this.codingPos] < columns) {
  29324. code1 = 0;
  29325. if (blackPixels) {
  29326. do {
  29327. code1 += code3 = this.getBlackCode();
  29328. } while (code3 >= 64);
  29329. } else {
  29330. do {
  29331. code1 += code3 = this.getWhiteCode();
  29332. } while (code3 >= 64);
  29333. }
  29334. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  29335. blackPixels ^= 1;
  29336. }
  29337. }
  29338. var gotEOL = false;
  29339. if (this.byteAlign) {
  29340. this.inputBits &= ~7;
  29341. }
  29342. if (!this.eoblock && this.row === this.rows - 1) {
  29343. this.eof = true;
  29344. } else {
  29345. code1 = this.lookBits(12);
  29346. if (this.eoline) {
  29347. while (code1 !== ccittEOF && code1 !== 1) {
  29348. this.eatBits(1);
  29349. code1 = this.lookBits(12);
  29350. }
  29351. } else {
  29352. while (code1 === 0) {
  29353. this.eatBits(1);
  29354. code1 = this.lookBits(12);
  29355. }
  29356. }
  29357. if (code1 === 1) {
  29358. this.eatBits(12);
  29359. gotEOL = true;
  29360. } else if (code1 === ccittEOF) {
  29361. this.eof = true;
  29362. }
  29363. }
  29364. if (!this.eof && this.encoding > 0) {
  29365. this.nextLine2D = !this.lookBits(1);
  29366. this.eatBits(1);
  29367. }
  29368. if (this.eoblock && gotEOL && this.byteAlign) {
  29369. code1 = this.lookBits(12);
  29370. if (code1 === 1) {
  29371. this.eatBits(12);
  29372. if (this.encoding > 0) {
  29373. this.lookBits(1);
  29374. this.eatBits(1);
  29375. }
  29376. if (this.encoding >= 0) {
  29377. for (i = 0; i < 4; ++i) {
  29378. code1 = this.lookBits(12);
  29379. if (code1 !== 1) {
  29380. info('bad rtc code: ' + code1);
  29381. }
  29382. this.eatBits(12);
  29383. if (this.encoding > 0) {
  29384. this.lookBits(1);
  29385. this.eatBits(1);
  29386. }
  29387. }
  29388. }
  29389. this.eof = true;
  29390. }
  29391. } else if (this.err && this.eoline) {
  29392. while (true) {
  29393. code1 = this.lookBits(13);
  29394. if (code1 === ccittEOF) {
  29395. this.eof = true;
  29396. return null;
  29397. }
  29398. if (code1 >> 1 === 1) {
  29399. break;
  29400. }
  29401. this.eatBits(1);
  29402. }
  29403. this.eatBits(12);
  29404. if (this.encoding > 0) {
  29405. this.eatBits(1);
  29406. this.nextLine2D = !(code1 & 1);
  29407. }
  29408. }
  29409. if (codingLine[0] > 0) {
  29410. this.outputBits = codingLine[this.codingPos = 0];
  29411. } else {
  29412. this.outputBits = codingLine[this.codingPos = 1];
  29413. }
  29414. this.row++;
  29415. }
  29416. var c;
  29417. if (this.outputBits >= 8) {
  29418. c = this.codingPos & 1 ? 0 : 0xFF;
  29419. this.outputBits -= 8;
  29420. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  29421. this.codingPos++;
  29422. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  29423. }
  29424. } else {
  29425. bits = 8;
  29426. c = 0;
  29427. do {
  29428. if (this.outputBits > bits) {
  29429. c <<= bits;
  29430. if (!(this.codingPos & 1)) {
  29431. c |= 0xFF >> 8 - bits;
  29432. }
  29433. this.outputBits -= bits;
  29434. bits = 0;
  29435. } else {
  29436. c <<= this.outputBits;
  29437. if (!(this.codingPos & 1)) {
  29438. c |= 0xFF >> 8 - this.outputBits;
  29439. }
  29440. bits -= this.outputBits;
  29441. this.outputBits = 0;
  29442. if (codingLine[this.codingPos] < columns) {
  29443. this.codingPos++;
  29444. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  29445. } else if (bits > 0) {
  29446. c <<= bits;
  29447. bits = 0;
  29448. }
  29449. }
  29450. } while (bits);
  29451. }
  29452. if (this.black) {
  29453. c ^= 0xFF;
  29454. }
  29455. return c;
  29456. };
  29457. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  29458. var limitValue = limit || 0;
  29459. for (var i = start; i <= end; ++i) {
  29460. var code = this.lookBits(i);
  29461. if (code === ccittEOF) {
  29462. return [
  29463. true,
  29464. 1,
  29465. false
  29466. ];
  29467. }
  29468. if (i < end) {
  29469. code <<= end - i;
  29470. }
  29471. if (!limitValue || code >= limitValue) {
  29472. var p = table[code - limitValue];
  29473. if (p[0] === i) {
  29474. this.eatBits(i);
  29475. return [
  29476. true,
  29477. p[1],
  29478. true
  29479. ];
  29480. }
  29481. }
  29482. }
  29483. return [
  29484. false,
  29485. 0,
  29486. false
  29487. ];
  29488. };
  29489. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  29490. var code = 0;
  29491. var p;
  29492. if (this.eoblock) {
  29493. code = this.lookBits(7);
  29494. p = twoDimTable[code];
  29495. if (p && p[0] > 0) {
  29496. this.eatBits(p[0]);
  29497. return p[1];
  29498. }
  29499. } else {
  29500. var result = this.findTableCode(1, 7, twoDimTable);
  29501. if (result[0] && result[2]) {
  29502. return result[1];
  29503. }
  29504. }
  29505. info('Bad two dim code');
  29506. return ccittEOF;
  29507. };
  29508. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  29509. var code = 0;
  29510. var p;
  29511. if (this.eoblock) {
  29512. code = this.lookBits(12);
  29513. if (code === ccittEOF) {
  29514. return 1;
  29515. }
  29516. if (code >> 5 === 0) {
  29517. p = whiteTable1[code];
  29518. } else {
  29519. p = whiteTable2[code >> 3];
  29520. }
  29521. if (p[0] > 0) {
  29522. this.eatBits(p[0]);
  29523. return p[1];
  29524. }
  29525. } else {
  29526. var result = this.findTableCode(1, 9, whiteTable2);
  29527. if (result[0]) {
  29528. return result[1];
  29529. }
  29530. result = this.findTableCode(11, 12, whiteTable1);
  29531. if (result[0]) {
  29532. return result[1];
  29533. }
  29534. }
  29535. info('bad white code');
  29536. this.eatBits(1);
  29537. return 1;
  29538. };
  29539. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  29540. var code, p;
  29541. if (this.eoblock) {
  29542. code = this.lookBits(13);
  29543. if (code === ccittEOF) {
  29544. return 1;
  29545. }
  29546. if (code >> 7 === 0) {
  29547. p = blackTable1[code];
  29548. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  29549. p = blackTable2[(code >> 1) - 64];
  29550. } else {
  29551. p = blackTable3[code >> 7];
  29552. }
  29553. if (p[0] > 0) {
  29554. this.eatBits(p[0]);
  29555. return p[1];
  29556. }
  29557. } else {
  29558. var result = this.findTableCode(2, 6, blackTable3);
  29559. if (result[0]) {
  29560. return result[1];
  29561. }
  29562. result = this.findTableCode(7, 12, blackTable2, 64);
  29563. if (result[0]) {
  29564. return result[1];
  29565. }
  29566. result = this.findTableCode(10, 13, blackTable1);
  29567. if (result[0]) {
  29568. return result[1];
  29569. }
  29570. }
  29571. info('bad black code');
  29572. this.eatBits(1);
  29573. return 1;
  29574. };
  29575. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  29576. var c;
  29577. while (this.inputBits < n) {
  29578. if ((c = this.str.getByte()) === -1) {
  29579. if (this.inputBits === 0) {
  29580. return ccittEOF;
  29581. }
  29582. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  29583. }
  29584. this.inputBuf = this.inputBuf << 8 | c;
  29585. this.inputBits += 8;
  29586. }
  29587. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  29588. };
  29589. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  29590. if ((this.inputBits -= n) < 0) {
  29591. this.inputBits = 0;
  29592. }
  29593. };
  29594. return CCITTFaxStream;
  29595. }();
  29596. var LZWStream = function LZWStreamClosure() {
  29597. function LZWStream(str, maybeLength, earlyChange) {
  29598. this.str = str;
  29599. this.dict = str.dict;
  29600. this.cachedData = 0;
  29601. this.bitsCached = 0;
  29602. var maxLzwDictionarySize = 4096;
  29603. var lzwState = {
  29604. earlyChange: earlyChange,
  29605. codeLength: 9,
  29606. nextCode: 258,
  29607. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  29608. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  29609. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  29610. currentSequence: new Uint8Array(maxLzwDictionarySize),
  29611. currentSequenceLength: 0
  29612. };
  29613. for (var i = 0; i < 256; ++i) {
  29614. lzwState.dictionaryValues[i] = i;
  29615. lzwState.dictionaryLengths[i] = 1;
  29616. }
  29617. this.lzwState = lzwState;
  29618. DecodeStream.call(this, maybeLength);
  29619. }
  29620. LZWStream.prototype = Object.create(DecodeStream.prototype);
  29621. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  29622. var bitsCached = this.bitsCached;
  29623. var cachedData = this.cachedData;
  29624. while (bitsCached < n) {
  29625. var c = this.str.getByte();
  29626. if (c === -1) {
  29627. this.eof = true;
  29628. return null;
  29629. }
  29630. cachedData = cachedData << 8 | c;
  29631. bitsCached += 8;
  29632. }
  29633. this.bitsCached = bitsCached -= n;
  29634. this.cachedData = cachedData;
  29635. this.lastCode = null;
  29636. return cachedData >>> bitsCached & (1 << n) - 1;
  29637. };
  29638. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  29639. var blockSize = 512;
  29640. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  29641. var i, j, q;
  29642. var lzwState = this.lzwState;
  29643. if (!lzwState) {
  29644. return;
  29645. }
  29646. var earlyChange = lzwState.earlyChange;
  29647. var nextCode = lzwState.nextCode;
  29648. var dictionaryValues = lzwState.dictionaryValues;
  29649. var dictionaryLengths = lzwState.dictionaryLengths;
  29650. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  29651. var codeLength = lzwState.codeLength;
  29652. var prevCode = lzwState.prevCode;
  29653. var currentSequence = lzwState.currentSequence;
  29654. var currentSequenceLength = lzwState.currentSequenceLength;
  29655. var decodedLength = 0;
  29656. var currentBufferLength = this.bufferLength;
  29657. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  29658. for (i = 0; i < blockSize; i++) {
  29659. var code = this.readBits(codeLength);
  29660. var hasPrev = currentSequenceLength > 0;
  29661. if (code < 256) {
  29662. currentSequence[0] = code;
  29663. currentSequenceLength = 1;
  29664. } else if (code >= 258) {
  29665. if (code < nextCode) {
  29666. currentSequenceLength = dictionaryLengths[code];
  29667. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  29668. currentSequence[j] = dictionaryValues[q];
  29669. q = dictionaryPrevCodes[q];
  29670. }
  29671. } else {
  29672. currentSequence[currentSequenceLength++] = currentSequence[0];
  29673. }
  29674. } else if (code === 256) {
  29675. codeLength = 9;
  29676. nextCode = 258;
  29677. currentSequenceLength = 0;
  29678. continue;
  29679. } else {
  29680. this.eof = true;
  29681. delete this.lzwState;
  29682. break;
  29683. }
  29684. if (hasPrev) {
  29685. dictionaryPrevCodes[nextCode] = prevCode;
  29686. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  29687. dictionaryValues[nextCode] = currentSequence[0];
  29688. nextCode++;
  29689. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  29690. }
  29691. prevCode = code;
  29692. decodedLength += currentSequenceLength;
  29693. if (estimatedDecodedSize < decodedLength) {
  29694. do {
  29695. estimatedDecodedSize += decodedSizeDelta;
  29696. } while (estimatedDecodedSize < decodedLength);
  29697. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  29698. }
  29699. for (j = 0; j < currentSequenceLength; j++) {
  29700. buffer[currentBufferLength++] = currentSequence[j];
  29701. }
  29702. }
  29703. lzwState.nextCode = nextCode;
  29704. lzwState.codeLength = codeLength;
  29705. lzwState.prevCode = prevCode;
  29706. lzwState.currentSequenceLength = currentSequenceLength;
  29707. this.bufferLength = currentBufferLength;
  29708. };
  29709. return LZWStream;
  29710. }();
  29711. var NullStream = function NullStreamClosure() {
  29712. function NullStream() {
  29713. Stream.call(this, new Uint8Array(0));
  29714. }
  29715. NullStream.prototype = Stream.prototype;
  29716. return NullStream;
  29717. }();
  29718. exports.Ascii85Stream = Ascii85Stream;
  29719. exports.AsciiHexStream = AsciiHexStream;
  29720. exports.CCITTFaxStream = CCITTFaxStream;
  29721. exports.DecryptStream = DecryptStream;
  29722. exports.DecodeStream = DecodeStream;
  29723. exports.FlateStream = FlateStream;
  29724. exports.Jbig2Stream = Jbig2Stream;
  29725. exports.JpegStream = JpegStream;
  29726. exports.JpxStream = JpxStream;
  29727. exports.NullStream = NullStream;
  29728. exports.PredictorStream = PredictorStream;
  29729. exports.RunLengthStream = RunLengthStream;
  29730. exports.Stream = Stream;
  29731. exports.StreamsSequenceStream = StreamsSequenceStream;
  29732. exports.StringStream = StringStream;
  29733. exports.LZWStream = LZWStream;
  29734. }));
  29735. (function (root, factory) {
  29736. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  29737. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  29738. var PasswordException = sharedUtil.PasswordException;
  29739. var PasswordResponses = sharedUtil.PasswordResponses;
  29740. var bytesToString = sharedUtil.bytesToString;
  29741. var warn = sharedUtil.warn;
  29742. var error = sharedUtil.error;
  29743. var assert = sharedUtil.assert;
  29744. var isInt = sharedUtil.isInt;
  29745. var stringToBytes = sharedUtil.stringToBytes;
  29746. var utf8StringToString = sharedUtil.utf8StringToString;
  29747. var Name = corePrimitives.Name;
  29748. var isName = corePrimitives.isName;
  29749. var isDict = corePrimitives.isDict;
  29750. var DecryptStream = coreStream.DecryptStream;
  29751. var ARCFourCipher = function ARCFourCipherClosure() {
  29752. function ARCFourCipher(key) {
  29753. this.a = 0;
  29754. this.b = 0;
  29755. var s = new Uint8Array(256);
  29756. var i, j = 0, tmp, keyLength = key.length;
  29757. for (i = 0; i < 256; ++i) {
  29758. s[i] = i;
  29759. }
  29760. for (i = 0; i < 256; ++i) {
  29761. tmp = s[i];
  29762. j = j + tmp + key[i % keyLength] & 0xFF;
  29763. s[i] = s[j];
  29764. s[j] = tmp;
  29765. }
  29766. this.s = s;
  29767. }
  29768. ARCFourCipher.prototype = {
  29769. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  29770. var i, n = data.length, tmp, tmp2;
  29771. var a = this.a, b = this.b, s = this.s;
  29772. var output = new Uint8Array(n);
  29773. for (i = 0; i < n; ++i) {
  29774. a = a + 1 & 0xFF;
  29775. tmp = s[a];
  29776. b = b + tmp & 0xFF;
  29777. tmp2 = s[b];
  29778. s[a] = tmp2;
  29779. s[b] = tmp;
  29780. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  29781. }
  29782. this.a = a;
  29783. this.b = b;
  29784. return output;
  29785. }
  29786. };
  29787. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  29788. return ARCFourCipher;
  29789. }();
  29790. var calculateMD5 = function calculateMD5Closure() {
  29791. var r = new Uint8Array([
  29792. 7,
  29793. 12,
  29794. 17,
  29795. 22,
  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. 5,
  29809. 9,
  29810. 14,
  29811. 20,
  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. 4,
  29825. 11,
  29826. 16,
  29827. 23,
  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. 6,
  29841. 10,
  29842. 15,
  29843. 21,
  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. ]);
  29857. var k = new Int32Array([
  29858. -680876936,
  29859. -389564586,
  29860. 606105819,
  29861. -1044525330,
  29862. -176418897,
  29863. 1200080426,
  29864. -1473231341,
  29865. -45705983,
  29866. 1770035416,
  29867. -1958414417,
  29868. -42063,
  29869. -1990404162,
  29870. 1804603682,
  29871. -40341101,
  29872. -1502002290,
  29873. 1236535329,
  29874. -165796510,
  29875. -1069501632,
  29876. 643717713,
  29877. -373897302,
  29878. -701558691,
  29879. 38016083,
  29880. -660478335,
  29881. -405537848,
  29882. 568446438,
  29883. -1019803690,
  29884. -187363961,
  29885. 1163531501,
  29886. -1444681467,
  29887. -51403784,
  29888. 1735328473,
  29889. -1926607734,
  29890. -378558,
  29891. -2022574463,
  29892. 1839030562,
  29893. -35309556,
  29894. -1530992060,
  29895. 1272893353,
  29896. -155497632,
  29897. -1094730640,
  29898. 681279174,
  29899. -358537222,
  29900. -722521979,
  29901. 76029189,
  29902. -640364487,
  29903. -421815835,
  29904. 530742520,
  29905. -995338651,
  29906. -198630844,
  29907. 1126891415,
  29908. -1416354905,
  29909. -57434055,
  29910. 1700485571,
  29911. -1894986606,
  29912. -1051523,
  29913. -2054922799,
  29914. 1873313359,
  29915. -30611744,
  29916. -1560198380,
  29917. 1309151649,
  29918. -145523070,
  29919. -1120210379,
  29920. 718787259,
  29921. -343485551
  29922. ]);
  29923. function hash(data, offset, length) {
  29924. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  29925. var paddedLength = length + 72 & ~63;
  29926. var padded = new Uint8Array(paddedLength);
  29927. var i, j, n;
  29928. for (i = 0; i < length; ++i) {
  29929. padded[i] = data[offset++];
  29930. }
  29931. padded[i++] = 0x80;
  29932. n = paddedLength - 8;
  29933. while (i < n) {
  29934. padded[i++] = 0;
  29935. }
  29936. padded[i++] = length << 3 & 0xFF;
  29937. padded[i++] = length >> 5 & 0xFF;
  29938. padded[i++] = length >> 13 & 0xFF;
  29939. padded[i++] = length >> 21 & 0xFF;
  29940. padded[i++] = length >>> 29 & 0xFF;
  29941. padded[i++] = 0;
  29942. padded[i++] = 0;
  29943. padded[i++] = 0;
  29944. var w = new Int32Array(16);
  29945. for (i = 0; i < paddedLength;) {
  29946. for (j = 0; j < 16; ++j, i += 4) {
  29947. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  29948. }
  29949. var a = h0, b = h1, c = h2, d = h3, f, g;
  29950. for (j = 0; j < 64; ++j) {
  29951. if (j < 16) {
  29952. f = b & c | ~b & d;
  29953. g = j;
  29954. } else if (j < 32) {
  29955. f = d & b | ~d & c;
  29956. g = 5 * j + 1 & 15;
  29957. } else if (j < 48) {
  29958. f = b ^ c ^ d;
  29959. g = 3 * j + 5 & 15;
  29960. } else {
  29961. f = c ^ (b | ~d);
  29962. g = 7 * j & 15;
  29963. }
  29964. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  29965. d = c;
  29966. c = b;
  29967. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  29968. a = tmp;
  29969. }
  29970. h0 = h0 + a | 0;
  29971. h1 = h1 + b | 0;
  29972. h2 = h2 + c | 0;
  29973. h3 = h3 + d | 0;
  29974. }
  29975. return new Uint8Array([
  29976. h0 & 0xFF,
  29977. h0 >> 8 & 0xFF,
  29978. h0 >> 16 & 0xFF,
  29979. h0 >>> 24 & 0xFF,
  29980. h1 & 0xFF,
  29981. h1 >> 8 & 0xFF,
  29982. h1 >> 16 & 0xFF,
  29983. h1 >>> 24 & 0xFF,
  29984. h2 & 0xFF,
  29985. h2 >> 8 & 0xFF,
  29986. h2 >> 16 & 0xFF,
  29987. h2 >>> 24 & 0xFF,
  29988. h3 & 0xFF,
  29989. h3 >> 8 & 0xFF,
  29990. h3 >> 16 & 0xFF,
  29991. h3 >>> 24 & 0xFF
  29992. ]);
  29993. }
  29994. return hash;
  29995. }();
  29996. var Word64 = function Word64Closure() {
  29997. function Word64(highInteger, lowInteger) {
  29998. this.high = highInteger | 0;
  29999. this.low = lowInteger | 0;
  30000. }
  30001. Word64.prototype = {
  30002. and: function Word64_and(word) {
  30003. this.high &= word.high;
  30004. this.low &= word.low;
  30005. },
  30006. xor: function Word64_xor(word) {
  30007. this.high ^= word.high;
  30008. this.low ^= word.low;
  30009. },
  30010. or: function Word64_or(word) {
  30011. this.high |= word.high;
  30012. this.low |= word.low;
  30013. },
  30014. shiftRight: function Word64_shiftRight(places) {
  30015. if (places >= 32) {
  30016. this.low = this.high >>> places - 32 | 0;
  30017. this.high = 0;
  30018. } else {
  30019. this.low = this.low >>> places | this.high << 32 - places;
  30020. this.high = this.high >>> places | 0;
  30021. }
  30022. },
  30023. shiftLeft: function Word64_shiftLeft(places) {
  30024. if (places >= 32) {
  30025. this.high = this.low << places - 32;
  30026. this.low = 0;
  30027. } else {
  30028. this.high = this.high << places | this.low >>> 32 - places;
  30029. this.low = this.low << places;
  30030. }
  30031. },
  30032. rotateRight: function Word64_rotateRight(places) {
  30033. var low, high;
  30034. if (places & 32) {
  30035. high = this.low;
  30036. low = this.high;
  30037. } else {
  30038. low = this.low;
  30039. high = this.high;
  30040. }
  30041. places &= 31;
  30042. this.low = low >>> places | high << 32 - places;
  30043. this.high = high >>> places | low << 32 - places;
  30044. },
  30045. not: function Word64_not() {
  30046. this.high = ~this.high;
  30047. this.low = ~this.low;
  30048. },
  30049. add: function Word64_add(word) {
  30050. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  30051. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  30052. if (lowAdd > 0xFFFFFFFF) {
  30053. highAdd += 1;
  30054. }
  30055. this.low = lowAdd | 0;
  30056. this.high = highAdd | 0;
  30057. },
  30058. copyTo: function Word64_copyTo(bytes, offset) {
  30059. bytes[offset] = this.high >>> 24 & 0xFF;
  30060. bytes[offset + 1] = this.high >> 16 & 0xFF;
  30061. bytes[offset + 2] = this.high >> 8 & 0xFF;
  30062. bytes[offset + 3] = this.high & 0xFF;
  30063. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  30064. bytes[offset + 5] = this.low >> 16 & 0xFF;
  30065. bytes[offset + 6] = this.low >> 8 & 0xFF;
  30066. bytes[offset + 7] = this.low & 0xFF;
  30067. },
  30068. assign: function Word64_assign(word) {
  30069. this.high = word.high;
  30070. this.low = word.low;
  30071. }
  30072. };
  30073. return Word64;
  30074. }();
  30075. var calculateSHA256 = function calculateSHA256Closure() {
  30076. function rotr(x, n) {
  30077. return x >>> n | x << 32 - n;
  30078. }
  30079. function ch(x, y, z) {
  30080. return x & y ^ ~x & z;
  30081. }
  30082. function maj(x, y, z) {
  30083. return x & y ^ x & z ^ y & z;
  30084. }
  30085. function sigma(x) {
  30086. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  30087. }
  30088. function sigmaPrime(x) {
  30089. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  30090. }
  30091. function littleSigma(x) {
  30092. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  30093. }
  30094. function littleSigmaPrime(x) {
  30095. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  30096. }
  30097. var k = [
  30098. 0x428a2f98,
  30099. 0x71374491,
  30100. 0xb5c0fbcf,
  30101. 0xe9b5dba5,
  30102. 0x3956c25b,
  30103. 0x59f111f1,
  30104. 0x923f82a4,
  30105. 0xab1c5ed5,
  30106. 0xd807aa98,
  30107. 0x12835b01,
  30108. 0x243185be,
  30109. 0x550c7dc3,
  30110. 0x72be5d74,
  30111. 0x80deb1fe,
  30112. 0x9bdc06a7,
  30113. 0xc19bf174,
  30114. 0xe49b69c1,
  30115. 0xefbe4786,
  30116. 0x0fc19dc6,
  30117. 0x240ca1cc,
  30118. 0x2de92c6f,
  30119. 0x4a7484aa,
  30120. 0x5cb0a9dc,
  30121. 0x76f988da,
  30122. 0x983e5152,
  30123. 0xa831c66d,
  30124. 0xb00327c8,
  30125. 0xbf597fc7,
  30126. 0xc6e00bf3,
  30127. 0xd5a79147,
  30128. 0x06ca6351,
  30129. 0x14292967,
  30130. 0x27b70a85,
  30131. 0x2e1b2138,
  30132. 0x4d2c6dfc,
  30133. 0x53380d13,
  30134. 0x650a7354,
  30135. 0x766a0abb,
  30136. 0x81c2c92e,
  30137. 0x92722c85,
  30138. 0xa2bfe8a1,
  30139. 0xa81a664b,
  30140. 0xc24b8b70,
  30141. 0xc76c51a3,
  30142. 0xd192e819,
  30143. 0xd6990624,
  30144. 0xf40e3585,
  30145. 0x106aa070,
  30146. 0x19a4c116,
  30147. 0x1e376c08,
  30148. 0x2748774c,
  30149. 0x34b0bcb5,
  30150. 0x391c0cb3,
  30151. 0x4ed8aa4a,
  30152. 0x5b9cca4f,
  30153. 0x682e6ff3,
  30154. 0x748f82ee,
  30155. 0x78a5636f,
  30156. 0x84c87814,
  30157. 0x8cc70208,
  30158. 0x90befffa,
  30159. 0xa4506ceb,
  30160. 0xbef9a3f7,
  30161. 0xc67178f2
  30162. ];
  30163. function hash(data, offset, length) {
  30164. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  30165. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  30166. var padded = new Uint8Array(paddedLength);
  30167. var i, j, n;
  30168. for (i = 0; i < length; ++i) {
  30169. padded[i] = data[offset++];
  30170. }
  30171. padded[i++] = 0x80;
  30172. n = paddedLength - 8;
  30173. while (i < n) {
  30174. padded[i++] = 0;
  30175. }
  30176. padded[i++] = 0;
  30177. padded[i++] = 0;
  30178. padded[i++] = 0;
  30179. padded[i++] = length >>> 29 & 0xFF;
  30180. padded[i++] = length >> 21 & 0xFF;
  30181. padded[i++] = length >> 13 & 0xFF;
  30182. padded[i++] = length >> 5 & 0xFF;
  30183. padded[i++] = length << 3 & 0xFF;
  30184. var w = new Uint32Array(64);
  30185. for (i = 0; i < paddedLength;) {
  30186. for (j = 0; j < 16; ++j) {
  30187. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  30188. i += 4;
  30189. }
  30190. for (j = 16; j < 64; ++j) {
  30191. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  30192. }
  30193. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  30194. for (j = 0; j < 64; ++j) {
  30195. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  30196. t2 = sigma(a) + maj(a, b, c);
  30197. h = g;
  30198. g = f;
  30199. f = e;
  30200. e = d + t1 | 0;
  30201. d = c;
  30202. c = b;
  30203. b = a;
  30204. a = t1 + t2 | 0;
  30205. }
  30206. h0 = h0 + a | 0;
  30207. h1 = h1 + b | 0;
  30208. h2 = h2 + c | 0;
  30209. h3 = h3 + d | 0;
  30210. h4 = h4 + e | 0;
  30211. h5 = h5 + f | 0;
  30212. h6 = h6 + g | 0;
  30213. h7 = h7 + h | 0;
  30214. }
  30215. return new Uint8Array([
  30216. h0 >> 24 & 0xFF,
  30217. h0 >> 16 & 0xFF,
  30218. h0 >> 8 & 0xFF,
  30219. h0 & 0xFF,
  30220. h1 >> 24 & 0xFF,
  30221. h1 >> 16 & 0xFF,
  30222. h1 >> 8 & 0xFF,
  30223. h1 & 0xFF,
  30224. h2 >> 24 & 0xFF,
  30225. h2 >> 16 & 0xFF,
  30226. h2 >> 8 & 0xFF,
  30227. h2 & 0xFF,
  30228. h3 >> 24 & 0xFF,
  30229. h3 >> 16 & 0xFF,
  30230. h3 >> 8 & 0xFF,
  30231. h3 & 0xFF,
  30232. h4 >> 24 & 0xFF,
  30233. h4 >> 16 & 0xFF,
  30234. h4 >> 8 & 0xFF,
  30235. h4 & 0xFF,
  30236. h5 >> 24 & 0xFF,
  30237. h5 >> 16 & 0xFF,
  30238. h5 >> 8 & 0xFF,
  30239. h5 & 0xFF,
  30240. h6 >> 24 & 0xFF,
  30241. h6 >> 16 & 0xFF,
  30242. h6 >> 8 & 0xFF,
  30243. h6 & 0xFF,
  30244. h7 >> 24 & 0xFF,
  30245. h7 >> 16 & 0xFF,
  30246. h7 >> 8 & 0xFF,
  30247. h7 & 0xFF
  30248. ]);
  30249. }
  30250. return hash;
  30251. }();
  30252. var calculateSHA512 = function calculateSHA512Closure() {
  30253. function ch(result, x, y, z, tmp) {
  30254. result.assign(x);
  30255. result.and(y);
  30256. tmp.assign(x);
  30257. tmp.not();
  30258. tmp.and(z);
  30259. result.xor(tmp);
  30260. }
  30261. function maj(result, x, y, z, tmp) {
  30262. result.assign(x);
  30263. result.and(y);
  30264. tmp.assign(x);
  30265. tmp.and(z);
  30266. result.xor(tmp);
  30267. tmp.assign(y);
  30268. tmp.and(z);
  30269. result.xor(tmp);
  30270. }
  30271. function sigma(result, x, tmp) {
  30272. result.assign(x);
  30273. result.rotateRight(28);
  30274. tmp.assign(x);
  30275. tmp.rotateRight(34);
  30276. result.xor(tmp);
  30277. tmp.assign(x);
  30278. tmp.rotateRight(39);
  30279. result.xor(tmp);
  30280. }
  30281. function sigmaPrime(result, x, tmp) {
  30282. result.assign(x);
  30283. result.rotateRight(14);
  30284. tmp.assign(x);
  30285. tmp.rotateRight(18);
  30286. result.xor(tmp);
  30287. tmp.assign(x);
  30288. tmp.rotateRight(41);
  30289. result.xor(tmp);
  30290. }
  30291. function littleSigma(result, x, tmp) {
  30292. result.assign(x);
  30293. result.rotateRight(1);
  30294. tmp.assign(x);
  30295. tmp.rotateRight(8);
  30296. result.xor(tmp);
  30297. tmp.assign(x);
  30298. tmp.shiftRight(7);
  30299. result.xor(tmp);
  30300. }
  30301. function littleSigmaPrime(result, x, tmp) {
  30302. result.assign(x);
  30303. result.rotateRight(19);
  30304. tmp.assign(x);
  30305. tmp.rotateRight(61);
  30306. result.xor(tmp);
  30307. tmp.assign(x);
  30308. tmp.shiftRight(6);
  30309. result.xor(tmp);
  30310. }
  30311. var k = [
  30312. new Word64(0x428a2f98, 0xd728ae22),
  30313. new Word64(0x71374491, 0x23ef65cd),
  30314. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  30315. new Word64(0xe9b5dba5, 0x8189dbbc),
  30316. new Word64(0x3956c25b, 0xf348b538),
  30317. new Word64(0x59f111f1, 0xb605d019),
  30318. new Word64(0x923f82a4, 0xaf194f9b),
  30319. new Word64(0xab1c5ed5, 0xda6d8118),
  30320. new Word64(0xd807aa98, 0xa3030242),
  30321. new Word64(0x12835b01, 0x45706fbe),
  30322. new Word64(0x243185be, 0x4ee4b28c),
  30323. new Word64(0x550c7dc3, 0xd5ffb4e2),
  30324. new Word64(0x72be5d74, 0xf27b896f),
  30325. new Word64(0x80deb1fe, 0x3b1696b1),
  30326. new Word64(0x9bdc06a7, 0x25c71235),
  30327. new Word64(0xc19bf174, 0xcf692694),
  30328. new Word64(0xe49b69c1, 0x9ef14ad2),
  30329. new Word64(0xefbe4786, 0x384f25e3),
  30330. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  30331. new Word64(0x240ca1cc, 0x77ac9c65),
  30332. new Word64(0x2de92c6f, 0x592b0275),
  30333. new Word64(0x4a7484aa, 0x6ea6e483),
  30334. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  30335. new Word64(0x76f988da, 0x831153b5),
  30336. new Word64(0x983e5152, 0xee66dfab),
  30337. new Word64(0xa831c66d, 0x2db43210),
  30338. new Word64(0xb00327c8, 0x98fb213f),
  30339. new Word64(0xbf597fc7, 0xbeef0ee4),
  30340. new Word64(0xc6e00bf3, 0x3da88fc2),
  30341. new Word64(0xd5a79147, 0x930aa725),
  30342. new Word64(0x06ca6351, 0xe003826f),
  30343. new Word64(0x14292967, 0x0a0e6e70),
  30344. new Word64(0x27b70a85, 0x46d22ffc),
  30345. new Word64(0x2e1b2138, 0x5c26c926),
  30346. new Word64(0x4d2c6dfc, 0x5ac42aed),
  30347. new Word64(0x53380d13, 0x9d95b3df),
  30348. new Word64(0x650a7354, 0x8baf63de),
  30349. new Word64(0x766a0abb, 0x3c77b2a8),
  30350. new Word64(0x81c2c92e, 0x47edaee6),
  30351. new Word64(0x92722c85, 0x1482353b),
  30352. new Word64(0xa2bfe8a1, 0x4cf10364),
  30353. new Word64(0xa81a664b, 0xbc423001),
  30354. new Word64(0xc24b8b70, 0xd0f89791),
  30355. new Word64(0xc76c51a3, 0x0654be30),
  30356. new Word64(0xd192e819, 0xd6ef5218),
  30357. new Word64(0xd6990624, 0x5565a910),
  30358. new Word64(0xf40e3585, 0x5771202a),
  30359. new Word64(0x106aa070, 0x32bbd1b8),
  30360. new Word64(0x19a4c116, 0xb8d2d0c8),
  30361. new Word64(0x1e376c08, 0x5141ab53),
  30362. new Word64(0x2748774c, 0xdf8eeb99),
  30363. new Word64(0x34b0bcb5, 0xe19b48a8),
  30364. new Word64(0x391c0cb3, 0xc5c95a63),
  30365. new Word64(0x4ed8aa4a, 0xe3418acb),
  30366. new Word64(0x5b9cca4f, 0x7763e373),
  30367. new Word64(0x682e6ff3, 0xd6b2b8a3),
  30368. new Word64(0x748f82ee, 0x5defb2fc),
  30369. new Word64(0x78a5636f, 0x43172f60),
  30370. new Word64(0x84c87814, 0xa1f0ab72),
  30371. new Word64(0x8cc70208, 0x1a6439ec),
  30372. new Word64(0x90befffa, 0x23631e28),
  30373. new Word64(0xa4506ceb, 0xde82bde9),
  30374. new Word64(0xbef9a3f7, 0xb2c67915),
  30375. new Word64(0xc67178f2, 0xe372532b),
  30376. new Word64(0xca273ece, 0xea26619c),
  30377. new Word64(0xd186b8c7, 0x21c0c207),
  30378. new Word64(0xeada7dd6, 0xcde0eb1e),
  30379. new Word64(0xf57d4f7f, 0xee6ed178),
  30380. new Word64(0x06f067aa, 0x72176fba),
  30381. new Word64(0x0a637dc5, 0xa2c898a6),
  30382. new Word64(0x113f9804, 0xbef90dae),
  30383. new Word64(0x1b710b35, 0x131c471b),
  30384. new Word64(0x28db77f5, 0x23047d84),
  30385. new Word64(0x32caab7b, 0x40c72493),
  30386. new Word64(0x3c9ebe0a, 0x15c9bebc),
  30387. new Word64(0x431d67c4, 0x9c100d4c),
  30388. new Word64(0x4cc5d4be, 0xcb3e42b6),
  30389. new Word64(0x597f299c, 0xfc657e2a),
  30390. new Word64(0x5fcb6fab, 0x3ad6faec),
  30391. new Word64(0x6c44198c, 0x4a475817)
  30392. ];
  30393. function hash(data, offset, length, mode384) {
  30394. mode384 = !!mode384;
  30395. var h0, h1, h2, h3, h4, h5, h6, h7;
  30396. if (!mode384) {
  30397. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  30398. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  30399. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  30400. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  30401. h4 = new Word64(0x510e527f, 0xade682d1);
  30402. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  30403. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  30404. h7 = new Word64(0x5be0cd19, 0x137e2179);
  30405. } else {
  30406. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  30407. h1 = new Word64(0x629a292a, 0x367cd507);
  30408. h2 = new Word64(0x9159015a, 0x3070dd17);
  30409. h3 = new Word64(0x152fecd8, 0xf70e5939);
  30410. h4 = new Word64(0x67332667, 0xffc00b31);
  30411. h5 = new Word64(0x8eb44a87, 0x68581511);
  30412. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  30413. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  30414. }
  30415. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  30416. var padded = new Uint8Array(paddedLength);
  30417. var i, j, n;
  30418. for (i = 0; i < length; ++i) {
  30419. padded[i] = data[offset++];
  30420. }
  30421. padded[i++] = 0x80;
  30422. n = paddedLength - 16;
  30423. while (i < n) {
  30424. padded[i++] = 0;
  30425. }
  30426. padded[i++] = 0;
  30427. padded[i++] = 0;
  30428. padded[i++] = 0;
  30429. padded[i++] = 0;
  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++] = length >>> 29 & 0xFF;
  30438. padded[i++] = length >> 21 & 0xFF;
  30439. padded[i++] = length >> 13 & 0xFF;
  30440. padded[i++] = length >> 5 & 0xFF;
  30441. padded[i++] = length << 3 & 0xFF;
  30442. var w = new Array(80);
  30443. for (i = 0; i < 80; i++) {
  30444. w[i] = new Word64(0, 0);
  30445. }
  30446. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  30447. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  30448. var g = new Word64(0, 0), h = new Word64(0, 0);
  30449. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  30450. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  30451. for (i = 0; i < paddedLength;) {
  30452. for (j = 0; j < 16; ++j) {
  30453. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  30454. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  30455. i += 8;
  30456. }
  30457. for (j = 16; j < 80; ++j) {
  30458. tmp3 = w[j];
  30459. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  30460. tmp3.add(w[j - 7]);
  30461. littleSigma(tmp1, w[j - 15], tmp2);
  30462. tmp3.add(tmp1);
  30463. tmp3.add(w[j - 16]);
  30464. }
  30465. a.assign(h0);
  30466. b.assign(h1);
  30467. c.assign(h2);
  30468. d.assign(h3);
  30469. e.assign(h4);
  30470. f.assign(h5);
  30471. g.assign(h6);
  30472. h.assign(h7);
  30473. for (j = 0; j < 80; ++j) {
  30474. t1.assign(h);
  30475. sigmaPrime(tmp1, e, tmp2);
  30476. t1.add(tmp1);
  30477. ch(tmp1, e, f, g, tmp2);
  30478. t1.add(tmp1);
  30479. t1.add(k[j]);
  30480. t1.add(w[j]);
  30481. sigma(t2, a, tmp2);
  30482. maj(tmp1, a, b, c, tmp2);
  30483. t2.add(tmp1);
  30484. tmp3 = h;
  30485. h = g;
  30486. g = f;
  30487. f = e;
  30488. d.add(t1);
  30489. e = d;
  30490. d = c;
  30491. c = b;
  30492. b = a;
  30493. tmp3.assign(t1);
  30494. tmp3.add(t2);
  30495. a = tmp3;
  30496. }
  30497. h0.add(a);
  30498. h1.add(b);
  30499. h2.add(c);
  30500. h3.add(d);
  30501. h4.add(e);
  30502. h5.add(f);
  30503. h6.add(g);
  30504. h7.add(h);
  30505. }
  30506. var result;
  30507. if (!mode384) {
  30508. result = new Uint8Array(64);
  30509. h0.copyTo(result, 0);
  30510. h1.copyTo(result, 8);
  30511. h2.copyTo(result, 16);
  30512. h3.copyTo(result, 24);
  30513. h4.copyTo(result, 32);
  30514. h5.copyTo(result, 40);
  30515. h6.copyTo(result, 48);
  30516. h7.copyTo(result, 56);
  30517. } else {
  30518. result = new Uint8Array(48);
  30519. h0.copyTo(result, 0);
  30520. h1.copyTo(result, 8);
  30521. h2.copyTo(result, 16);
  30522. h3.copyTo(result, 24);
  30523. h4.copyTo(result, 32);
  30524. h5.copyTo(result, 40);
  30525. }
  30526. return result;
  30527. }
  30528. return hash;
  30529. }();
  30530. var calculateSHA384 = function calculateSHA384Closure() {
  30531. function hash(data, offset, length) {
  30532. return calculateSHA512(data, offset, length, true);
  30533. }
  30534. return hash;
  30535. }();
  30536. var NullCipher = function NullCipherClosure() {
  30537. function NullCipher() {
  30538. }
  30539. NullCipher.prototype = {
  30540. decryptBlock: function NullCipher_decryptBlock(data) {
  30541. return data;
  30542. }
  30543. };
  30544. return NullCipher;
  30545. }();
  30546. var AES128Cipher = function AES128CipherClosure() {
  30547. var rcon = new Uint8Array([
  30548. 0x8d,
  30549. 0x01,
  30550. 0x02,
  30551. 0x04,
  30552. 0x08,
  30553. 0x10,
  30554. 0x20,
  30555. 0x40,
  30556. 0x80,
  30557. 0x1b,
  30558. 0x36,
  30559. 0x6c,
  30560. 0xd8,
  30561. 0xab,
  30562. 0x4d,
  30563. 0x9a,
  30564. 0x2f,
  30565. 0x5e,
  30566. 0xbc,
  30567. 0x63,
  30568. 0xc6,
  30569. 0x97,
  30570. 0x35,
  30571. 0x6a,
  30572. 0xd4,
  30573. 0xb3,
  30574. 0x7d,
  30575. 0xfa,
  30576. 0xef,
  30577. 0xc5,
  30578. 0x91,
  30579. 0x39,
  30580. 0x72,
  30581. 0xe4,
  30582. 0xd3,
  30583. 0xbd,
  30584. 0x61,
  30585. 0xc2,
  30586. 0x9f,
  30587. 0x25,
  30588. 0x4a,
  30589. 0x94,
  30590. 0x33,
  30591. 0x66,
  30592. 0xcc,
  30593. 0x83,
  30594. 0x1d,
  30595. 0x3a,
  30596. 0x74,
  30597. 0xe8,
  30598. 0xcb,
  30599. 0x8d,
  30600. 0x01,
  30601. 0x02,
  30602. 0x04,
  30603. 0x08,
  30604. 0x10,
  30605. 0x20,
  30606. 0x40,
  30607. 0x80,
  30608. 0x1b,
  30609. 0x36,
  30610. 0x6c,
  30611. 0xd8,
  30612. 0xab,
  30613. 0x4d,
  30614. 0x9a,
  30615. 0x2f,
  30616. 0x5e,
  30617. 0xbc,
  30618. 0x63,
  30619. 0xc6,
  30620. 0x97,
  30621. 0x35,
  30622. 0x6a,
  30623. 0xd4,
  30624. 0xb3,
  30625. 0x7d,
  30626. 0xfa,
  30627. 0xef,
  30628. 0xc5,
  30629. 0x91,
  30630. 0x39,
  30631. 0x72,
  30632. 0xe4,
  30633. 0xd3,
  30634. 0xbd,
  30635. 0x61,
  30636. 0xc2,
  30637. 0x9f,
  30638. 0x25,
  30639. 0x4a,
  30640. 0x94,
  30641. 0x33,
  30642. 0x66,
  30643. 0xcc,
  30644. 0x83,
  30645. 0x1d,
  30646. 0x3a,
  30647. 0x74,
  30648. 0xe8,
  30649. 0xcb,
  30650. 0x8d,
  30651. 0x01,
  30652. 0x02,
  30653. 0x04,
  30654. 0x08,
  30655. 0x10,
  30656. 0x20,
  30657. 0x40,
  30658. 0x80,
  30659. 0x1b,
  30660. 0x36,
  30661. 0x6c,
  30662. 0xd8,
  30663. 0xab,
  30664. 0x4d,
  30665. 0x9a,
  30666. 0x2f,
  30667. 0x5e,
  30668. 0xbc,
  30669. 0x63,
  30670. 0xc6,
  30671. 0x97,
  30672. 0x35,
  30673. 0x6a,
  30674. 0xd4,
  30675. 0xb3,
  30676. 0x7d,
  30677. 0xfa,
  30678. 0xef,
  30679. 0xc5,
  30680. 0x91,
  30681. 0x39,
  30682. 0x72,
  30683. 0xe4,
  30684. 0xd3,
  30685. 0xbd,
  30686. 0x61,
  30687. 0xc2,
  30688. 0x9f,
  30689. 0x25,
  30690. 0x4a,
  30691. 0x94,
  30692. 0x33,
  30693. 0x66,
  30694. 0xcc,
  30695. 0x83,
  30696. 0x1d,
  30697. 0x3a,
  30698. 0x74,
  30699. 0xe8,
  30700. 0xcb,
  30701. 0x8d,
  30702. 0x01,
  30703. 0x02,
  30704. 0x04,
  30705. 0x08,
  30706. 0x10,
  30707. 0x20,
  30708. 0x40,
  30709. 0x80,
  30710. 0x1b,
  30711. 0x36,
  30712. 0x6c,
  30713. 0xd8,
  30714. 0xab,
  30715. 0x4d,
  30716. 0x9a,
  30717. 0x2f,
  30718. 0x5e,
  30719. 0xbc,
  30720. 0x63,
  30721. 0xc6,
  30722. 0x97,
  30723. 0x35,
  30724. 0x6a,
  30725. 0xd4,
  30726. 0xb3,
  30727. 0x7d,
  30728. 0xfa,
  30729. 0xef,
  30730. 0xc5,
  30731. 0x91,
  30732. 0x39,
  30733. 0x72,
  30734. 0xe4,
  30735. 0xd3,
  30736. 0xbd,
  30737. 0x61,
  30738. 0xc2,
  30739. 0x9f,
  30740. 0x25,
  30741. 0x4a,
  30742. 0x94,
  30743. 0x33,
  30744. 0x66,
  30745. 0xcc,
  30746. 0x83,
  30747. 0x1d,
  30748. 0x3a,
  30749. 0x74,
  30750. 0xe8,
  30751. 0xcb,
  30752. 0x8d,
  30753. 0x01,
  30754. 0x02,
  30755. 0x04,
  30756. 0x08,
  30757. 0x10,
  30758. 0x20,
  30759. 0x40,
  30760. 0x80,
  30761. 0x1b,
  30762. 0x36,
  30763. 0x6c,
  30764. 0xd8,
  30765. 0xab,
  30766. 0x4d,
  30767. 0x9a,
  30768. 0x2f,
  30769. 0x5e,
  30770. 0xbc,
  30771. 0x63,
  30772. 0xc6,
  30773. 0x97,
  30774. 0x35,
  30775. 0x6a,
  30776. 0xd4,
  30777. 0xb3,
  30778. 0x7d,
  30779. 0xfa,
  30780. 0xef,
  30781. 0xc5,
  30782. 0x91,
  30783. 0x39,
  30784. 0x72,
  30785. 0xe4,
  30786. 0xd3,
  30787. 0xbd,
  30788. 0x61,
  30789. 0xc2,
  30790. 0x9f,
  30791. 0x25,
  30792. 0x4a,
  30793. 0x94,
  30794. 0x33,
  30795. 0x66,
  30796. 0xcc,
  30797. 0x83,
  30798. 0x1d,
  30799. 0x3a,
  30800. 0x74,
  30801. 0xe8,
  30802. 0xcb,
  30803. 0x8d
  30804. ]);
  30805. var s = new Uint8Array([
  30806. 0x63,
  30807. 0x7c,
  30808. 0x77,
  30809. 0x7b,
  30810. 0xf2,
  30811. 0x6b,
  30812. 0x6f,
  30813. 0xc5,
  30814. 0x30,
  30815. 0x01,
  30816. 0x67,
  30817. 0x2b,
  30818. 0xfe,
  30819. 0xd7,
  30820. 0xab,
  30821. 0x76,
  30822. 0xca,
  30823. 0x82,
  30824. 0xc9,
  30825. 0x7d,
  30826. 0xfa,
  30827. 0x59,
  30828. 0x47,
  30829. 0xf0,
  30830. 0xad,
  30831. 0xd4,
  30832. 0xa2,
  30833. 0xaf,
  30834. 0x9c,
  30835. 0xa4,
  30836. 0x72,
  30837. 0xc0,
  30838. 0xb7,
  30839. 0xfd,
  30840. 0x93,
  30841. 0x26,
  30842. 0x36,
  30843. 0x3f,
  30844. 0xf7,
  30845. 0xcc,
  30846. 0x34,
  30847. 0xa5,
  30848. 0xe5,
  30849. 0xf1,
  30850. 0x71,
  30851. 0xd8,
  30852. 0x31,
  30853. 0x15,
  30854. 0x04,
  30855. 0xc7,
  30856. 0x23,
  30857. 0xc3,
  30858. 0x18,
  30859. 0x96,
  30860. 0x05,
  30861. 0x9a,
  30862. 0x07,
  30863. 0x12,
  30864. 0x80,
  30865. 0xe2,
  30866. 0xeb,
  30867. 0x27,
  30868. 0xb2,
  30869. 0x75,
  30870. 0x09,
  30871. 0x83,
  30872. 0x2c,
  30873. 0x1a,
  30874. 0x1b,
  30875. 0x6e,
  30876. 0x5a,
  30877. 0xa0,
  30878. 0x52,
  30879. 0x3b,
  30880. 0xd6,
  30881. 0xb3,
  30882. 0x29,
  30883. 0xe3,
  30884. 0x2f,
  30885. 0x84,
  30886. 0x53,
  30887. 0xd1,
  30888. 0x00,
  30889. 0xed,
  30890. 0x20,
  30891. 0xfc,
  30892. 0xb1,
  30893. 0x5b,
  30894. 0x6a,
  30895. 0xcb,
  30896. 0xbe,
  30897. 0x39,
  30898. 0x4a,
  30899. 0x4c,
  30900. 0x58,
  30901. 0xcf,
  30902. 0xd0,
  30903. 0xef,
  30904. 0xaa,
  30905. 0xfb,
  30906. 0x43,
  30907. 0x4d,
  30908. 0x33,
  30909. 0x85,
  30910. 0x45,
  30911. 0xf9,
  30912. 0x02,
  30913. 0x7f,
  30914. 0x50,
  30915. 0x3c,
  30916. 0x9f,
  30917. 0xa8,
  30918. 0x51,
  30919. 0xa3,
  30920. 0x40,
  30921. 0x8f,
  30922. 0x92,
  30923. 0x9d,
  30924. 0x38,
  30925. 0xf5,
  30926. 0xbc,
  30927. 0xb6,
  30928. 0xda,
  30929. 0x21,
  30930. 0x10,
  30931. 0xff,
  30932. 0xf3,
  30933. 0xd2,
  30934. 0xcd,
  30935. 0x0c,
  30936. 0x13,
  30937. 0xec,
  30938. 0x5f,
  30939. 0x97,
  30940. 0x44,
  30941. 0x17,
  30942. 0xc4,
  30943. 0xa7,
  30944. 0x7e,
  30945. 0x3d,
  30946. 0x64,
  30947. 0x5d,
  30948. 0x19,
  30949. 0x73,
  30950. 0x60,
  30951. 0x81,
  30952. 0x4f,
  30953. 0xdc,
  30954. 0x22,
  30955. 0x2a,
  30956. 0x90,
  30957. 0x88,
  30958. 0x46,
  30959. 0xee,
  30960. 0xb8,
  30961. 0x14,
  30962. 0xde,
  30963. 0x5e,
  30964. 0x0b,
  30965. 0xdb,
  30966. 0xe0,
  30967. 0x32,
  30968. 0x3a,
  30969. 0x0a,
  30970. 0x49,
  30971. 0x06,
  30972. 0x24,
  30973. 0x5c,
  30974. 0xc2,
  30975. 0xd3,
  30976. 0xac,
  30977. 0x62,
  30978. 0x91,
  30979. 0x95,
  30980. 0xe4,
  30981. 0x79,
  30982. 0xe7,
  30983. 0xc8,
  30984. 0x37,
  30985. 0x6d,
  30986. 0x8d,
  30987. 0xd5,
  30988. 0x4e,
  30989. 0xa9,
  30990. 0x6c,
  30991. 0x56,
  30992. 0xf4,
  30993. 0xea,
  30994. 0x65,
  30995. 0x7a,
  30996. 0xae,
  30997. 0x08,
  30998. 0xba,
  30999. 0x78,
  31000. 0x25,
  31001. 0x2e,
  31002. 0x1c,
  31003. 0xa6,
  31004. 0xb4,
  31005. 0xc6,
  31006. 0xe8,
  31007. 0xdd,
  31008. 0x74,
  31009. 0x1f,
  31010. 0x4b,
  31011. 0xbd,
  31012. 0x8b,
  31013. 0x8a,
  31014. 0x70,
  31015. 0x3e,
  31016. 0xb5,
  31017. 0x66,
  31018. 0x48,
  31019. 0x03,
  31020. 0xf6,
  31021. 0x0e,
  31022. 0x61,
  31023. 0x35,
  31024. 0x57,
  31025. 0xb9,
  31026. 0x86,
  31027. 0xc1,
  31028. 0x1d,
  31029. 0x9e,
  31030. 0xe1,
  31031. 0xf8,
  31032. 0x98,
  31033. 0x11,
  31034. 0x69,
  31035. 0xd9,
  31036. 0x8e,
  31037. 0x94,
  31038. 0x9b,
  31039. 0x1e,
  31040. 0x87,
  31041. 0xe9,
  31042. 0xce,
  31043. 0x55,
  31044. 0x28,
  31045. 0xdf,
  31046. 0x8c,
  31047. 0xa1,
  31048. 0x89,
  31049. 0x0d,
  31050. 0xbf,
  31051. 0xe6,
  31052. 0x42,
  31053. 0x68,
  31054. 0x41,
  31055. 0x99,
  31056. 0x2d,
  31057. 0x0f,
  31058. 0xb0,
  31059. 0x54,
  31060. 0xbb,
  31061. 0x16
  31062. ]);
  31063. var inv_s = new Uint8Array([
  31064. 0x52,
  31065. 0x09,
  31066. 0x6a,
  31067. 0xd5,
  31068. 0x30,
  31069. 0x36,
  31070. 0xa5,
  31071. 0x38,
  31072. 0xbf,
  31073. 0x40,
  31074. 0xa3,
  31075. 0x9e,
  31076. 0x81,
  31077. 0xf3,
  31078. 0xd7,
  31079. 0xfb,
  31080. 0x7c,
  31081. 0xe3,
  31082. 0x39,
  31083. 0x82,
  31084. 0x9b,
  31085. 0x2f,
  31086. 0xff,
  31087. 0x87,
  31088. 0x34,
  31089. 0x8e,
  31090. 0x43,
  31091. 0x44,
  31092. 0xc4,
  31093. 0xde,
  31094. 0xe9,
  31095. 0xcb,
  31096. 0x54,
  31097. 0x7b,
  31098. 0x94,
  31099. 0x32,
  31100. 0xa6,
  31101. 0xc2,
  31102. 0x23,
  31103. 0x3d,
  31104. 0xee,
  31105. 0x4c,
  31106. 0x95,
  31107. 0x0b,
  31108. 0x42,
  31109. 0xfa,
  31110. 0xc3,
  31111. 0x4e,
  31112. 0x08,
  31113. 0x2e,
  31114. 0xa1,
  31115. 0x66,
  31116. 0x28,
  31117. 0xd9,
  31118. 0x24,
  31119. 0xb2,
  31120. 0x76,
  31121. 0x5b,
  31122. 0xa2,
  31123. 0x49,
  31124. 0x6d,
  31125. 0x8b,
  31126. 0xd1,
  31127. 0x25,
  31128. 0x72,
  31129. 0xf8,
  31130. 0xf6,
  31131. 0x64,
  31132. 0x86,
  31133. 0x68,
  31134. 0x98,
  31135. 0x16,
  31136. 0xd4,
  31137. 0xa4,
  31138. 0x5c,
  31139. 0xcc,
  31140. 0x5d,
  31141. 0x65,
  31142. 0xb6,
  31143. 0x92,
  31144. 0x6c,
  31145. 0x70,
  31146. 0x48,
  31147. 0x50,
  31148. 0xfd,
  31149. 0xed,
  31150. 0xb9,
  31151. 0xda,
  31152. 0x5e,
  31153. 0x15,
  31154. 0x46,
  31155. 0x57,
  31156. 0xa7,
  31157. 0x8d,
  31158. 0x9d,
  31159. 0x84,
  31160. 0x90,
  31161. 0xd8,
  31162. 0xab,
  31163. 0x00,
  31164. 0x8c,
  31165. 0xbc,
  31166. 0xd3,
  31167. 0x0a,
  31168. 0xf7,
  31169. 0xe4,
  31170. 0x58,
  31171. 0x05,
  31172. 0xb8,
  31173. 0xb3,
  31174. 0x45,
  31175. 0x06,
  31176. 0xd0,
  31177. 0x2c,
  31178. 0x1e,
  31179. 0x8f,
  31180. 0xca,
  31181. 0x3f,
  31182. 0x0f,
  31183. 0x02,
  31184. 0xc1,
  31185. 0xaf,
  31186. 0xbd,
  31187. 0x03,
  31188. 0x01,
  31189. 0x13,
  31190. 0x8a,
  31191. 0x6b,
  31192. 0x3a,
  31193. 0x91,
  31194. 0x11,
  31195. 0x41,
  31196. 0x4f,
  31197. 0x67,
  31198. 0xdc,
  31199. 0xea,
  31200. 0x97,
  31201. 0xf2,
  31202. 0xcf,
  31203. 0xce,
  31204. 0xf0,
  31205. 0xb4,
  31206. 0xe6,
  31207. 0x73,
  31208. 0x96,
  31209. 0xac,
  31210. 0x74,
  31211. 0x22,
  31212. 0xe7,
  31213. 0xad,
  31214. 0x35,
  31215. 0x85,
  31216. 0xe2,
  31217. 0xf9,
  31218. 0x37,
  31219. 0xe8,
  31220. 0x1c,
  31221. 0x75,
  31222. 0xdf,
  31223. 0x6e,
  31224. 0x47,
  31225. 0xf1,
  31226. 0x1a,
  31227. 0x71,
  31228. 0x1d,
  31229. 0x29,
  31230. 0xc5,
  31231. 0x89,
  31232. 0x6f,
  31233. 0xb7,
  31234. 0x62,
  31235. 0x0e,
  31236. 0xaa,
  31237. 0x18,
  31238. 0xbe,
  31239. 0x1b,
  31240. 0xfc,
  31241. 0x56,
  31242. 0x3e,
  31243. 0x4b,
  31244. 0xc6,
  31245. 0xd2,
  31246. 0x79,
  31247. 0x20,
  31248. 0x9a,
  31249. 0xdb,
  31250. 0xc0,
  31251. 0xfe,
  31252. 0x78,
  31253. 0xcd,
  31254. 0x5a,
  31255. 0xf4,
  31256. 0x1f,
  31257. 0xdd,
  31258. 0xa8,
  31259. 0x33,
  31260. 0x88,
  31261. 0x07,
  31262. 0xc7,
  31263. 0x31,
  31264. 0xb1,
  31265. 0x12,
  31266. 0x10,
  31267. 0x59,
  31268. 0x27,
  31269. 0x80,
  31270. 0xec,
  31271. 0x5f,
  31272. 0x60,
  31273. 0x51,
  31274. 0x7f,
  31275. 0xa9,
  31276. 0x19,
  31277. 0xb5,
  31278. 0x4a,
  31279. 0x0d,
  31280. 0x2d,
  31281. 0xe5,
  31282. 0x7a,
  31283. 0x9f,
  31284. 0x93,
  31285. 0xc9,
  31286. 0x9c,
  31287. 0xef,
  31288. 0xa0,
  31289. 0xe0,
  31290. 0x3b,
  31291. 0x4d,
  31292. 0xae,
  31293. 0x2a,
  31294. 0xf5,
  31295. 0xb0,
  31296. 0xc8,
  31297. 0xeb,
  31298. 0xbb,
  31299. 0x3c,
  31300. 0x83,
  31301. 0x53,
  31302. 0x99,
  31303. 0x61,
  31304. 0x17,
  31305. 0x2b,
  31306. 0x04,
  31307. 0x7e,
  31308. 0xba,
  31309. 0x77,
  31310. 0xd6,
  31311. 0x26,
  31312. 0xe1,
  31313. 0x69,
  31314. 0x14,
  31315. 0x63,
  31316. 0x55,
  31317. 0x21,
  31318. 0x0c,
  31319. 0x7d
  31320. ]);
  31321. var mixCol = new Uint8Array(256);
  31322. for (var i = 0; i < 256; i++) {
  31323. if (i < 128) {
  31324. mixCol[i] = i << 1;
  31325. } else {
  31326. mixCol[i] = i << 1 ^ 0x1b;
  31327. }
  31328. }
  31329. var mix = new Uint32Array([
  31330. 0x00000000,
  31331. 0x0e090d0b,
  31332. 0x1c121a16,
  31333. 0x121b171d,
  31334. 0x3824342c,
  31335. 0x362d3927,
  31336. 0x24362e3a,
  31337. 0x2a3f2331,
  31338. 0x70486858,
  31339. 0x7e416553,
  31340. 0x6c5a724e,
  31341. 0x62537f45,
  31342. 0x486c5c74,
  31343. 0x4665517f,
  31344. 0x547e4662,
  31345. 0x5a774b69,
  31346. 0xe090d0b0,
  31347. 0xee99ddbb,
  31348. 0xfc82caa6,
  31349. 0xf28bc7ad,
  31350. 0xd8b4e49c,
  31351. 0xd6bde997,
  31352. 0xc4a6fe8a,
  31353. 0xcaaff381,
  31354. 0x90d8b8e8,
  31355. 0x9ed1b5e3,
  31356. 0x8ccaa2fe,
  31357. 0x82c3aff5,
  31358. 0xa8fc8cc4,
  31359. 0xa6f581cf,
  31360. 0xb4ee96d2,
  31361. 0xbae79bd9,
  31362. 0xdb3bbb7b,
  31363. 0xd532b670,
  31364. 0xc729a16d,
  31365. 0xc920ac66,
  31366. 0xe31f8f57,
  31367. 0xed16825c,
  31368. 0xff0d9541,
  31369. 0xf104984a,
  31370. 0xab73d323,
  31371. 0xa57ade28,
  31372. 0xb761c935,
  31373. 0xb968c43e,
  31374. 0x9357e70f,
  31375. 0x9d5eea04,
  31376. 0x8f45fd19,
  31377. 0x814cf012,
  31378. 0x3bab6bcb,
  31379. 0x35a266c0,
  31380. 0x27b971dd,
  31381. 0x29b07cd6,
  31382. 0x038f5fe7,
  31383. 0x0d8652ec,
  31384. 0x1f9d45f1,
  31385. 0x119448fa,
  31386. 0x4be30393,
  31387. 0x45ea0e98,
  31388. 0x57f11985,
  31389. 0x59f8148e,
  31390. 0x73c737bf,
  31391. 0x7dce3ab4,
  31392. 0x6fd52da9,
  31393. 0x61dc20a2,
  31394. 0xad766df6,
  31395. 0xa37f60fd,
  31396. 0xb16477e0,
  31397. 0xbf6d7aeb,
  31398. 0x955259da,
  31399. 0x9b5b54d1,
  31400. 0x894043cc,
  31401. 0x87494ec7,
  31402. 0xdd3e05ae,
  31403. 0xd33708a5,
  31404. 0xc12c1fb8,
  31405. 0xcf2512b3,
  31406. 0xe51a3182,
  31407. 0xeb133c89,
  31408. 0xf9082b94,
  31409. 0xf701269f,
  31410. 0x4de6bd46,
  31411. 0x43efb04d,
  31412. 0x51f4a750,
  31413. 0x5ffdaa5b,
  31414. 0x75c2896a,
  31415. 0x7bcb8461,
  31416. 0x69d0937c,
  31417. 0x67d99e77,
  31418. 0x3daed51e,
  31419. 0x33a7d815,
  31420. 0x21bccf08,
  31421. 0x2fb5c203,
  31422. 0x058ae132,
  31423. 0x0b83ec39,
  31424. 0x1998fb24,
  31425. 0x1791f62f,
  31426. 0x764dd68d,
  31427. 0x7844db86,
  31428. 0x6a5fcc9b,
  31429. 0x6456c190,
  31430. 0x4e69e2a1,
  31431. 0x4060efaa,
  31432. 0x527bf8b7,
  31433. 0x5c72f5bc,
  31434. 0x0605bed5,
  31435. 0x080cb3de,
  31436. 0x1a17a4c3,
  31437. 0x141ea9c8,
  31438. 0x3e218af9,
  31439. 0x302887f2,
  31440. 0x223390ef,
  31441. 0x2c3a9de4,
  31442. 0x96dd063d,
  31443. 0x98d40b36,
  31444. 0x8acf1c2b,
  31445. 0x84c61120,
  31446. 0xaef93211,
  31447. 0xa0f03f1a,
  31448. 0xb2eb2807,
  31449. 0xbce2250c,
  31450. 0xe6956e65,
  31451. 0xe89c636e,
  31452. 0xfa877473,
  31453. 0xf48e7978,
  31454. 0xdeb15a49,
  31455. 0xd0b85742,
  31456. 0xc2a3405f,
  31457. 0xccaa4d54,
  31458. 0x41ecdaf7,
  31459. 0x4fe5d7fc,
  31460. 0x5dfec0e1,
  31461. 0x53f7cdea,
  31462. 0x79c8eedb,
  31463. 0x77c1e3d0,
  31464. 0x65daf4cd,
  31465. 0x6bd3f9c6,
  31466. 0x31a4b2af,
  31467. 0x3fadbfa4,
  31468. 0x2db6a8b9,
  31469. 0x23bfa5b2,
  31470. 0x09808683,
  31471. 0x07898b88,
  31472. 0x15929c95,
  31473. 0x1b9b919e,
  31474. 0xa17c0a47,
  31475. 0xaf75074c,
  31476. 0xbd6e1051,
  31477. 0xb3671d5a,
  31478. 0x99583e6b,
  31479. 0x97513360,
  31480. 0x854a247d,
  31481. 0x8b432976,
  31482. 0xd134621f,
  31483. 0xdf3d6f14,
  31484. 0xcd267809,
  31485. 0xc32f7502,
  31486. 0xe9105633,
  31487. 0xe7195b38,
  31488. 0xf5024c25,
  31489. 0xfb0b412e,
  31490. 0x9ad7618c,
  31491. 0x94de6c87,
  31492. 0x86c57b9a,
  31493. 0x88cc7691,
  31494. 0xa2f355a0,
  31495. 0xacfa58ab,
  31496. 0xbee14fb6,
  31497. 0xb0e842bd,
  31498. 0xea9f09d4,
  31499. 0xe49604df,
  31500. 0xf68d13c2,
  31501. 0xf8841ec9,
  31502. 0xd2bb3df8,
  31503. 0xdcb230f3,
  31504. 0xcea927ee,
  31505. 0xc0a02ae5,
  31506. 0x7a47b13c,
  31507. 0x744ebc37,
  31508. 0x6655ab2a,
  31509. 0x685ca621,
  31510. 0x42638510,
  31511. 0x4c6a881b,
  31512. 0x5e719f06,
  31513. 0x5078920d,
  31514. 0x0a0fd964,
  31515. 0x0406d46f,
  31516. 0x161dc372,
  31517. 0x1814ce79,
  31518. 0x322bed48,
  31519. 0x3c22e043,
  31520. 0x2e39f75e,
  31521. 0x2030fa55,
  31522. 0xec9ab701,
  31523. 0xe293ba0a,
  31524. 0xf088ad17,
  31525. 0xfe81a01c,
  31526. 0xd4be832d,
  31527. 0xdab78e26,
  31528. 0xc8ac993b,
  31529. 0xc6a59430,
  31530. 0x9cd2df59,
  31531. 0x92dbd252,
  31532. 0x80c0c54f,
  31533. 0x8ec9c844,
  31534. 0xa4f6eb75,
  31535. 0xaaffe67e,
  31536. 0xb8e4f163,
  31537. 0xb6edfc68,
  31538. 0x0c0a67b1,
  31539. 0x02036aba,
  31540. 0x10187da7,
  31541. 0x1e1170ac,
  31542. 0x342e539d,
  31543. 0x3a275e96,
  31544. 0x283c498b,
  31545. 0x26354480,
  31546. 0x7c420fe9,
  31547. 0x724b02e2,
  31548. 0x605015ff,
  31549. 0x6e5918f4,
  31550. 0x44663bc5,
  31551. 0x4a6f36ce,
  31552. 0x587421d3,
  31553. 0x567d2cd8,
  31554. 0x37a10c7a,
  31555. 0x39a80171,
  31556. 0x2bb3166c,
  31557. 0x25ba1b67,
  31558. 0x0f853856,
  31559. 0x018c355d,
  31560. 0x13972240,
  31561. 0x1d9e2f4b,
  31562. 0x47e96422,
  31563. 0x49e06929,
  31564. 0x5bfb7e34,
  31565. 0x55f2733f,
  31566. 0x7fcd500e,
  31567. 0x71c45d05,
  31568. 0x63df4a18,
  31569. 0x6dd64713,
  31570. 0xd731dcca,
  31571. 0xd938d1c1,
  31572. 0xcb23c6dc,
  31573. 0xc52acbd7,
  31574. 0xef15e8e6,
  31575. 0xe11ce5ed,
  31576. 0xf307f2f0,
  31577. 0xfd0efffb,
  31578. 0xa779b492,
  31579. 0xa970b999,
  31580. 0xbb6bae84,
  31581. 0xb562a38f,
  31582. 0x9f5d80be,
  31583. 0x91548db5,
  31584. 0x834f9aa8,
  31585. 0x8d4697a3
  31586. ]);
  31587. function expandKey128(cipherKey) {
  31588. var b = 176, result = new Uint8Array(b);
  31589. result.set(cipherKey);
  31590. for (var j = 16, i = 1; j < b; ++i) {
  31591. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  31592. t1 = s[t1];
  31593. t2 = s[t2];
  31594. t3 = s[t3];
  31595. t4 = s[t4];
  31596. t1 = t1 ^ rcon[i];
  31597. for (var n = 0; n < 4; ++n) {
  31598. result[j] = t1 ^= result[j - 16];
  31599. j++;
  31600. result[j] = t2 ^= result[j - 16];
  31601. j++;
  31602. result[j] = t3 ^= result[j - 16];
  31603. j++;
  31604. result[j] = t4 ^= result[j - 16];
  31605. j++;
  31606. }
  31607. }
  31608. return result;
  31609. }
  31610. function decrypt128(input, key) {
  31611. var state = new Uint8Array(16);
  31612. state.set(input);
  31613. var i, j, k;
  31614. var t, u, v;
  31615. for (j = 0, k = 160; j < 16; ++j, ++k) {
  31616. state[j] ^= key[k];
  31617. }
  31618. for (i = 9; i >= 1; --i) {
  31619. t = state[13];
  31620. state[13] = state[9];
  31621. state[9] = state[5];
  31622. state[5] = state[1];
  31623. state[1] = t;
  31624. t = state[14];
  31625. u = state[10];
  31626. state[14] = state[6];
  31627. state[10] = state[2];
  31628. state[6] = t;
  31629. state[2] = u;
  31630. t = state[15];
  31631. u = state[11];
  31632. v = state[7];
  31633. state[15] = state[3];
  31634. state[11] = t;
  31635. state[7] = u;
  31636. state[3] = v;
  31637. for (j = 0; j < 16; ++j) {
  31638. state[j] = inv_s[state[j]];
  31639. }
  31640. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  31641. state[j] ^= key[k];
  31642. }
  31643. for (j = 0; j < 16; j += 4) {
  31644. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  31645. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  31646. state[j] = t >>> 24 & 0xFF;
  31647. state[j + 1] = t >> 16 & 0xFF;
  31648. state[j + 2] = t >> 8 & 0xFF;
  31649. state[j + 3] = t & 0xFF;
  31650. }
  31651. }
  31652. t = state[13];
  31653. state[13] = state[9];
  31654. state[9] = state[5];
  31655. state[5] = state[1];
  31656. state[1] = t;
  31657. t = state[14];
  31658. u = state[10];
  31659. state[14] = state[6];
  31660. state[10] = state[2];
  31661. state[6] = t;
  31662. state[2] = u;
  31663. t = state[15];
  31664. u = state[11];
  31665. v = state[7];
  31666. state[15] = state[3];
  31667. state[11] = t;
  31668. state[7] = u;
  31669. state[3] = v;
  31670. for (j = 0; j < 16; ++j) {
  31671. state[j] = inv_s[state[j]];
  31672. state[j] ^= key[j];
  31673. }
  31674. return state;
  31675. }
  31676. function encrypt128(input, key) {
  31677. var t, u, v, k;
  31678. var state = new Uint8Array(16);
  31679. state.set(input);
  31680. for (j = 0; j < 16; ++j) {
  31681. state[j] ^= key[j];
  31682. }
  31683. for (i = 1; i < 10; i++) {
  31684. for (j = 0; j < 16; ++j) {
  31685. state[j] = s[state[j]];
  31686. }
  31687. v = state[1];
  31688. state[1] = state[5];
  31689. state[5] = state[9];
  31690. state[9] = state[13];
  31691. state[13] = v;
  31692. v = state[2];
  31693. u = state[6];
  31694. state[2] = state[10];
  31695. state[6] = state[14];
  31696. state[10] = v;
  31697. state[14] = u;
  31698. v = state[3];
  31699. u = state[7];
  31700. t = state[11];
  31701. state[3] = state[15];
  31702. state[7] = v;
  31703. state[11] = u;
  31704. state[15] = t;
  31705. for (var j = 0; j < 16; j += 4) {
  31706. var s0 = state[j + 0], s1 = state[j + 1];
  31707. var s2 = state[j + 2], s3 = state[j + 3];
  31708. t = s0 ^ s1 ^ s2 ^ s3;
  31709. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  31710. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  31711. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  31712. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  31713. }
  31714. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  31715. state[j] ^= key[k];
  31716. }
  31717. }
  31718. for (j = 0; j < 16; ++j) {
  31719. state[j] = s[state[j]];
  31720. }
  31721. v = state[1];
  31722. state[1] = state[5];
  31723. state[5] = state[9];
  31724. state[9] = state[13];
  31725. state[13] = v;
  31726. v = state[2];
  31727. u = state[6];
  31728. state[2] = state[10];
  31729. state[6] = state[14];
  31730. state[10] = v;
  31731. state[14] = u;
  31732. v = state[3];
  31733. u = state[7];
  31734. t = state[11];
  31735. state[3] = state[15];
  31736. state[7] = v;
  31737. state[11] = u;
  31738. state[15] = t;
  31739. for (j = 0, k = 160; j < 16; ++j, ++k) {
  31740. state[j] ^= key[k];
  31741. }
  31742. return state;
  31743. }
  31744. function AES128Cipher(key) {
  31745. this.key = expandKey128(key);
  31746. this.buffer = new Uint8Array(16);
  31747. this.bufferPosition = 0;
  31748. }
  31749. function decryptBlock2(data, finalize) {
  31750. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  31751. for (i = 0; i < sourceLength; ++i) {
  31752. buffer[bufferLength] = data[i];
  31753. ++bufferLength;
  31754. if (bufferLength < 16) {
  31755. continue;
  31756. }
  31757. var plain = decrypt128(buffer, this.key);
  31758. for (j = 0; j < 16; ++j) {
  31759. plain[j] ^= iv[j];
  31760. }
  31761. iv = buffer;
  31762. result.push(plain);
  31763. buffer = new Uint8Array(16);
  31764. bufferLength = 0;
  31765. }
  31766. this.buffer = buffer;
  31767. this.bufferLength = bufferLength;
  31768. this.iv = iv;
  31769. if (result.length === 0) {
  31770. return new Uint8Array([]);
  31771. }
  31772. var outputLength = 16 * result.length;
  31773. if (finalize) {
  31774. var lastBlock = result[result.length - 1];
  31775. var psLen = lastBlock[15];
  31776. if (psLen <= 16) {
  31777. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  31778. if (lastBlock[i] !== psLen) {
  31779. psLen = 0;
  31780. break;
  31781. }
  31782. }
  31783. outputLength -= psLen;
  31784. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  31785. }
  31786. }
  31787. var output = new Uint8Array(outputLength);
  31788. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  31789. output.set(result[i], j);
  31790. }
  31791. return output;
  31792. }
  31793. AES128Cipher.prototype = {
  31794. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  31795. var i, sourceLength = data.length;
  31796. var buffer = this.buffer, bufferLength = this.bufferPosition;
  31797. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  31798. buffer[bufferLength] = data[i];
  31799. }
  31800. if (bufferLength < 16) {
  31801. this.bufferLength = bufferLength;
  31802. return new Uint8Array([]);
  31803. }
  31804. this.iv = buffer;
  31805. this.buffer = new Uint8Array(16);
  31806. this.bufferLength = 0;
  31807. this.decryptBlock = decryptBlock2;
  31808. return this.decryptBlock(data.subarray(16), finalize);
  31809. },
  31810. encrypt: function AES128Cipher_encrypt(data, iv) {
  31811. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  31812. if (!iv) {
  31813. iv = new Uint8Array(16);
  31814. }
  31815. for (i = 0; i < sourceLength; ++i) {
  31816. buffer[bufferLength] = data[i];
  31817. ++bufferLength;
  31818. if (bufferLength < 16) {
  31819. continue;
  31820. }
  31821. for (j = 0; j < 16; ++j) {
  31822. buffer[j] ^= iv[j];
  31823. }
  31824. var cipher = encrypt128(buffer, this.key);
  31825. iv = cipher;
  31826. result.push(cipher);
  31827. buffer = new Uint8Array(16);
  31828. bufferLength = 0;
  31829. }
  31830. this.buffer = buffer;
  31831. this.bufferLength = bufferLength;
  31832. this.iv = iv;
  31833. if (result.length === 0) {
  31834. return new Uint8Array([]);
  31835. }
  31836. var outputLength = 16 * result.length;
  31837. var output = new Uint8Array(outputLength);
  31838. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  31839. output.set(result[i], j);
  31840. }
  31841. return output;
  31842. }
  31843. };
  31844. return AES128Cipher;
  31845. }();
  31846. var AES256Cipher = function AES256CipherClosure() {
  31847. var rcon = new Uint8Array([
  31848. 0x8d,
  31849. 0x01,
  31850. 0x02,
  31851. 0x04,
  31852. 0x08,
  31853. 0x10,
  31854. 0x20,
  31855. 0x40,
  31856. 0x80,
  31857. 0x1b,
  31858. 0x36,
  31859. 0x6c,
  31860. 0xd8,
  31861. 0xab,
  31862. 0x4d,
  31863. 0x9a,
  31864. 0x2f,
  31865. 0x5e,
  31866. 0xbc,
  31867. 0x63,
  31868. 0xc6,
  31869. 0x97,
  31870. 0x35,
  31871. 0x6a,
  31872. 0xd4,
  31873. 0xb3,
  31874. 0x7d,
  31875. 0xfa,
  31876. 0xef,
  31877. 0xc5,
  31878. 0x91,
  31879. 0x39,
  31880. 0x72,
  31881. 0xe4,
  31882. 0xd3,
  31883. 0xbd,
  31884. 0x61,
  31885. 0xc2,
  31886. 0x9f,
  31887. 0x25,
  31888. 0x4a,
  31889. 0x94,
  31890. 0x33,
  31891. 0x66,
  31892. 0xcc,
  31893. 0x83,
  31894. 0x1d,
  31895. 0x3a,
  31896. 0x74,
  31897. 0xe8,
  31898. 0xcb,
  31899. 0x8d,
  31900. 0x01,
  31901. 0x02,
  31902. 0x04,
  31903. 0x08,
  31904. 0x10,
  31905. 0x20,
  31906. 0x40,
  31907. 0x80,
  31908. 0x1b,
  31909. 0x36,
  31910. 0x6c,
  31911. 0xd8,
  31912. 0xab,
  31913. 0x4d,
  31914. 0x9a,
  31915. 0x2f,
  31916. 0x5e,
  31917. 0xbc,
  31918. 0x63,
  31919. 0xc6,
  31920. 0x97,
  31921. 0x35,
  31922. 0x6a,
  31923. 0xd4,
  31924. 0xb3,
  31925. 0x7d,
  31926. 0xfa,
  31927. 0xef,
  31928. 0xc5,
  31929. 0x91,
  31930. 0x39,
  31931. 0x72,
  31932. 0xe4,
  31933. 0xd3,
  31934. 0xbd,
  31935. 0x61,
  31936. 0xc2,
  31937. 0x9f,
  31938. 0x25,
  31939. 0x4a,
  31940. 0x94,
  31941. 0x33,
  31942. 0x66,
  31943. 0xcc,
  31944. 0x83,
  31945. 0x1d,
  31946. 0x3a,
  31947. 0x74,
  31948. 0xe8,
  31949. 0xcb,
  31950. 0x8d,
  31951. 0x01,
  31952. 0x02,
  31953. 0x04,
  31954. 0x08,
  31955. 0x10,
  31956. 0x20,
  31957. 0x40,
  31958. 0x80,
  31959. 0x1b,
  31960. 0x36,
  31961. 0x6c,
  31962. 0xd8,
  31963. 0xab,
  31964. 0x4d,
  31965. 0x9a,
  31966. 0x2f,
  31967. 0x5e,
  31968. 0xbc,
  31969. 0x63,
  31970. 0xc6,
  31971. 0x97,
  31972. 0x35,
  31973. 0x6a,
  31974. 0xd4,
  31975. 0xb3,
  31976. 0x7d,
  31977. 0xfa,
  31978. 0xef,
  31979. 0xc5,
  31980. 0x91,
  31981. 0x39,
  31982. 0x72,
  31983. 0xe4,
  31984. 0xd3,
  31985. 0xbd,
  31986. 0x61,
  31987. 0xc2,
  31988. 0x9f,
  31989. 0x25,
  31990. 0x4a,
  31991. 0x94,
  31992. 0x33,
  31993. 0x66,
  31994. 0xcc,
  31995. 0x83,
  31996. 0x1d,
  31997. 0x3a,
  31998. 0x74,
  31999. 0xe8,
  32000. 0xcb,
  32001. 0x8d,
  32002. 0x01,
  32003. 0x02,
  32004. 0x04,
  32005. 0x08,
  32006. 0x10,
  32007. 0x20,
  32008. 0x40,
  32009. 0x80,
  32010. 0x1b,
  32011. 0x36,
  32012. 0x6c,
  32013. 0xd8,
  32014. 0xab,
  32015. 0x4d,
  32016. 0x9a,
  32017. 0x2f,
  32018. 0x5e,
  32019. 0xbc,
  32020. 0x63,
  32021. 0xc6,
  32022. 0x97,
  32023. 0x35,
  32024. 0x6a,
  32025. 0xd4,
  32026. 0xb3,
  32027. 0x7d,
  32028. 0xfa,
  32029. 0xef,
  32030. 0xc5,
  32031. 0x91,
  32032. 0x39,
  32033. 0x72,
  32034. 0xe4,
  32035. 0xd3,
  32036. 0xbd,
  32037. 0x61,
  32038. 0xc2,
  32039. 0x9f,
  32040. 0x25,
  32041. 0x4a,
  32042. 0x94,
  32043. 0x33,
  32044. 0x66,
  32045. 0xcc,
  32046. 0x83,
  32047. 0x1d,
  32048. 0x3a,
  32049. 0x74,
  32050. 0xe8,
  32051. 0xcb,
  32052. 0x8d,
  32053. 0x01,
  32054. 0x02,
  32055. 0x04,
  32056. 0x08,
  32057. 0x10,
  32058. 0x20,
  32059. 0x40,
  32060. 0x80,
  32061. 0x1b,
  32062. 0x36,
  32063. 0x6c,
  32064. 0xd8,
  32065. 0xab,
  32066. 0x4d,
  32067. 0x9a,
  32068. 0x2f,
  32069. 0x5e,
  32070. 0xbc,
  32071. 0x63,
  32072. 0xc6,
  32073. 0x97,
  32074. 0x35,
  32075. 0x6a,
  32076. 0xd4,
  32077. 0xb3,
  32078. 0x7d,
  32079. 0xfa,
  32080. 0xef,
  32081. 0xc5,
  32082. 0x91,
  32083. 0x39,
  32084. 0x72,
  32085. 0xe4,
  32086. 0xd3,
  32087. 0xbd,
  32088. 0x61,
  32089. 0xc2,
  32090. 0x9f,
  32091. 0x25,
  32092. 0x4a,
  32093. 0x94,
  32094. 0x33,
  32095. 0x66,
  32096. 0xcc,
  32097. 0x83,
  32098. 0x1d,
  32099. 0x3a,
  32100. 0x74,
  32101. 0xe8,
  32102. 0xcb,
  32103. 0x8d
  32104. ]);
  32105. var s = new Uint8Array([
  32106. 0x63,
  32107. 0x7c,
  32108. 0x77,
  32109. 0x7b,
  32110. 0xf2,
  32111. 0x6b,
  32112. 0x6f,
  32113. 0xc5,
  32114. 0x30,
  32115. 0x01,
  32116. 0x67,
  32117. 0x2b,
  32118. 0xfe,
  32119. 0xd7,
  32120. 0xab,
  32121. 0x76,
  32122. 0xca,
  32123. 0x82,
  32124. 0xc9,
  32125. 0x7d,
  32126. 0xfa,
  32127. 0x59,
  32128. 0x47,
  32129. 0xf0,
  32130. 0xad,
  32131. 0xd4,
  32132. 0xa2,
  32133. 0xaf,
  32134. 0x9c,
  32135. 0xa4,
  32136. 0x72,
  32137. 0xc0,
  32138. 0xb7,
  32139. 0xfd,
  32140. 0x93,
  32141. 0x26,
  32142. 0x36,
  32143. 0x3f,
  32144. 0xf7,
  32145. 0xcc,
  32146. 0x34,
  32147. 0xa5,
  32148. 0xe5,
  32149. 0xf1,
  32150. 0x71,
  32151. 0xd8,
  32152. 0x31,
  32153. 0x15,
  32154. 0x04,
  32155. 0xc7,
  32156. 0x23,
  32157. 0xc3,
  32158. 0x18,
  32159. 0x96,
  32160. 0x05,
  32161. 0x9a,
  32162. 0x07,
  32163. 0x12,
  32164. 0x80,
  32165. 0xe2,
  32166. 0xeb,
  32167. 0x27,
  32168. 0xb2,
  32169. 0x75,
  32170. 0x09,
  32171. 0x83,
  32172. 0x2c,
  32173. 0x1a,
  32174. 0x1b,
  32175. 0x6e,
  32176. 0x5a,
  32177. 0xa0,
  32178. 0x52,
  32179. 0x3b,
  32180. 0xd6,
  32181. 0xb3,
  32182. 0x29,
  32183. 0xe3,
  32184. 0x2f,
  32185. 0x84,
  32186. 0x53,
  32187. 0xd1,
  32188. 0x00,
  32189. 0xed,
  32190. 0x20,
  32191. 0xfc,
  32192. 0xb1,
  32193. 0x5b,
  32194. 0x6a,
  32195. 0xcb,
  32196. 0xbe,
  32197. 0x39,
  32198. 0x4a,
  32199. 0x4c,
  32200. 0x58,
  32201. 0xcf,
  32202. 0xd0,
  32203. 0xef,
  32204. 0xaa,
  32205. 0xfb,
  32206. 0x43,
  32207. 0x4d,
  32208. 0x33,
  32209. 0x85,
  32210. 0x45,
  32211. 0xf9,
  32212. 0x02,
  32213. 0x7f,
  32214. 0x50,
  32215. 0x3c,
  32216. 0x9f,
  32217. 0xa8,
  32218. 0x51,
  32219. 0xa3,
  32220. 0x40,
  32221. 0x8f,
  32222. 0x92,
  32223. 0x9d,
  32224. 0x38,
  32225. 0xf5,
  32226. 0xbc,
  32227. 0xb6,
  32228. 0xda,
  32229. 0x21,
  32230. 0x10,
  32231. 0xff,
  32232. 0xf3,
  32233. 0xd2,
  32234. 0xcd,
  32235. 0x0c,
  32236. 0x13,
  32237. 0xec,
  32238. 0x5f,
  32239. 0x97,
  32240. 0x44,
  32241. 0x17,
  32242. 0xc4,
  32243. 0xa7,
  32244. 0x7e,
  32245. 0x3d,
  32246. 0x64,
  32247. 0x5d,
  32248. 0x19,
  32249. 0x73,
  32250. 0x60,
  32251. 0x81,
  32252. 0x4f,
  32253. 0xdc,
  32254. 0x22,
  32255. 0x2a,
  32256. 0x90,
  32257. 0x88,
  32258. 0x46,
  32259. 0xee,
  32260. 0xb8,
  32261. 0x14,
  32262. 0xde,
  32263. 0x5e,
  32264. 0x0b,
  32265. 0xdb,
  32266. 0xe0,
  32267. 0x32,
  32268. 0x3a,
  32269. 0x0a,
  32270. 0x49,
  32271. 0x06,
  32272. 0x24,
  32273. 0x5c,
  32274. 0xc2,
  32275. 0xd3,
  32276. 0xac,
  32277. 0x62,
  32278. 0x91,
  32279. 0x95,
  32280. 0xe4,
  32281. 0x79,
  32282. 0xe7,
  32283. 0xc8,
  32284. 0x37,
  32285. 0x6d,
  32286. 0x8d,
  32287. 0xd5,
  32288. 0x4e,
  32289. 0xa9,
  32290. 0x6c,
  32291. 0x56,
  32292. 0xf4,
  32293. 0xea,
  32294. 0x65,
  32295. 0x7a,
  32296. 0xae,
  32297. 0x08,
  32298. 0xba,
  32299. 0x78,
  32300. 0x25,
  32301. 0x2e,
  32302. 0x1c,
  32303. 0xa6,
  32304. 0xb4,
  32305. 0xc6,
  32306. 0xe8,
  32307. 0xdd,
  32308. 0x74,
  32309. 0x1f,
  32310. 0x4b,
  32311. 0xbd,
  32312. 0x8b,
  32313. 0x8a,
  32314. 0x70,
  32315. 0x3e,
  32316. 0xb5,
  32317. 0x66,
  32318. 0x48,
  32319. 0x03,
  32320. 0xf6,
  32321. 0x0e,
  32322. 0x61,
  32323. 0x35,
  32324. 0x57,
  32325. 0xb9,
  32326. 0x86,
  32327. 0xc1,
  32328. 0x1d,
  32329. 0x9e,
  32330. 0xe1,
  32331. 0xf8,
  32332. 0x98,
  32333. 0x11,
  32334. 0x69,
  32335. 0xd9,
  32336. 0x8e,
  32337. 0x94,
  32338. 0x9b,
  32339. 0x1e,
  32340. 0x87,
  32341. 0xe9,
  32342. 0xce,
  32343. 0x55,
  32344. 0x28,
  32345. 0xdf,
  32346. 0x8c,
  32347. 0xa1,
  32348. 0x89,
  32349. 0x0d,
  32350. 0xbf,
  32351. 0xe6,
  32352. 0x42,
  32353. 0x68,
  32354. 0x41,
  32355. 0x99,
  32356. 0x2d,
  32357. 0x0f,
  32358. 0xb0,
  32359. 0x54,
  32360. 0xbb,
  32361. 0x16
  32362. ]);
  32363. var inv_s = new Uint8Array([
  32364. 0x52,
  32365. 0x09,
  32366. 0x6a,
  32367. 0xd5,
  32368. 0x30,
  32369. 0x36,
  32370. 0xa5,
  32371. 0x38,
  32372. 0xbf,
  32373. 0x40,
  32374. 0xa3,
  32375. 0x9e,
  32376. 0x81,
  32377. 0xf3,
  32378. 0xd7,
  32379. 0xfb,
  32380. 0x7c,
  32381. 0xe3,
  32382. 0x39,
  32383. 0x82,
  32384. 0x9b,
  32385. 0x2f,
  32386. 0xff,
  32387. 0x87,
  32388. 0x34,
  32389. 0x8e,
  32390. 0x43,
  32391. 0x44,
  32392. 0xc4,
  32393. 0xde,
  32394. 0xe9,
  32395. 0xcb,
  32396. 0x54,
  32397. 0x7b,
  32398. 0x94,
  32399. 0x32,
  32400. 0xa6,
  32401. 0xc2,
  32402. 0x23,
  32403. 0x3d,
  32404. 0xee,
  32405. 0x4c,
  32406. 0x95,
  32407. 0x0b,
  32408. 0x42,
  32409. 0xfa,
  32410. 0xc3,
  32411. 0x4e,
  32412. 0x08,
  32413. 0x2e,
  32414. 0xa1,
  32415. 0x66,
  32416. 0x28,
  32417. 0xd9,
  32418. 0x24,
  32419. 0xb2,
  32420. 0x76,
  32421. 0x5b,
  32422. 0xa2,
  32423. 0x49,
  32424. 0x6d,
  32425. 0x8b,
  32426. 0xd1,
  32427. 0x25,
  32428. 0x72,
  32429. 0xf8,
  32430. 0xf6,
  32431. 0x64,
  32432. 0x86,
  32433. 0x68,
  32434. 0x98,
  32435. 0x16,
  32436. 0xd4,
  32437. 0xa4,
  32438. 0x5c,
  32439. 0xcc,
  32440. 0x5d,
  32441. 0x65,
  32442. 0xb6,
  32443. 0x92,
  32444. 0x6c,
  32445. 0x70,
  32446. 0x48,
  32447. 0x50,
  32448. 0xfd,
  32449. 0xed,
  32450. 0xb9,
  32451. 0xda,
  32452. 0x5e,
  32453. 0x15,
  32454. 0x46,
  32455. 0x57,
  32456. 0xa7,
  32457. 0x8d,
  32458. 0x9d,
  32459. 0x84,
  32460. 0x90,
  32461. 0xd8,
  32462. 0xab,
  32463. 0x00,
  32464. 0x8c,
  32465. 0xbc,
  32466. 0xd3,
  32467. 0x0a,
  32468. 0xf7,
  32469. 0xe4,
  32470. 0x58,
  32471. 0x05,
  32472. 0xb8,
  32473. 0xb3,
  32474. 0x45,
  32475. 0x06,
  32476. 0xd0,
  32477. 0x2c,
  32478. 0x1e,
  32479. 0x8f,
  32480. 0xca,
  32481. 0x3f,
  32482. 0x0f,
  32483. 0x02,
  32484. 0xc1,
  32485. 0xaf,
  32486. 0xbd,
  32487. 0x03,
  32488. 0x01,
  32489. 0x13,
  32490. 0x8a,
  32491. 0x6b,
  32492. 0x3a,
  32493. 0x91,
  32494. 0x11,
  32495. 0x41,
  32496. 0x4f,
  32497. 0x67,
  32498. 0xdc,
  32499. 0xea,
  32500. 0x97,
  32501. 0xf2,
  32502. 0xcf,
  32503. 0xce,
  32504. 0xf0,
  32505. 0xb4,
  32506. 0xe6,
  32507. 0x73,
  32508. 0x96,
  32509. 0xac,
  32510. 0x74,
  32511. 0x22,
  32512. 0xe7,
  32513. 0xad,
  32514. 0x35,
  32515. 0x85,
  32516. 0xe2,
  32517. 0xf9,
  32518. 0x37,
  32519. 0xe8,
  32520. 0x1c,
  32521. 0x75,
  32522. 0xdf,
  32523. 0x6e,
  32524. 0x47,
  32525. 0xf1,
  32526. 0x1a,
  32527. 0x71,
  32528. 0x1d,
  32529. 0x29,
  32530. 0xc5,
  32531. 0x89,
  32532. 0x6f,
  32533. 0xb7,
  32534. 0x62,
  32535. 0x0e,
  32536. 0xaa,
  32537. 0x18,
  32538. 0xbe,
  32539. 0x1b,
  32540. 0xfc,
  32541. 0x56,
  32542. 0x3e,
  32543. 0x4b,
  32544. 0xc6,
  32545. 0xd2,
  32546. 0x79,
  32547. 0x20,
  32548. 0x9a,
  32549. 0xdb,
  32550. 0xc0,
  32551. 0xfe,
  32552. 0x78,
  32553. 0xcd,
  32554. 0x5a,
  32555. 0xf4,
  32556. 0x1f,
  32557. 0xdd,
  32558. 0xa8,
  32559. 0x33,
  32560. 0x88,
  32561. 0x07,
  32562. 0xc7,
  32563. 0x31,
  32564. 0xb1,
  32565. 0x12,
  32566. 0x10,
  32567. 0x59,
  32568. 0x27,
  32569. 0x80,
  32570. 0xec,
  32571. 0x5f,
  32572. 0x60,
  32573. 0x51,
  32574. 0x7f,
  32575. 0xa9,
  32576. 0x19,
  32577. 0xb5,
  32578. 0x4a,
  32579. 0x0d,
  32580. 0x2d,
  32581. 0xe5,
  32582. 0x7a,
  32583. 0x9f,
  32584. 0x93,
  32585. 0xc9,
  32586. 0x9c,
  32587. 0xef,
  32588. 0xa0,
  32589. 0xe0,
  32590. 0x3b,
  32591. 0x4d,
  32592. 0xae,
  32593. 0x2a,
  32594. 0xf5,
  32595. 0xb0,
  32596. 0xc8,
  32597. 0xeb,
  32598. 0xbb,
  32599. 0x3c,
  32600. 0x83,
  32601. 0x53,
  32602. 0x99,
  32603. 0x61,
  32604. 0x17,
  32605. 0x2b,
  32606. 0x04,
  32607. 0x7e,
  32608. 0xba,
  32609. 0x77,
  32610. 0xd6,
  32611. 0x26,
  32612. 0xe1,
  32613. 0x69,
  32614. 0x14,
  32615. 0x63,
  32616. 0x55,
  32617. 0x21,
  32618. 0x0c,
  32619. 0x7d
  32620. ]);
  32621. var mixCol = new Uint8Array(256);
  32622. for (var i = 0; i < 256; i++) {
  32623. if (i < 128) {
  32624. mixCol[i] = i << 1;
  32625. } else {
  32626. mixCol[i] = i << 1 ^ 0x1b;
  32627. }
  32628. }
  32629. var mix = new Uint32Array([
  32630. 0x00000000,
  32631. 0x0e090d0b,
  32632. 0x1c121a16,
  32633. 0x121b171d,
  32634. 0x3824342c,
  32635. 0x362d3927,
  32636. 0x24362e3a,
  32637. 0x2a3f2331,
  32638. 0x70486858,
  32639. 0x7e416553,
  32640. 0x6c5a724e,
  32641. 0x62537f45,
  32642. 0x486c5c74,
  32643. 0x4665517f,
  32644. 0x547e4662,
  32645. 0x5a774b69,
  32646. 0xe090d0b0,
  32647. 0xee99ddbb,
  32648. 0xfc82caa6,
  32649. 0xf28bc7ad,
  32650. 0xd8b4e49c,
  32651. 0xd6bde997,
  32652. 0xc4a6fe8a,
  32653. 0xcaaff381,
  32654. 0x90d8b8e8,
  32655. 0x9ed1b5e3,
  32656. 0x8ccaa2fe,
  32657. 0x82c3aff5,
  32658. 0xa8fc8cc4,
  32659. 0xa6f581cf,
  32660. 0xb4ee96d2,
  32661. 0xbae79bd9,
  32662. 0xdb3bbb7b,
  32663. 0xd532b670,
  32664. 0xc729a16d,
  32665. 0xc920ac66,
  32666. 0xe31f8f57,
  32667. 0xed16825c,
  32668. 0xff0d9541,
  32669. 0xf104984a,
  32670. 0xab73d323,
  32671. 0xa57ade28,
  32672. 0xb761c935,
  32673. 0xb968c43e,
  32674. 0x9357e70f,
  32675. 0x9d5eea04,
  32676. 0x8f45fd19,
  32677. 0x814cf012,
  32678. 0x3bab6bcb,
  32679. 0x35a266c0,
  32680. 0x27b971dd,
  32681. 0x29b07cd6,
  32682. 0x038f5fe7,
  32683. 0x0d8652ec,
  32684. 0x1f9d45f1,
  32685. 0x119448fa,
  32686. 0x4be30393,
  32687. 0x45ea0e98,
  32688. 0x57f11985,
  32689. 0x59f8148e,
  32690. 0x73c737bf,
  32691. 0x7dce3ab4,
  32692. 0x6fd52da9,
  32693. 0x61dc20a2,
  32694. 0xad766df6,
  32695. 0xa37f60fd,
  32696. 0xb16477e0,
  32697. 0xbf6d7aeb,
  32698. 0x955259da,
  32699. 0x9b5b54d1,
  32700. 0x894043cc,
  32701. 0x87494ec7,
  32702. 0xdd3e05ae,
  32703. 0xd33708a5,
  32704. 0xc12c1fb8,
  32705. 0xcf2512b3,
  32706. 0xe51a3182,
  32707. 0xeb133c89,
  32708. 0xf9082b94,
  32709. 0xf701269f,
  32710. 0x4de6bd46,
  32711. 0x43efb04d,
  32712. 0x51f4a750,
  32713. 0x5ffdaa5b,
  32714. 0x75c2896a,
  32715. 0x7bcb8461,
  32716. 0x69d0937c,
  32717. 0x67d99e77,
  32718. 0x3daed51e,
  32719. 0x33a7d815,
  32720. 0x21bccf08,
  32721. 0x2fb5c203,
  32722. 0x058ae132,
  32723. 0x0b83ec39,
  32724. 0x1998fb24,
  32725. 0x1791f62f,
  32726. 0x764dd68d,
  32727. 0x7844db86,
  32728. 0x6a5fcc9b,
  32729. 0x6456c190,
  32730. 0x4e69e2a1,
  32731. 0x4060efaa,
  32732. 0x527bf8b7,
  32733. 0x5c72f5bc,
  32734. 0x0605bed5,
  32735. 0x080cb3de,
  32736. 0x1a17a4c3,
  32737. 0x141ea9c8,
  32738. 0x3e218af9,
  32739. 0x302887f2,
  32740. 0x223390ef,
  32741. 0x2c3a9de4,
  32742. 0x96dd063d,
  32743. 0x98d40b36,
  32744. 0x8acf1c2b,
  32745. 0x84c61120,
  32746. 0xaef93211,
  32747. 0xa0f03f1a,
  32748. 0xb2eb2807,
  32749. 0xbce2250c,
  32750. 0xe6956e65,
  32751. 0xe89c636e,
  32752. 0xfa877473,
  32753. 0xf48e7978,
  32754. 0xdeb15a49,
  32755. 0xd0b85742,
  32756. 0xc2a3405f,
  32757. 0xccaa4d54,
  32758. 0x41ecdaf7,
  32759. 0x4fe5d7fc,
  32760. 0x5dfec0e1,
  32761. 0x53f7cdea,
  32762. 0x79c8eedb,
  32763. 0x77c1e3d0,
  32764. 0x65daf4cd,
  32765. 0x6bd3f9c6,
  32766. 0x31a4b2af,
  32767. 0x3fadbfa4,
  32768. 0x2db6a8b9,
  32769. 0x23bfa5b2,
  32770. 0x09808683,
  32771. 0x07898b88,
  32772. 0x15929c95,
  32773. 0x1b9b919e,
  32774. 0xa17c0a47,
  32775. 0xaf75074c,
  32776. 0xbd6e1051,
  32777. 0xb3671d5a,
  32778. 0x99583e6b,
  32779. 0x97513360,
  32780. 0x854a247d,
  32781. 0x8b432976,
  32782. 0xd134621f,
  32783. 0xdf3d6f14,
  32784. 0xcd267809,
  32785. 0xc32f7502,
  32786. 0xe9105633,
  32787. 0xe7195b38,
  32788. 0xf5024c25,
  32789. 0xfb0b412e,
  32790. 0x9ad7618c,
  32791. 0x94de6c87,
  32792. 0x86c57b9a,
  32793. 0x88cc7691,
  32794. 0xa2f355a0,
  32795. 0xacfa58ab,
  32796. 0xbee14fb6,
  32797. 0xb0e842bd,
  32798. 0xea9f09d4,
  32799. 0xe49604df,
  32800. 0xf68d13c2,
  32801. 0xf8841ec9,
  32802. 0xd2bb3df8,
  32803. 0xdcb230f3,
  32804. 0xcea927ee,
  32805. 0xc0a02ae5,
  32806. 0x7a47b13c,
  32807. 0x744ebc37,
  32808. 0x6655ab2a,
  32809. 0x685ca621,
  32810. 0x42638510,
  32811. 0x4c6a881b,
  32812. 0x5e719f06,
  32813. 0x5078920d,
  32814. 0x0a0fd964,
  32815. 0x0406d46f,
  32816. 0x161dc372,
  32817. 0x1814ce79,
  32818. 0x322bed48,
  32819. 0x3c22e043,
  32820. 0x2e39f75e,
  32821. 0x2030fa55,
  32822. 0xec9ab701,
  32823. 0xe293ba0a,
  32824. 0xf088ad17,
  32825. 0xfe81a01c,
  32826. 0xd4be832d,
  32827. 0xdab78e26,
  32828. 0xc8ac993b,
  32829. 0xc6a59430,
  32830. 0x9cd2df59,
  32831. 0x92dbd252,
  32832. 0x80c0c54f,
  32833. 0x8ec9c844,
  32834. 0xa4f6eb75,
  32835. 0xaaffe67e,
  32836. 0xb8e4f163,
  32837. 0xb6edfc68,
  32838. 0x0c0a67b1,
  32839. 0x02036aba,
  32840. 0x10187da7,
  32841. 0x1e1170ac,
  32842. 0x342e539d,
  32843. 0x3a275e96,
  32844. 0x283c498b,
  32845. 0x26354480,
  32846. 0x7c420fe9,
  32847. 0x724b02e2,
  32848. 0x605015ff,
  32849. 0x6e5918f4,
  32850. 0x44663bc5,
  32851. 0x4a6f36ce,
  32852. 0x587421d3,
  32853. 0x567d2cd8,
  32854. 0x37a10c7a,
  32855. 0x39a80171,
  32856. 0x2bb3166c,
  32857. 0x25ba1b67,
  32858. 0x0f853856,
  32859. 0x018c355d,
  32860. 0x13972240,
  32861. 0x1d9e2f4b,
  32862. 0x47e96422,
  32863. 0x49e06929,
  32864. 0x5bfb7e34,
  32865. 0x55f2733f,
  32866. 0x7fcd500e,
  32867. 0x71c45d05,
  32868. 0x63df4a18,
  32869. 0x6dd64713,
  32870. 0xd731dcca,
  32871. 0xd938d1c1,
  32872. 0xcb23c6dc,
  32873. 0xc52acbd7,
  32874. 0xef15e8e6,
  32875. 0xe11ce5ed,
  32876. 0xf307f2f0,
  32877. 0xfd0efffb,
  32878. 0xa779b492,
  32879. 0xa970b999,
  32880. 0xbb6bae84,
  32881. 0xb562a38f,
  32882. 0x9f5d80be,
  32883. 0x91548db5,
  32884. 0x834f9aa8,
  32885. 0x8d4697a3
  32886. ]);
  32887. function expandKey256(cipherKey) {
  32888. var b = 240, result = new Uint8Array(b);
  32889. var r = 1;
  32890. result.set(cipherKey);
  32891. for (var j = 32, i = 1; j < b; ++i) {
  32892. if (j % 32 === 16) {
  32893. t1 = s[t1];
  32894. t2 = s[t2];
  32895. t3 = s[t3];
  32896. t4 = s[t4];
  32897. } else if (j % 32 === 0) {
  32898. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  32899. t1 = s[t1];
  32900. t2 = s[t2];
  32901. t3 = s[t3];
  32902. t4 = s[t4];
  32903. t1 = t1 ^ r;
  32904. if ((r <<= 1) >= 256) {
  32905. r = (r ^ 0x1b) & 0xFF;
  32906. }
  32907. }
  32908. for (var n = 0; n < 4; ++n) {
  32909. result[j] = t1 ^= result[j - 32];
  32910. j++;
  32911. result[j] = t2 ^= result[j - 32];
  32912. j++;
  32913. result[j] = t3 ^= result[j - 32];
  32914. j++;
  32915. result[j] = t4 ^= result[j - 32];
  32916. j++;
  32917. }
  32918. }
  32919. return result;
  32920. }
  32921. function decrypt256(input, key) {
  32922. var state = new Uint8Array(16);
  32923. state.set(input);
  32924. var i, j, k;
  32925. var t, u, v;
  32926. for (j = 0, k = 224; j < 16; ++j, ++k) {
  32927. state[j] ^= key[k];
  32928. }
  32929. for (i = 13; i >= 1; --i) {
  32930. t = state[13];
  32931. state[13] = state[9];
  32932. state[9] = state[5];
  32933. state[5] = state[1];
  32934. state[1] = t;
  32935. t = state[14];
  32936. u = state[10];
  32937. state[14] = state[6];
  32938. state[10] = state[2];
  32939. state[6] = t;
  32940. state[2] = u;
  32941. t = state[15];
  32942. u = state[11];
  32943. v = state[7];
  32944. state[15] = state[3];
  32945. state[11] = t;
  32946. state[7] = u;
  32947. state[3] = v;
  32948. for (j = 0; j < 16; ++j) {
  32949. state[j] = inv_s[state[j]];
  32950. }
  32951. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  32952. state[j] ^= key[k];
  32953. }
  32954. for (j = 0; j < 16; j += 4) {
  32955. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  32956. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  32957. state[j] = t >>> 24 & 0xFF;
  32958. state[j + 1] = t >> 16 & 0xFF;
  32959. state[j + 2] = t >> 8 & 0xFF;
  32960. state[j + 3] = t & 0xFF;
  32961. }
  32962. }
  32963. t = state[13];
  32964. state[13] = state[9];
  32965. state[9] = state[5];
  32966. state[5] = state[1];
  32967. state[1] = t;
  32968. t = state[14];
  32969. u = state[10];
  32970. state[14] = state[6];
  32971. state[10] = state[2];
  32972. state[6] = t;
  32973. state[2] = u;
  32974. t = state[15];
  32975. u = state[11];
  32976. v = state[7];
  32977. state[15] = state[3];
  32978. state[11] = t;
  32979. state[7] = u;
  32980. state[3] = v;
  32981. for (j = 0; j < 16; ++j) {
  32982. state[j] = inv_s[state[j]];
  32983. state[j] ^= key[j];
  32984. }
  32985. return state;
  32986. }
  32987. function encrypt256(input, key) {
  32988. var t, u, v, k;
  32989. var state = new Uint8Array(16);
  32990. state.set(input);
  32991. for (j = 0; j < 16; ++j) {
  32992. state[j] ^= key[j];
  32993. }
  32994. for (i = 1; i < 14; i++) {
  32995. for (j = 0; j < 16; ++j) {
  32996. state[j] = s[state[j]];
  32997. }
  32998. v = state[1];
  32999. state[1] = state[5];
  33000. state[5] = state[9];
  33001. state[9] = state[13];
  33002. state[13] = v;
  33003. v = state[2];
  33004. u = state[6];
  33005. state[2] = state[10];
  33006. state[6] = state[14];
  33007. state[10] = v;
  33008. state[14] = u;
  33009. v = state[3];
  33010. u = state[7];
  33011. t = state[11];
  33012. state[3] = state[15];
  33013. state[7] = v;
  33014. state[11] = u;
  33015. state[15] = t;
  33016. for (var j = 0; j < 16; j += 4) {
  33017. var s0 = state[j + 0], s1 = state[j + 1];
  33018. var s2 = state[j + 2], s3 = state[j + 3];
  33019. t = s0 ^ s1 ^ s2 ^ s3;
  33020. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  33021. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  33022. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  33023. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  33024. }
  33025. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  33026. state[j] ^= key[k];
  33027. }
  33028. }
  33029. for (j = 0; j < 16; ++j) {
  33030. state[j] = s[state[j]];
  33031. }
  33032. v = state[1];
  33033. state[1] = state[5];
  33034. state[5] = state[9];
  33035. state[9] = state[13];
  33036. state[13] = v;
  33037. v = state[2];
  33038. u = state[6];
  33039. state[2] = state[10];
  33040. state[6] = state[14];
  33041. state[10] = v;
  33042. state[14] = u;
  33043. v = state[3];
  33044. u = state[7];
  33045. t = state[11];
  33046. state[3] = state[15];
  33047. state[7] = v;
  33048. state[11] = u;
  33049. state[15] = t;
  33050. for (j = 0, k = 224; j < 16; ++j, ++k) {
  33051. state[j] ^= key[k];
  33052. }
  33053. return state;
  33054. }
  33055. function AES256Cipher(key) {
  33056. this.key = expandKey256(key);
  33057. this.buffer = new Uint8Array(16);
  33058. this.bufferPosition = 0;
  33059. }
  33060. function decryptBlock2(data, finalize) {
  33061. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  33062. for (i = 0; i < sourceLength; ++i) {
  33063. buffer[bufferLength] = data[i];
  33064. ++bufferLength;
  33065. if (bufferLength < 16) {
  33066. continue;
  33067. }
  33068. var plain = decrypt256(buffer, this.key);
  33069. for (j = 0; j < 16; ++j) {
  33070. plain[j] ^= iv[j];
  33071. }
  33072. iv = buffer;
  33073. result.push(plain);
  33074. buffer = new Uint8Array(16);
  33075. bufferLength = 0;
  33076. }
  33077. this.buffer = buffer;
  33078. this.bufferLength = bufferLength;
  33079. this.iv = iv;
  33080. if (result.length === 0) {
  33081. return new Uint8Array([]);
  33082. }
  33083. var outputLength = 16 * result.length;
  33084. if (finalize) {
  33085. var lastBlock = result[result.length - 1];
  33086. var psLen = lastBlock[15];
  33087. if (psLen <= 16) {
  33088. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  33089. if (lastBlock[i] !== psLen) {
  33090. psLen = 0;
  33091. break;
  33092. }
  33093. }
  33094. outputLength -= psLen;
  33095. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  33096. }
  33097. }
  33098. var output = new Uint8Array(outputLength);
  33099. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  33100. output.set(result[i], j);
  33101. }
  33102. return output;
  33103. }
  33104. AES256Cipher.prototype = {
  33105. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  33106. var i, sourceLength = data.length;
  33107. var buffer = this.buffer, bufferLength = this.bufferPosition;
  33108. if (iv) {
  33109. this.iv = iv;
  33110. } else {
  33111. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  33112. buffer[bufferLength] = data[i];
  33113. }
  33114. if (bufferLength < 16) {
  33115. this.bufferLength = bufferLength;
  33116. return new Uint8Array([]);
  33117. }
  33118. this.iv = buffer;
  33119. data = data.subarray(16);
  33120. }
  33121. this.buffer = new Uint8Array(16);
  33122. this.bufferLength = 0;
  33123. this.decryptBlock = decryptBlock2;
  33124. return this.decryptBlock(data, finalize);
  33125. },
  33126. encrypt: function AES256Cipher_encrypt(data, iv) {
  33127. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  33128. if (!iv) {
  33129. iv = new Uint8Array(16);
  33130. }
  33131. for (i = 0; i < sourceLength; ++i) {
  33132. buffer[bufferLength] = data[i];
  33133. ++bufferLength;
  33134. if (bufferLength < 16) {
  33135. continue;
  33136. }
  33137. for (j = 0; j < 16; ++j) {
  33138. buffer[j] ^= iv[j];
  33139. }
  33140. var cipher = encrypt256(buffer, this.key);
  33141. this.iv = cipher;
  33142. result.push(cipher);
  33143. buffer = new Uint8Array(16);
  33144. bufferLength = 0;
  33145. }
  33146. this.buffer = buffer;
  33147. this.bufferLength = bufferLength;
  33148. this.iv = iv;
  33149. if (result.length === 0) {
  33150. return new Uint8Array([]);
  33151. }
  33152. var outputLength = 16 * result.length;
  33153. var output = new Uint8Array(outputLength);
  33154. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  33155. output.set(result[i], j);
  33156. }
  33157. return output;
  33158. }
  33159. };
  33160. return AES256Cipher;
  33161. }();
  33162. var PDF17 = function PDF17Closure() {
  33163. function compareByteArrays(array1, array2) {
  33164. if (array1.length !== array2.length) {
  33165. return false;
  33166. }
  33167. for (var i = 0; i < array1.length; i++) {
  33168. if (array1[i] !== array2[i]) {
  33169. return false;
  33170. }
  33171. }
  33172. return true;
  33173. }
  33174. function PDF17() {
  33175. }
  33176. PDF17.prototype = {
  33177. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  33178. var hashData = new Uint8Array(password.length + 56);
  33179. hashData.set(password, 0);
  33180. hashData.set(ownerValidationSalt, password.length);
  33181. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  33182. var result = calculateSHA256(hashData, 0, hashData.length);
  33183. return compareByteArrays(result, ownerPassword);
  33184. },
  33185. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  33186. var hashData = new Uint8Array(password.length + 8);
  33187. hashData.set(password, 0);
  33188. hashData.set(userValidationSalt, password.length);
  33189. var result = calculateSHA256(hashData, 0, hashData.length);
  33190. return compareByteArrays(result, userPassword);
  33191. },
  33192. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  33193. var hashData = new Uint8Array(password.length + 56);
  33194. hashData.set(password, 0);
  33195. hashData.set(ownerKeySalt, password.length);
  33196. hashData.set(userBytes, password.length + ownerKeySalt.length);
  33197. var key = calculateSHA256(hashData, 0, hashData.length);
  33198. var cipher = new AES256Cipher(key);
  33199. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  33200. },
  33201. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  33202. var hashData = new Uint8Array(password.length + 8);
  33203. hashData.set(password, 0);
  33204. hashData.set(userKeySalt, password.length);
  33205. var key = calculateSHA256(hashData, 0, hashData.length);
  33206. var cipher = new AES256Cipher(key);
  33207. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  33208. }
  33209. };
  33210. return PDF17;
  33211. }();
  33212. var PDF20 = function PDF20Closure() {
  33213. function concatArrays(array1, array2) {
  33214. var t = new Uint8Array(array1.length + array2.length);
  33215. t.set(array1, 0);
  33216. t.set(array2, array1.length);
  33217. return t;
  33218. }
  33219. function calculatePDF20Hash(password, input, userBytes) {
  33220. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  33221. var e = [0];
  33222. var i = 0;
  33223. while (i < 64 || e[e.length - 1] > i - 32) {
  33224. var arrayLength = password.length + k.length + userBytes.length;
  33225. var k1 = new Uint8Array(arrayLength * 64);
  33226. var array = concatArrays(password, k);
  33227. array = concatArrays(array, userBytes);
  33228. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  33229. k1.set(array, pos);
  33230. }
  33231. var cipher = new AES128Cipher(k.subarray(0, 16));
  33232. e = cipher.encrypt(k1, k.subarray(16, 32));
  33233. var remainder = 0;
  33234. for (var z = 0; z < 16; z++) {
  33235. remainder *= 256 % 3;
  33236. remainder %= 3;
  33237. remainder += (e[z] >>> 0) % 3;
  33238. remainder %= 3;
  33239. }
  33240. if (remainder === 0) {
  33241. k = calculateSHA256(e, 0, e.length);
  33242. } else if (remainder === 1) {
  33243. k = calculateSHA384(e, 0, e.length);
  33244. } else if (remainder === 2) {
  33245. k = calculateSHA512(e, 0, e.length);
  33246. }
  33247. i++;
  33248. }
  33249. return k.subarray(0, 32);
  33250. }
  33251. function PDF20() {
  33252. }
  33253. function compareByteArrays(array1, array2) {
  33254. if (array1.length !== array2.length) {
  33255. return false;
  33256. }
  33257. for (var i = 0; i < array1.length; i++) {
  33258. if (array1[i] !== array2[i]) {
  33259. return false;
  33260. }
  33261. }
  33262. return true;
  33263. }
  33264. PDF20.prototype = {
  33265. hash: function PDF20_hash(password, concatBytes, userBytes) {
  33266. return calculatePDF20Hash(password, concatBytes, userBytes);
  33267. },
  33268. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  33269. var hashData = new Uint8Array(password.length + 56);
  33270. hashData.set(password, 0);
  33271. hashData.set(ownerValidationSalt, password.length);
  33272. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  33273. var result = calculatePDF20Hash(password, hashData, userBytes);
  33274. return compareByteArrays(result, ownerPassword);
  33275. },
  33276. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  33277. var hashData = new Uint8Array(password.length + 8);
  33278. hashData.set(password, 0);
  33279. hashData.set(userValidationSalt, password.length);
  33280. var result = calculatePDF20Hash(password, hashData, []);
  33281. return compareByteArrays(result, userPassword);
  33282. },
  33283. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  33284. var hashData = new Uint8Array(password.length + 56);
  33285. hashData.set(password, 0);
  33286. hashData.set(ownerKeySalt, password.length);
  33287. hashData.set(userBytes, password.length + ownerKeySalt.length);
  33288. var key = calculatePDF20Hash(password, hashData, userBytes);
  33289. var cipher = new AES256Cipher(key);
  33290. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  33291. },
  33292. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  33293. var hashData = new Uint8Array(password.length + 8);
  33294. hashData.set(password, 0);
  33295. hashData.set(userKeySalt, password.length);
  33296. var key = calculatePDF20Hash(password, hashData, []);
  33297. var cipher = new AES256Cipher(key);
  33298. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  33299. }
  33300. };
  33301. return PDF20;
  33302. }();
  33303. var CipherTransform = function CipherTransformClosure() {
  33304. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  33305. this.StringCipherConstructor = stringCipherConstructor;
  33306. this.StreamCipherConstructor = streamCipherConstructor;
  33307. }
  33308. CipherTransform.prototype = {
  33309. createStream: function CipherTransform_createStream(stream, length) {
  33310. var cipher = new this.StreamCipherConstructor();
  33311. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  33312. return cipher.decryptBlock(data, finalize);
  33313. });
  33314. },
  33315. decryptString: function CipherTransform_decryptString(s) {
  33316. var cipher = new this.StringCipherConstructor();
  33317. var data = stringToBytes(s);
  33318. data = cipher.decryptBlock(data, true);
  33319. return bytesToString(data);
  33320. }
  33321. };
  33322. return CipherTransform;
  33323. }();
  33324. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  33325. var defaultPasswordBytes = new Uint8Array([
  33326. 0x28,
  33327. 0xBF,
  33328. 0x4E,
  33329. 0x5E,
  33330. 0x4E,
  33331. 0x75,
  33332. 0x8A,
  33333. 0x41,
  33334. 0x64,
  33335. 0x00,
  33336. 0x4E,
  33337. 0x56,
  33338. 0xFF,
  33339. 0xFA,
  33340. 0x01,
  33341. 0x08,
  33342. 0x2E,
  33343. 0x2E,
  33344. 0x00,
  33345. 0xB6,
  33346. 0xD0,
  33347. 0x68,
  33348. 0x3E,
  33349. 0x80,
  33350. 0x2F,
  33351. 0x0C,
  33352. 0xA9,
  33353. 0xFE,
  33354. 0x64,
  33355. 0x53,
  33356. 0x69,
  33357. 0x7A
  33358. ]);
  33359. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  33360. if (password) {
  33361. var passwordLength = Math.min(127, password.length);
  33362. password = password.subarray(0, passwordLength);
  33363. } else {
  33364. password = [];
  33365. }
  33366. var pdfAlgorithm;
  33367. if (revision === 6) {
  33368. pdfAlgorithm = new PDF20();
  33369. } else {
  33370. pdfAlgorithm = new PDF17();
  33371. }
  33372. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  33373. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  33374. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  33375. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  33376. }
  33377. return null;
  33378. }
  33379. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  33380. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  33381. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  33382. if (password) {
  33383. n = Math.min(32, password.length);
  33384. for (; i < n; ++i) {
  33385. hashData[i] = password[i];
  33386. }
  33387. }
  33388. j = 0;
  33389. while (i < 32) {
  33390. hashData[i++] = defaultPasswordBytes[j++];
  33391. }
  33392. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  33393. hashData[i++] = ownerPassword[j];
  33394. }
  33395. hashData[i++] = flags & 0xFF;
  33396. hashData[i++] = flags >> 8 & 0xFF;
  33397. hashData[i++] = flags >> 16 & 0xFF;
  33398. hashData[i++] = flags >>> 24 & 0xFF;
  33399. for (j = 0, n = fileId.length; j < n; ++j) {
  33400. hashData[i++] = fileId[j];
  33401. }
  33402. if (revision >= 4 && !encryptMetadata) {
  33403. hashData[i++] = 0xFF;
  33404. hashData[i++] = 0xFF;
  33405. hashData[i++] = 0xFF;
  33406. hashData[i++] = 0xFF;
  33407. }
  33408. var hash = calculateMD5(hashData, 0, i);
  33409. var keyLengthInBytes = keyLength >> 3;
  33410. if (revision >= 3) {
  33411. for (j = 0; j < 50; ++j) {
  33412. hash = calculateMD5(hash, 0, keyLengthInBytes);
  33413. }
  33414. }
  33415. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  33416. var cipher, checkData;
  33417. if (revision >= 3) {
  33418. for (i = 0; i < 32; ++i) {
  33419. hashData[i] = defaultPasswordBytes[i];
  33420. }
  33421. for (j = 0, n = fileId.length; j < n; ++j) {
  33422. hashData[i++] = fileId[j];
  33423. }
  33424. cipher = new ARCFourCipher(encryptionKey);
  33425. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  33426. n = encryptionKey.length;
  33427. var derivedKey = new Uint8Array(n), k;
  33428. for (j = 1; j <= 19; ++j) {
  33429. for (k = 0; k < n; ++k) {
  33430. derivedKey[k] = encryptionKey[k] ^ j;
  33431. }
  33432. cipher = new ARCFourCipher(derivedKey);
  33433. checkData = cipher.encryptBlock(checkData);
  33434. }
  33435. for (j = 0, n = checkData.length; j < n; ++j) {
  33436. if (userPassword[j] !== checkData[j]) {
  33437. return null;
  33438. }
  33439. }
  33440. } else {
  33441. cipher = new ARCFourCipher(encryptionKey);
  33442. checkData = cipher.encryptBlock(defaultPasswordBytes);
  33443. for (j = 0, n = checkData.length; j < n; ++j) {
  33444. if (userPassword[j] !== checkData[j]) {
  33445. return null;
  33446. }
  33447. }
  33448. }
  33449. return encryptionKey;
  33450. }
  33451. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  33452. var hashData = new Uint8Array(32), i = 0, j, n;
  33453. n = Math.min(32, password.length);
  33454. for (; i < n; ++i) {
  33455. hashData[i] = password[i];
  33456. }
  33457. j = 0;
  33458. while (i < 32) {
  33459. hashData[i++] = defaultPasswordBytes[j++];
  33460. }
  33461. var hash = calculateMD5(hashData, 0, i);
  33462. var keyLengthInBytes = keyLength >> 3;
  33463. if (revision >= 3) {
  33464. for (j = 0; j < 50; ++j) {
  33465. hash = calculateMD5(hash, 0, hash.length);
  33466. }
  33467. }
  33468. var cipher, userPassword;
  33469. if (revision >= 3) {
  33470. userPassword = ownerPassword;
  33471. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  33472. for (j = 19; j >= 0; j--) {
  33473. for (k = 0; k < keyLengthInBytes; ++k) {
  33474. derivedKey[k] = hash[k] ^ j;
  33475. }
  33476. cipher = new ARCFourCipher(derivedKey);
  33477. userPassword = cipher.encryptBlock(userPassword);
  33478. }
  33479. } else {
  33480. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  33481. userPassword = cipher.encryptBlock(ownerPassword);
  33482. }
  33483. return userPassword;
  33484. }
  33485. var identityName = Name.get('Identity');
  33486. function CipherTransformFactory(dict, fileId, password) {
  33487. var filter = dict.get('Filter');
  33488. if (!isName(filter, 'Standard')) {
  33489. error('unknown encryption method');
  33490. }
  33491. this.dict = dict;
  33492. var algorithm = dict.get('V');
  33493. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  33494. error('unsupported encryption algorithm');
  33495. }
  33496. this.algorithm = algorithm;
  33497. var keyLength = dict.get('Length');
  33498. if (!keyLength) {
  33499. if (algorithm <= 3) {
  33500. keyLength = 40;
  33501. } else {
  33502. var cfDict = dict.get('CF');
  33503. var streamCryptoName = dict.get('StmF');
  33504. if (isDict(cfDict) && isName(streamCryptoName)) {
  33505. cfDict.suppressEncryption = true;
  33506. var handlerDict = cfDict.get(streamCryptoName.name);
  33507. keyLength = handlerDict && handlerDict.get('Length') || 128;
  33508. if (keyLength < 40) {
  33509. keyLength <<= 3;
  33510. }
  33511. }
  33512. }
  33513. }
  33514. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  33515. error('invalid key length');
  33516. }
  33517. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  33518. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  33519. var flags = dict.get('P');
  33520. var revision = dict.get('R');
  33521. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  33522. this.encryptMetadata = encryptMetadata;
  33523. var fileIdBytes = stringToBytes(fileId);
  33524. var passwordBytes;
  33525. if (password) {
  33526. if (revision === 6) {
  33527. try {
  33528. password = utf8StringToString(password);
  33529. } catch (ex) {
  33530. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  33531. }
  33532. }
  33533. passwordBytes = stringToBytes(password);
  33534. }
  33535. var encryptionKey;
  33536. if (algorithm !== 5) {
  33537. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  33538. } else {
  33539. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  33540. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  33541. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  33542. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  33543. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  33544. var ownerEncryption = stringToBytes(dict.get('OE'));
  33545. var userEncryption = stringToBytes(dict.get('UE'));
  33546. var perms = stringToBytes(dict.get('Perms'));
  33547. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  33548. }
  33549. if (!encryptionKey && !password) {
  33550. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  33551. } else if (!encryptionKey && password) {
  33552. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  33553. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  33554. }
  33555. if (!encryptionKey) {
  33556. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  33557. }
  33558. this.encryptionKey = encryptionKey;
  33559. if (algorithm >= 4) {
  33560. var cf = dict.get('CF');
  33561. if (isDict(cf)) {
  33562. cf.suppressEncryption = true;
  33563. }
  33564. this.cf = cf;
  33565. this.stmf = dict.get('StmF') || identityName;
  33566. this.strf = dict.get('StrF') || identityName;
  33567. this.eff = dict.get('EFF') || this.stmf;
  33568. }
  33569. }
  33570. function buildObjectKey(num, gen, encryptionKey, isAes) {
  33571. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  33572. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  33573. key[i] = encryptionKey[i];
  33574. }
  33575. key[i++] = num & 0xFF;
  33576. key[i++] = num >> 8 & 0xFF;
  33577. key[i++] = num >> 16 & 0xFF;
  33578. key[i++] = gen & 0xFF;
  33579. key[i++] = gen >> 8 & 0xFF;
  33580. if (isAes) {
  33581. key[i++] = 0x73;
  33582. key[i++] = 0x41;
  33583. key[i++] = 0x6C;
  33584. key[i++] = 0x54;
  33585. }
  33586. var hash = calculateMD5(key, 0, i);
  33587. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  33588. }
  33589. function buildCipherConstructor(cf, name, num, gen, key) {
  33590. assert(isName(name), 'Invalid crypt filter name.');
  33591. var cryptFilter = cf.get(name.name);
  33592. var cfm;
  33593. if (cryptFilter !== null && cryptFilter !== undefined) {
  33594. cfm = cryptFilter.get('CFM');
  33595. }
  33596. if (!cfm || cfm.name === 'None') {
  33597. return function cipherTransformFactoryBuildCipherConstructorNone() {
  33598. return new NullCipher();
  33599. };
  33600. }
  33601. if (cfm.name === 'V2') {
  33602. return function cipherTransformFactoryBuildCipherConstructorV2() {
  33603. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  33604. };
  33605. }
  33606. if (cfm.name === 'AESV2') {
  33607. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  33608. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  33609. };
  33610. }
  33611. if (cfm.name === 'AESV3') {
  33612. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  33613. return new AES256Cipher(key);
  33614. };
  33615. }
  33616. error('Unknown crypto method');
  33617. }
  33618. CipherTransformFactory.prototype = {
  33619. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  33620. if (this.algorithm === 4 || this.algorithm === 5) {
  33621. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  33622. }
  33623. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  33624. var cipherConstructor = function buildCipherCipherConstructor() {
  33625. return new ARCFourCipher(key);
  33626. };
  33627. return new CipherTransform(cipherConstructor, cipherConstructor);
  33628. }
  33629. };
  33630. return CipherTransformFactory;
  33631. }();
  33632. exports.AES128Cipher = AES128Cipher;
  33633. exports.AES256Cipher = AES256Cipher;
  33634. exports.ARCFourCipher = ARCFourCipher;
  33635. exports.CipherTransformFactory = CipherTransformFactory;
  33636. exports.PDF17 = PDF17;
  33637. exports.PDF20 = PDF20;
  33638. exports.calculateMD5 = calculateMD5;
  33639. exports.calculateSHA256 = calculateSHA256;
  33640. exports.calculateSHA384 = calculateSHA384;
  33641. exports.calculateSHA512 = calculateSHA512;
  33642. }));
  33643. (function (root, factory) {
  33644. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  33645. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  33646. var Util = sharedUtil.Util;
  33647. var bytesToString = sharedUtil.bytesToString;
  33648. var error = sharedUtil.error;
  33649. var Stream = coreStream.Stream;
  33650. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  33651. var StandardEncoding = coreEncodings.StandardEncoding;
  33652. var CFFParser = coreCFFParser.CFFParser;
  33653. var FontRendererFactory = function FontRendererFactoryClosure() {
  33654. function getLong(data, offset) {
  33655. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  33656. }
  33657. function getUshort(data, offset) {
  33658. return data[offset] << 8 | data[offset + 1];
  33659. }
  33660. function parseCmap(data, start, end) {
  33661. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  33662. var format = getUshort(data, start + offset);
  33663. var length, ranges, p, i;
  33664. if (format === 4) {
  33665. length = getUshort(data, start + offset + 2);
  33666. var segCount = getUshort(data, start + offset + 6) >> 1;
  33667. p = start + offset + 14;
  33668. ranges = [];
  33669. for (i = 0; i < segCount; i++, p += 2) {
  33670. ranges[i] = { end: getUshort(data, p) };
  33671. }
  33672. p += 2;
  33673. for (i = 0; i < segCount; i++, p += 2) {
  33674. ranges[i].start = getUshort(data, p);
  33675. }
  33676. for (i = 0; i < segCount; i++, p += 2) {
  33677. ranges[i].idDelta = getUshort(data, p);
  33678. }
  33679. for (i = 0; i < segCount; i++, p += 2) {
  33680. var idOffset = getUshort(data, p);
  33681. if (idOffset === 0) {
  33682. continue;
  33683. }
  33684. ranges[i].ids = [];
  33685. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  33686. ranges[i].ids[j] = getUshort(data, p + idOffset);
  33687. idOffset += 2;
  33688. }
  33689. }
  33690. return ranges;
  33691. } else if (format === 12) {
  33692. length = getLong(data, start + offset + 4);
  33693. var groups = getLong(data, start + offset + 12);
  33694. p = start + offset + 16;
  33695. ranges = [];
  33696. for (i = 0; i < groups; i++) {
  33697. ranges.push({
  33698. start: getLong(data, p),
  33699. end: getLong(data, p + 4),
  33700. idDelta: getLong(data, p + 8) - getLong(data, p)
  33701. });
  33702. p += 12;
  33703. }
  33704. return ranges;
  33705. }
  33706. error('not supported cmap: ' + format);
  33707. }
  33708. function parseCff(data, start, end, seacAnalysisEnabled) {
  33709. var properties = {};
  33710. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  33711. var cff = parser.parse();
  33712. return {
  33713. glyphs: cff.charStrings.objects,
  33714. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  33715. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  33716. };
  33717. }
  33718. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  33719. var itemSize, itemDecode;
  33720. if (isGlyphLocationsLong) {
  33721. itemSize = 4;
  33722. itemDecode = function fontItemDecodeLong(data, offset) {
  33723. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  33724. };
  33725. } else {
  33726. itemSize = 2;
  33727. itemDecode = function fontItemDecode(data, offset) {
  33728. return data[offset] << 9 | data[offset + 1] << 1;
  33729. };
  33730. }
  33731. var glyphs = [];
  33732. var startOffset = itemDecode(loca, 0);
  33733. for (var j = itemSize; j < loca.length; j += itemSize) {
  33734. var endOffset = itemDecode(loca, j);
  33735. glyphs.push(glyf.subarray(startOffset, endOffset));
  33736. startOffset = endOffset;
  33737. }
  33738. return glyphs;
  33739. }
  33740. function lookupCmap(ranges, unicode) {
  33741. var code = unicode.charCodeAt(0), gid = 0;
  33742. var l = 0, r = ranges.length - 1;
  33743. while (l < r) {
  33744. var c = l + r + 1 >> 1;
  33745. if (code < ranges[c].start) {
  33746. r = c - 1;
  33747. } else {
  33748. l = c;
  33749. }
  33750. }
  33751. if (ranges[l].start <= code && code <= ranges[l].end) {
  33752. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  33753. }
  33754. return {
  33755. charCode: code,
  33756. glyphId: gid
  33757. };
  33758. }
  33759. function compileGlyf(code, cmds, font) {
  33760. function moveTo(x, y) {
  33761. cmds.push({
  33762. cmd: 'moveTo',
  33763. args: [
  33764. x,
  33765. y
  33766. ]
  33767. });
  33768. }
  33769. function lineTo(x, y) {
  33770. cmds.push({
  33771. cmd: 'lineTo',
  33772. args: [
  33773. x,
  33774. y
  33775. ]
  33776. });
  33777. }
  33778. function quadraticCurveTo(xa, ya, x, y) {
  33779. cmds.push({
  33780. cmd: 'quadraticCurveTo',
  33781. args: [
  33782. xa,
  33783. ya,
  33784. x,
  33785. y
  33786. ]
  33787. });
  33788. }
  33789. var i = 0;
  33790. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  33791. var flags;
  33792. var x = 0, y = 0;
  33793. i += 10;
  33794. if (numberOfContours < 0) {
  33795. do {
  33796. flags = code[i] << 8 | code[i + 1];
  33797. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  33798. i += 4;
  33799. var arg1, arg2;
  33800. if (flags & 0x01) {
  33801. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  33802. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  33803. i += 4;
  33804. } else {
  33805. arg1 = code[i++];
  33806. arg2 = code[i++];
  33807. }
  33808. if (flags & 0x02) {
  33809. x = arg1;
  33810. y = arg2;
  33811. } else {
  33812. x = 0;
  33813. y = 0;
  33814. }
  33815. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  33816. if (flags & 0x08) {
  33817. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  33818. i += 2;
  33819. } else if (flags & 0x40) {
  33820. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  33821. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  33822. i += 4;
  33823. } else if (flags & 0x80) {
  33824. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  33825. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  33826. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  33827. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  33828. i += 8;
  33829. }
  33830. var subglyph = font.glyphs[glyphIndex];
  33831. if (subglyph) {
  33832. cmds.push({ cmd: 'save' });
  33833. cmds.push({
  33834. cmd: 'transform',
  33835. args: [
  33836. scaleX,
  33837. scale01,
  33838. scale10,
  33839. scaleY,
  33840. x,
  33841. y
  33842. ]
  33843. });
  33844. compileGlyf(subglyph, cmds, font);
  33845. cmds.push({ cmd: 'restore' });
  33846. }
  33847. } while (flags & 0x20);
  33848. } else {
  33849. var endPtsOfContours = [];
  33850. var j, jj;
  33851. for (j = 0; j < numberOfContours; j++) {
  33852. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  33853. i += 2;
  33854. }
  33855. var instructionLength = code[i] << 8 | code[i + 1];
  33856. i += 2 + instructionLength;
  33857. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  33858. var points = [];
  33859. while (points.length < numberOfPoints) {
  33860. flags = code[i++];
  33861. var repeat = 1;
  33862. if (flags & 0x08) {
  33863. repeat += code[i++];
  33864. }
  33865. while (repeat-- > 0) {
  33866. points.push({ flags: flags });
  33867. }
  33868. }
  33869. for (j = 0; j < numberOfPoints; j++) {
  33870. switch (points[j].flags & 0x12) {
  33871. case 0x00:
  33872. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  33873. i += 2;
  33874. break;
  33875. case 0x02:
  33876. x -= code[i++];
  33877. break;
  33878. case 0x12:
  33879. x += code[i++];
  33880. break;
  33881. }
  33882. points[j].x = x;
  33883. }
  33884. for (j = 0; j < numberOfPoints; j++) {
  33885. switch (points[j].flags & 0x24) {
  33886. case 0x00:
  33887. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  33888. i += 2;
  33889. break;
  33890. case 0x04:
  33891. y -= code[i++];
  33892. break;
  33893. case 0x24:
  33894. y += code[i++];
  33895. break;
  33896. }
  33897. points[j].y = y;
  33898. }
  33899. var startPoint = 0;
  33900. for (i = 0; i < numberOfContours; i++) {
  33901. var endPoint = endPtsOfContours[i];
  33902. var contour = points.slice(startPoint, endPoint + 1);
  33903. if (contour[0].flags & 1) {
  33904. contour.push(contour[0]);
  33905. } else if (contour[contour.length - 1].flags & 1) {
  33906. contour.unshift(contour[contour.length - 1]);
  33907. } else {
  33908. var p = {
  33909. flags: 1,
  33910. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  33911. y: (contour[0].y + contour[contour.length - 1].y) / 2
  33912. };
  33913. contour.unshift(p);
  33914. contour.push(p);
  33915. }
  33916. moveTo(contour[0].x, contour[0].y);
  33917. for (j = 1, jj = contour.length; j < jj; j++) {
  33918. if (contour[j].flags & 1) {
  33919. lineTo(contour[j].x, contour[j].y);
  33920. } else if (contour[j + 1].flags & 1) {
  33921. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  33922. j++;
  33923. } else {
  33924. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  33925. }
  33926. }
  33927. startPoint = endPoint + 1;
  33928. }
  33929. }
  33930. }
  33931. function compileCharString(code, cmds, font) {
  33932. var stack = [];
  33933. var x = 0, y = 0;
  33934. var stems = 0;
  33935. function moveTo(x, y) {
  33936. cmds.push({
  33937. cmd: 'moveTo',
  33938. args: [
  33939. x,
  33940. y
  33941. ]
  33942. });
  33943. }
  33944. function lineTo(x, y) {
  33945. cmds.push({
  33946. cmd: 'lineTo',
  33947. args: [
  33948. x,
  33949. y
  33950. ]
  33951. });
  33952. }
  33953. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  33954. cmds.push({
  33955. cmd: 'bezierCurveTo',
  33956. args: [
  33957. x1,
  33958. y1,
  33959. x2,
  33960. y2,
  33961. x,
  33962. y
  33963. ]
  33964. });
  33965. }
  33966. function parse(code) {
  33967. var i = 0;
  33968. while (i < code.length) {
  33969. var stackClean = false;
  33970. var v = code[i++];
  33971. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  33972. switch (v) {
  33973. case 1:
  33974. stems += stack.length >> 1;
  33975. stackClean = true;
  33976. break;
  33977. case 3:
  33978. stems += stack.length >> 1;
  33979. stackClean = true;
  33980. break;
  33981. case 4:
  33982. y += stack.pop();
  33983. moveTo(x, y);
  33984. stackClean = true;
  33985. break;
  33986. case 5:
  33987. while (stack.length > 0) {
  33988. x += stack.shift();
  33989. y += stack.shift();
  33990. lineTo(x, y);
  33991. }
  33992. break;
  33993. case 6:
  33994. while (stack.length > 0) {
  33995. x += stack.shift();
  33996. lineTo(x, y);
  33997. if (stack.length === 0) {
  33998. break;
  33999. }
  34000. y += stack.shift();
  34001. lineTo(x, y);
  34002. }
  34003. break;
  34004. case 7:
  34005. while (stack.length > 0) {
  34006. y += stack.shift();
  34007. lineTo(x, y);
  34008. if (stack.length === 0) {
  34009. break;
  34010. }
  34011. x += stack.shift();
  34012. lineTo(x, y);
  34013. }
  34014. break;
  34015. case 8:
  34016. while (stack.length > 0) {
  34017. xa = x + stack.shift();
  34018. ya = y + stack.shift();
  34019. xb = xa + stack.shift();
  34020. yb = ya + stack.shift();
  34021. x = xb + stack.shift();
  34022. y = yb + stack.shift();
  34023. bezierCurveTo(xa, ya, xb, yb, x, y);
  34024. }
  34025. break;
  34026. case 10:
  34027. n = stack.pop() + font.subrsBias;
  34028. subrCode = font.subrs[n];
  34029. if (subrCode) {
  34030. parse(subrCode);
  34031. }
  34032. break;
  34033. case 11:
  34034. return;
  34035. case 12:
  34036. v = code[i++];
  34037. switch (v) {
  34038. case 34:
  34039. xa = x + stack.shift();
  34040. xb = xa + stack.shift();
  34041. y1 = y + stack.shift();
  34042. x = xb + stack.shift();
  34043. bezierCurveTo(xa, y, xb, y1, x, y1);
  34044. xa = x + stack.shift();
  34045. xb = xa + stack.shift();
  34046. x = xb + stack.shift();
  34047. bezierCurveTo(xa, y1, xb, y, x, y);
  34048. break;
  34049. case 35:
  34050. xa = x + stack.shift();
  34051. ya = y + stack.shift();
  34052. xb = xa + stack.shift();
  34053. yb = ya + stack.shift();
  34054. x = xb + stack.shift();
  34055. y = yb + stack.shift();
  34056. bezierCurveTo(xa, ya, xb, yb, x, y);
  34057. xa = x + stack.shift();
  34058. ya = y + stack.shift();
  34059. xb = xa + stack.shift();
  34060. yb = ya + stack.shift();
  34061. x = xb + stack.shift();
  34062. y = yb + stack.shift();
  34063. bezierCurveTo(xa, ya, xb, yb, x, y);
  34064. stack.pop();
  34065. break;
  34066. case 36:
  34067. xa = x + stack.shift();
  34068. y1 = y + stack.shift();
  34069. xb = xa + stack.shift();
  34070. y2 = y1 + stack.shift();
  34071. x = xb + stack.shift();
  34072. bezierCurveTo(xa, y1, xb, y2, x, y2);
  34073. xa = x + stack.shift();
  34074. xb = xa + stack.shift();
  34075. y3 = y2 + stack.shift();
  34076. x = xb + stack.shift();
  34077. bezierCurveTo(xa, y2, xb, y3, x, y);
  34078. break;
  34079. case 37:
  34080. var x0 = x, y0 = y;
  34081. xa = x + stack.shift();
  34082. ya = y + stack.shift();
  34083. xb = xa + stack.shift();
  34084. yb = ya + stack.shift();
  34085. x = xb + stack.shift();
  34086. y = yb + stack.shift();
  34087. bezierCurveTo(xa, ya, xb, yb, x, y);
  34088. xa = x + stack.shift();
  34089. ya = y + stack.shift();
  34090. xb = xa + stack.shift();
  34091. yb = ya + stack.shift();
  34092. x = xb;
  34093. y = yb;
  34094. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  34095. x += stack.shift();
  34096. } else {
  34097. y += stack.shift();
  34098. }
  34099. bezierCurveTo(xa, ya, xb, yb, x, y);
  34100. break;
  34101. default:
  34102. error('unknown operator: 12 ' + v);
  34103. }
  34104. break;
  34105. case 14:
  34106. if (stack.length >= 4) {
  34107. var achar = stack.pop();
  34108. var bchar = stack.pop();
  34109. y = stack.pop();
  34110. x = stack.pop();
  34111. cmds.push({ cmd: 'save' });
  34112. cmds.push({
  34113. cmd: 'translate',
  34114. args: [
  34115. x,
  34116. y
  34117. ]
  34118. });
  34119. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  34120. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  34121. cmds.push({ cmd: 'restore' });
  34122. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  34123. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  34124. }
  34125. return;
  34126. case 18:
  34127. stems += stack.length >> 1;
  34128. stackClean = true;
  34129. break;
  34130. case 19:
  34131. stems += stack.length >> 1;
  34132. i += stems + 7 >> 3;
  34133. stackClean = true;
  34134. break;
  34135. case 20:
  34136. stems += stack.length >> 1;
  34137. i += stems + 7 >> 3;
  34138. stackClean = true;
  34139. break;
  34140. case 21:
  34141. y += stack.pop();
  34142. x += stack.pop();
  34143. moveTo(x, y);
  34144. stackClean = true;
  34145. break;
  34146. case 22:
  34147. x += stack.pop();
  34148. moveTo(x, y);
  34149. stackClean = true;
  34150. break;
  34151. case 23:
  34152. stems += stack.length >> 1;
  34153. stackClean = true;
  34154. break;
  34155. case 24:
  34156. while (stack.length > 2) {
  34157. xa = x + stack.shift();
  34158. ya = y + stack.shift();
  34159. xb = xa + stack.shift();
  34160. yb = ya + stack.shift();
  34161. x = xb + stack.shift();
  34162. y = yb + stack.shift();
  34163. bezierCurveTo(xa, ya, xb, yb, x, y);
  34164. }
  34165. x += stack.shift();
  34166. y += stack.shift();
  34167. lineTo(x, y);
  34168. break;
  34169. case 25:
  34170. while (stack.length > 6) {
  34171. x += stack.shift();
  34172. y += stack.shift();
  34173. lineTo(x, y);
  34174. }
  34175. xa = x + stack.shift();
  34176. ya = y + stack.shift();
  34177. xb = xa + stack.shift();
  34178. yb = ya + stack.shift();
  34179. x = xb + stack.shift();
  34180. y = yb + stack.shift();
  34181. bezierCurveTo(xa, ya, xb, yb, x, y);
  34182. break;
  34183. case 26:
  34184. if (stack.length % 2) {
  34185. x += stack.shift();
  34186. }
  34187. while (stack.length > 0) {
  34188. xa = x;
  34189. ya = y + stack.shift();
  34190. xb = xa + stack.shift();
  34191. yb = ya + stack.shift();
  34192. x = xb;
  34193. y = yb + stack.shift();
  34194. bezierCurveTo(xa, ya, xb, yb, x, y);
  34195. }
  34196. break;
  34197. case 27:
  34198. if (stack.length % 2) {
  34199. y += stack.shift();
  34200. }
  34201. while (stack.length > 0) {
  34202. xa = x + stack.shift();
  34203. ya = y;
  34204. xb = xa + stack.shift();
  34205. yb = ya + stack.shift();
  34206. x = xb + stack.shift();
  34207. y = yb;
  34208. bezierCurveTo(xa, ya, xb, yb, x, y);
  34209. }
  34210. break;
  34211. case 28:
  34212. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  34213. i += 2;
  34214. break;
  34215. case 29:
  34216. n = stack.pop() + font.gsubrsBias;
  34217. subrCode = font.gsubrs[n];
  34218. if (subrCode) {
  34219. parse(subrCode);
  34220. }
  34221. break;
  34222. case 30:
  34223. while (stack.length > 0) {
  34224. xa = x;
  34225. ya = y + stack.shift();
  34226. xb = xa + stack.shift();
  34227. yb = ya + stack.shift();
  34228. x = xb + stack.shift();
  34229. y = yb + (stack.length === 1 ? stack.shift() : 0);
  34230. bezierCurveTo(xa, ya, xb, yb, x, y);
  34231. if (stack.length === 0) {
  34232. break;
  34233. }
  34234. xa = x + stack.shift();
  34235. ya = y;
  34236. xb = xa + stack.shift();
  34237. yb = ya + stack.shift();
  34238. y = yb + stack.shift();
  34239. x = xb + (stack.length === 1 ? stack.shift() : 0);
  34240. bezierCurveTo(xa, ya, xb, yb, x, y);
  34241. }
  34242. break;
  34243. case 31:
  34244. while (stack.length > 0) {
  34245. xa = x + stack.shift();
  34246. ya = y;
  34247. xb = xa + stack.shift();
  34248. yb = ya + stack.shift();
  34249. y = yb + stack.shift();
  34250. x = xb + (stack.length === 1 ? stack.shift() : 0);
  34251. bezierCurveTo(xa, ya, xb, yb, x, y);
  34252. if (stack.length === 0) {
  34253. break;
  34254. }
  34255. xa = x;
  34256. ya = y + stack.shift();
  34257. xb = xa + stack.shift();
  34258. yb = ya + stack.shift();
  34259. x = xb + stack.shift();
  34260. y = yb + (stack.length === 1 ? stack.shift() : 0);
  34261. bezierCurveTo(xa, ya, xb, yb, x, y);
  34262. }
  34263. break;
  34264. default:
  34265. if (v < 32) {
  34266. error('unknown operator: ' + v);
  34267. }
  34268. if (v < 247) {
  34269. stack.push(v - 139);
  34270. } else if (v < 251) {
  34271. stack.push((v - 247) * 256 + code[i++] + 108);
  34272. } else if (v < 255) {
  34273. stack.push(-(v - 251) * 256 - code[i++] - 108);
  34274. } else {
  34275. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  34276. i += 4;
  34277. }
  34278. break;
  34279. }
  34280. if (stackClean) {
  34281. stack.length = 0;
  34282. }
  34283. }
  34284. }
  34285. parse(code);
  34286. }
  34287. var noop = '';
  34288. function CompiledFont(fontMatrix) {
  34289. this.compiledGlyphs = Object.create(null);
  34290. this.compiledCharCodeToGlyphId = Object.create(null);
  34291. this.fontMatrix = fontMatrix;
  34292. }
  34293. CompiledFont.prototype = {
  34294. getPathJs: function (unicode) {
  34295. var cmap = lookupCmap(this.cmap, unicode);
  34296. var fn = this.compiledGlyphs[cmap.glyphId];
  34297. if (!fn) {
  34298. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  34299. this.compiledGlyphs[cmap.glyphId] = fn;
  34300. }
  34301. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  34302. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  34303. }
  34304. return fn;
  34305. },
  34306. compileGlyph: function (code) {
  34307. if (!code || code.length === 0 || code[0] === 14) {
  34308. return noop;
  34309. }
  34310. var cmds = [];
  34311. cmds.push({ cmd: 'save' });
  34312. cmds.push({
  34313. cmd: 'transform',
  34314. args: this.fontMatrix.slice()
  34315. });
  34316. cmds.push({
  34317. cmd: 'scale',
  34318. args: [
  34319. 'size',
  34320. '-size'
  34321. ]
  34322. });
  34323. this.compileGlyphImpl(code, cmds);
  34324. cmds.push({ cmd: 'restore' });
  34325. return cmds;
  34326. },
  34327. compileGlyphImpl: function () {
  34328. error('Children classes should implement this.');
  34329. },
  34330. hasBuiltPath: function (unicode) {
  34331. var cmap = lookupCmap(this.cmap, unicode);
  34332. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  34333. }
  34334. };
  34335. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  34336. fontMatrix = fontMatrix || [
  34337. 0.000488,
  34338. 0,
  34339. 0,
  34340. 0.000488,
  34341. 0,
  34342. 0
  34343. ];
  34344. CompiledFont.call(this, fontMatrix);
  34345. this.glyphs = glyphs;
  34346. this.cmap = cmap;
  34347. }
  34348. Util.inherit(TrueTypeCompiled, CompiledFont, {
  34349. compileGlyphImpl: function (code, cmds) {
  34350. compileGlyf(code, cmds, this);
  34351. }
  34352. });
  34353. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  34354. fontMatrix = fontMatrix || [
  34355. 0.001,
  34356. 0,
  34357. 0,
  34358. 0.001,
  34359. 0,
  34360. 0
  34361. ];
  34362. CompiledFont.call(this, fontMatrix);
  34363. this.glyphs = cffInfo.glyphs;
  34364. this.gsubrs = cffInfo.gsubrs || [];
  34365. this.subrs = cffInfo.subrs || [];
  34366. this.cmap = cmap;
  34367. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  34368. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  34369. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  34370. }
  34371. Util.inherit(Type2Compiled, CompiledFont, {
  34372. compileGlyphImpl: function (code, cmds) {
  34373. compileCharString(code, cmds, this);
  34374. }
  34375. });
  34376. return {
  34377. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  34378. var data = new Uint8Array(font.data);
  34379. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  34380. var numTables = getUshort(data, 4);
  34381. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  34382. var tag = bytesToString(data.subarray(p, p + 4));
  34383. var offset = getLong(data, p + 8);
  34384. var length = getLong(data, p + 12);
  34385. switch (tag) {
  34386. case 'cmap':
  34387. cmap = parseCmap(data, offset, offset + length);
  34388. break;
  34389. case 'glyf':
  34390. glyf = data.subarray(offset, offset + length);
  34391. break;
  34392. case 'loca':
  34393. loca = data.subarray(offset, offset + length);
  34394. break;
  34395. case 'head':
  34396. unitsPerEm = getUshort(data, offset + 18);
  34397. indexToLocFormat = getUshort(data, offset + 50);
  34398. break;
  34399. case 'CFF ':
  34400. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  34401. break;
  34402. }
  34403. }
  34404. if (glyf) {
  34405. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  34406. 1 / unitsPerEm,
  34407. 0,
  34408. 0,
  34409. 1 / unitsPerEm,
  34410. 0,
  34411. 0
  34412. ];
  34413. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  34414. }
  34415. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  34416. }
  34417. };
  34418. }();
  34419. exports.FontRendererFactory = FontRendererFactory;
  34420. }));
  34421. (function (root, factory) {
  34422. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  34423. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  34424. var MissingDataException = sharedUtil.MissingDataException;
  34425. var StreamType = sharedUtil.StreamType;
  34426. var assert = sharedUtil.assert;
  34427. var error = sharedUtil.error;
  34428. var info = sharedUtil.info;
  34429. var isArray = sharedUtil.isArray;
  34430. var isInt = sharedUtil.isInt;
  34431. var isNum = sharedUtil.isNum;
  34432. var isString = sharedUtil.isString;
  34433. var warn = sharedUtil.warn;
  34434. var Cmd = corePrimitives.Cmd;
  34435. var Dict = corePrimitives.Dict;
  34436. var Name = corePrimitives.Name;
  34437. var Ref = corePrimitives.Ref;
  34438. var isCmd = corePrimitives.isCmd;
  34439. var isDict = corePrimitives.isDict;
  34440. var isName = corePrimitives.isName;
  34441. var Ascii85Stream = coreStream.Ascii85Stream;
  34442. var AsciiHexStream = coreStream.AsciiHexStream;
  34443. var CCITTFaxStream = coreStream.CCITTFaxStream;
  34444. var FlateStream = coreStream.FlateStream;
  34445. var Jbig2Stream = coreStream.Jbig2Stream;
  34446. var JpegStream = coreStream.JpegStream;
  34447. var JpxStream = coreStream.JpxStream;
  34448. var LZWStream = coreStream.LZWStream;
  34449. var NullStream = coreStream.NullStream;
  34450. var PredictorStream = coreStream.PredictorStream;
  34451. var RunLengthStream = coreStream.RunLengthStream;
  34452. var EOF = {};
  34453. function isEOF(v) {
  34454. return v === EOF;
  34455. }
  34456. var MAX_LENGTH_TO_CACHE = 1000;
  34457. var Parser = function ParserClosure() {
  34458. function Parser(lexer, allowStreams, xref, recoveryMode) {
  34459. this.lexer = lexer;
  34460. this.allowStreams = allowStreams;
  34461. this.xref = xref;
  34462. this.recoveryMode = recoveryMode || false;
  34463. this.imageCache = Object.create(null);
  34464. this.refill();
  34465. }
  34466. Parser.prototype = {
  34467. refill: function Parser_refill() {
  34468. this.buf1 = this.lexer.getObj();
  34469. this.buf2 = this.lexer.getObj();
  34470. },
  34471. shift: function Parser_shift() {
  34472. if (isCmd(this.buf2, 'ID')) {
  34473. this.buf1 = this.buf2;
  34474. this.buf2 = null;
  34475. } else {
  34476. this.buf1 = this.buf2;
  34477. this.buf2 = this.lexer.getObj();
  34478. }
  34479. },
  34480. tryShift: function Parser_tryShift() {
  34481. try {
  34482. this.shift();
  34483. return true;
  34484. } catch (e) {
  34485. if (e instanceof MissingDataException) {
  34486. throw e;
  34487. }
  34488. return false;
  34489. }
  34490. },
  34491. getObj: function Parser_getObj(cipherTransform) {
  34492. var buf1 = this.buf1;
  34493. this.shift();
  34494. if (buf1 instanceof Cmd) {
  34495. switch (buf1.cmd) {
  34496. case 'BI':
  34497. return this.makeInlineImage(cipherTransform);
  34498. case '[':
  34499. var array = [];
  34500. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  34501. array.push(this.getObj(cipherTransform));
  34502. }
  34503. if (isEOF(this.buf1)) {
  34504. if (!this.recoveryMode) {
  34505. error('End of file inside array');
  34506. }
  34507. return array;
  34508. }
  34509. this.shift();
  34510. return array;
  34511. case '<<':
  34512. var dict = new Dict(this.xref);
  34513. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  34514. if (!isName(this.buf1)) {
  34515. info('Malformed dictionary: key must be a name object');
  34516. this.shift();
  34517. continue;
  34518. }
  34519. var key = this.buf1.name;
  34520. this.shift();
  34521. if (isEOF(this.buf1)) {
  34522. break;
  34523. }
  34524. dict.set(key, this.getObj(cipherTransform));
  34525. }
  34526. if (isEOF(this.buf1)) {
  34527. if (!this.recoveryMode) {
  34528. error('End of file inside dictionary');
  34529. }
  34530. return dict;
  34531. }
  34532. if (isCmd(this.buf2, 'stream')) {
  34533. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  34534. }
  34535. this.shift();
  34536. return dict;
  34537. default:
  34538. return buf1;
  34539. }
  34540. }
  34541. if (isInt(buf1)) {
  34542. var num = buf1;
  34543. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  34544. var ref = new Ref(num, this.buf1);
  34545. this.shift();
  34546. this.shift();
  34547. return ref;
  34548. }
  34549. return num;
  34550. }
  34551. if (isString(buf1)) {
  34552. var str = buf1;
  34553. if (cipherTransform) {
  34554. str = cipherTransform.decryptString(str);
  34555. }
  34556. return str;
  34557. }
  34558. return buf1;
  34559. },
  34560. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  34561. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  34562. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  34563. while ((ch = stream.getByte()) !== -1) {
  34564. if (state === 0) {
  34565. state = ch === E ? 1 : 0;
  34566. } else if (state === 1) {
  34567. state = ch === I ? 2 : 0;
  34568. } else {
  34569. assert(state === 2);
  34570. if (ch === SPACE || ch === LF || ch === CR) {
  34571. n = 5;
  34572. followingBytes = stream.peekBytes(n);
  34573. for (i = 0; i < n; i++) {
  34574. ch = followingBytes[i];
  34575. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  34576. state = 0;
  34577. break;
  34578. }
  34579. }
  34580. if (state === 2) {
  34581. break;
  34582. }
  34583. } else
  34584. {
  34585. state = 0;
  34586. }
  34587. }
  34588. }
  34589. return stream.pos - 4 - startPos;
  34590. },
  34591. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  34592. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  34593. while ((b = stream.getByte()) !== -1) {
  34594. if (b !== 0xFF) {
  34595. continue;
  34596. }
  34597. switch (stream.getByte()) {
  34598. case 0x00:
  34599. break;
  34600. case 0xFF:
  34601. stream.skip(-1);
  34602. break;
  34603. case 0xD9:
  34604. foundEOI = true;
  34605. break;
  34606. case 0xC0:
  34607. case 0xC1:
  34608. case 0xC2:
  34609. case 0xC3:
  34610. case 0xC5:
  34611. case 0xC6:
  34612. case 0xC7:
  34613. case 0xC9:
  34614. case 0xCA:
  34615. case 0xCB:
  34616. case 0xCD:
  34617. case 0xCE:
  34618. case 0xCF:
  34619. case 0xC4:
  34620. case 0xCC:
  34621. case 0xDA:
  34622. case 0xDB:
  34623. case 0xDC:
  34624. case 0xDD:
  34625. case 0xDE:
  34626. case 0xDF:
  34627. case 0xE0:
  34628. case 0xE1:
  34629. case 0xE2:
  34630. case 0xE3:
  34631. case 0xE4:
  34632. case 0xE5:
  34633. case 0xE6:
  34634. case 0xE7:
  34635. case 0xE8:
  34636. case 0xE9:
  34637. case 0xEA:
  34638. case 0xEB:
  34639. case 0xEC:
  34640. case 0xED:
  34641. case 0xEE:
  34642. case 0xEF:
  34643. case 0xFE:
  34644. markerLength = stream.getUint16();
  34645. if (markerLength > 2) {
  34646. stream.skip(markerLength - 2);
  34647. } else
  34648. {
  34649. stream.skip(-2);
  34650. }
  34651. break;
  34652. }
  34653. if (foundEOI) {
  34654. break;
  34655. }
  34656. }
  34657. length = stream.pos - startPos;
  34658. if (b === -1) {
  34659. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  34660. stream.skip(-length);
  34661. return this.findDefaultInlineStreamEnd(stream);
  34662. }
  34663. this.inlineStreamSkipEI(stream);
  34664. return length;
  34665. },
  34666. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  34667. var TILDE = 0x7E, GT = 0x3E;
  34668. var startPos = stream.pos, ch, length;
  34669. while ((ch = stream.getByte()) !== -1) {
  34670. if (ch === TILDE && stream.peekByte() === GT) {
  34671. stream.skip();
  34672. break;
  34673. }
  34674. }
  34675. length = stream.pos - startPos;
  34676. if (ch === -1) {
  34677. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  34678. stream.skip(-length);
  34679. return this.findDefaultInlineStreamEnd(stream);
  34680. }
  34681. this.inlineStreamSkipEI(stream);
  34682. return length;
  34683. },
  34684. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  34685. var GT = 0x3E;
  34686. var startPos = stream.pos, ch, length;
  34687. while ((ch = stream.getByte()) !== -1) {
  34688. if (ch === GT) {
  34689. break;
  34690. }
  34691. }
  34692. length = stream.pos - startPos;
  34693. if (ch === -1) {
  34694. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  34695. stream.skip(-length);
  34696. return this.findDefaultInlineStreamEnd(stream);
  34697. }
  34698. this.inlineStreamSkipEI(stream);
  34699. return length;
  34700. },
  34701. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  34702. var E = 0x45, I = 0x49;
  34703. var state = 0, ch;
  34704. while ((ch = stream.getByte()) !== -1) {
  34705. if (state === 0) {
  34706. state = ch === E ? 1 : 0;
  34707. } else if (state === 1) {
  34708. state = ch === I ? 2 : 0;
  34709. } else if (state === 2) {
  34710. break;
  34711. }
  34712. }
  34713. },
  34714. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  34715. var lexer = this.lexer;
  34716. var stream = lexer.stream;
  34717. var dict = new Dict(this.xref);
  34718. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  34719. if (!isName(this.buf1)) {
  34720. error('Dictionary key must be a name object');
  34721. }
  34722. var key = this.buf1.name;
  34723. this.shift();
  34724. if (isEOF(this.buf1)) {
  34725. break;
  34726. }
  34727. dict.set(key, this.getObj(cipherTransform));
  34728. }
  34729. var filter = dict.get('Filter', 'F'), filterName;
  34730. if (isName(filter)) {
  34731. filterName = filter.name;
  34732. } else if (isArray(filter)) {
  34733. var filterZero = this.xref.fetchIfRef(filter[0]);
  34734. if (isName(filterZero)) {
  34735. filterName = filterZero.name;
  34736. }
  34737. }
  34738. var startPos = stream.pos, length, i, ii;
  34739. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  34740. length = this.findDCTDecodeInlineStreamEnd(stream);
  34741. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  34742. length = this.findASCII85DecodeInlineStreamEnd(stream);
  34743. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  34744. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  34745. } else {
  34746. length = this.findDefaultInlineStreamEnd(stream);
  34747. }
  34748. var imageStream = stream.makeSubStream(startPos, length, dict);
  34749. var adler32;
  34750. if (length < MAX_LENGTH_TO_CACHE) {
  34751. var imageBytes = imageStream.getBytes();
  34752. imageStream.reset();
  34753. var a = 1;
  34754. var b = 0;
  34755. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  34756. a += imageBytes[i] & 0xff;
  34757. b += a;
  34758. }
  34759. adler32 = b % 65521 << 16 | a % 65521;
  34760. if (this.imageCache.adler32 === adler32) {
  34761. this.buf2 = Cmd.get('EI');
  34762. this.shift();
  34763. this.imageCache[adler32].reset();
  34764. return this.imageCache[adler32];
  34765. }
  34766. }
  34767. if (cipherTransform) {
  34768. imageStream = cipherTransform.createStream(imageStream, length);
  34769. }
  34770. imageStream = this.filter(imageStream, dict, length);
  34771. imageStream.dict = dict;
  34772. if (adler32 !== undefined) {
  34773. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  34774. this.imageCache[adler32] = imageStream;
  34775. }
  34776. this.buf2 = Cmd.get('EI');
  34777. this.shift();
  34778. return imageStream;
  34779. },
  34780. makeStream: function Parser_makeStream(dict, cipherTransform) {
  34781. var lexer = this.lexer;
  34782. var stream = lexer.stream;
  34783. lexer.skipToNextLine();
  34784. var pos = stream.pos - 1;
  34785. var length = dict.get('Length');
  34786. if (!isInt(length)) {
  34787. info('Bad ' + length + ' attribute in stream');
  34788. length = 0;
  34789. }
  34790. stream.pos = pos + length;
  34791. lexer.nextChar();
  34792. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  34793. this.shift();
  34794. } else
  34795. {
  34796. stream.pos = pos;
  34797. var SCAN_BLOCK_SIZE = 2048;
  34798. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  34799. var ENDSTREAM_SIGNATURE = [
  34800. 0x65,
  34801. 0x6E,
  34802. 0x64,
  34803. 0x73,
  34804. 0x74,
  34805. 0x72,
  34806. 0x65,
  34807. 0x61,
  34808. 0x6D
  34809. ];
  34810. var skipped = 0, found = false, i, j;
  34811. while (stream.pos < stream.end) {
  34812. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  34813. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  34814. if (scanLength <= 0) {
  34815. break;
  34816. }
  34817. found = false;
  34818. i = 0;
  34819. while (i < scanLength) {
  34820. j = 0;
  34821. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  34822. j++;
  34823. }
  34824. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  34825. found = true;
  34826. break;
  34827. }
  34828. i++;
  34829. }
  34830. if (found) {
  34831. skipped += i;
  34832. stream.pos += i;
  34833. break;
  34834. }
  34835. skipped += scanLength;
  34836. stream.pos += scanLength;
  34837. }
  34838. if (!found) {
  34839. error('Missing endstream');
  34840. }
  34841. length = skipped;
  34842. lexer.nextChar();
  34843. this.shift();
  34844. this.shift();
  34845. }
  34846. this.shift();
  34847. stream = stream.makeSubStream(pos, length, dict);
  34848. if (cipherTransform) {
  34849. stream = cipherTransform.createStream(stream, length);
  34850. }
  34851. stream = this.filter(stream, dict, length);
  34852. stream.dict = dict;
  34853. return stream;
  34854. },
  34855. filter: function Parser_filter(stream, dict, length) {
  34856. var filter = dict.get('Filter', 'F');
  34857. var params = dict.get('DecodeParms', 'DP');
  34858. if (isName(filter)) {
  34859. if (isArray(params)) {
  34860. params = this.xref.fetchIfRef(params[0]);
  34861. }
  34862. return this.makeFilter(stream, filter.name, length, params);
  34863. }
  34864. var maybeLength = length;
  34865. if (isArray(filter)) {
  34866. var filterArray = filter;
  34867. var paramsArray = params;
  34868. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  34869. filter = this.xref.fetchIfRef(filterArray[i]);
  34870. if (!isName(filter)) {
  34871. error('Bad filter name: ' + filter);
  34872. }
  34873. params = null;
  34874. if (isArray(paramsArray) && i in paramsArray) {
  34875. params = this.xref.fetchIfRef(paramsArray[i]);
  34876. }
  34877. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  34878. maybeLength = null;
  34879. }
  34880. }
  34881. return stream;
  34882. },
  34883. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  34884. if (maybeLength === 0) {
  34885. warn('Empty "' + name + '" stream.');
  34886. return new NullStream(stream);
  34887. }
  34888. try {
  34889. var xrefStreamStats = this.xref.stats.streamTypes;
  34890. if (name === 'FlateDecode' || name === 'Fl') {
  34891. xrefStreamStats[StreamType.FLATE] = true;
  34892. if (params) {
  34893. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  34894. }
  34895. return new FlateStream(stream, maybeLength);
  34896. }
  34897. if (name === 'LZWDecode' || name === 'LZW') {
  34898. xrefStreamStats[StreamType.LZW] = true;
  34899. var earlyChange = 1;
  34900. if (params) {
  34901. if (params.has('EarlyChange')) {
  34902. earlyChange = params.get('EarlyChange');
  34903. }
  34904. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  34905. }
  34906. return new LZWStream(stream, maybeLength, earlyChange);
  34907. }
  34908. if (name === 'DCTDecode' || name === 'DCT') {
  34909. xrefStreamStats[StreamType.DCT] = true;
  34910. return new JpegStream(stream, maybeLength, stream.dict, params);
  34911. }
  34912. if (name === 'JPXDecode' || name === 'JPX') {
  34913. xrefStreamStats[StreamType.JPX] = true;
  34914. return new JpxStream(stream, maybeLength, stream.dict, params);
  34915. }
  34916. if (name === 'ASCII85Decode' || name === 'A85') {
  34917. xrefStreamStats[StreamType.A85] = true;
  34918. return new Ascii85Stream(stream, maybeLength);
  34919. }
  34920. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  34921. xrefStreamStats[StreamType.AHX] = true;
  34922. return new AsciiHexStream(stream, maybeLength);
  34923. }
  34924. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  34925. xrefStreamStats[StreamType.CCF] = true;
  34926. return new CCITTFaxStream(stream, maybeLength, params);
  34927. }
  34928. if (name === 'RunLengthDecode' || name === 'RL') {
  34929. xrefStreamStats[StreamType.RL] = true;
  34930. return new RunLengthStream(stream, maybeLength);
  34931. }
  34932. if (name === 'JBIG2Decode') {
  34933. xrefStreamStats[StreamType.JBIG] = true;
  34934. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  34935. }
  34936. warn('filter "' + name + '" not supported yet');
  34937. return stream;
  34938. } catch (ex) {
  34939. if (ex instanceof MissingDataException) {
  34940. throw ex;
  34941. }
  34942. warn('Invalid stream: \"' + ex + '\"');
  34943. return new NullStream(stream);
  34944. }
  34945. }
  34946. };
  34947. return Parser;
  34948. }();
  34949. var Lexer = function LexerClosure() {
  34950. function Lexer(stream, knownCommands) {
  34951. this.stream = stream;
  34952. this.nextChar();
  34953. this.strBuf = [];
  34954. this.knownCommands = knownCommands;
  34955. }
  34956. var specialChars = [
  34957. 1,
  34958. 0,
  34959. 0,
  34960. 0,
  34961. 0,
  34962. 0,
  34963. 0,
  34964. 0,
  34965. 0,
  34966. 1,
  34967. 1,
  34968. 0,
  34969. 1,
  34970. 1,
  34971. 0,
  34972. 0,
  34973. 0,
  34974. 0,
  34975. 0,
  34976. 0,
  34977. 0,
  34978. 0,
  34979. 0,
  34980. 0,
  34981. 0,
  34982. 0,
  34983. 0,
  34984. 0,
  34985. 0,
  34986. 0,
  34987. 0,
  34988. 0,
  34989. 1,
  34990. 0,
  34991. 0,
  34992. 0,
  34993. 0,
  34994. 2,
  34995. 0,
  34996. 0,
  34997. 2,
  34998. 2,
  34999. 0,
  35000. 0,
  35001. 0,
  35002. 0,
  35003. 0,
  35004. 2,
  35005. 0,
  35006. 0,
  35007. 0,
  35008. 0,
  35009. 0,
  35010. 0,
  35011. 0,
  35012. 0,
  35013. 0,
  35014. 0,
  35015. 0,
  35016. 0,
  35017. 2,
  35018. 0,
  35019. 2,
  35020. 0,
  35021. 0,
  35022. 0,
  35023. 0,
  35024. 0,
  35025. 0,
  35026. 0,
  35027. 0,
  35028. 0,
  35029. 0,
  35030. 0,
  35031. 0,
  35032. 0,
  35033. 0,
  35034. 0,
  35035. 0,
  35036. 0,
  35037. 0,
  35038. 0,
  35039. 0,
  35040. 0,
  35041. 0,
  35042. 0,
  35043. 0,
  35044. 0,
  35045. 0,
  35046. 0,
  35047. 0,
  35048. 2,
  35049. 0,
  35050. 2,
  35051. 0,
  35052. 0,
  35053. 0,
  35054. 0,
  35055. 0,
  35056. 0,
  35057. 0,
  35058. 0,
  35059. 0,
  35060. 0,
  35061. 0,
  35062. 0,
  35063. 0,
  35064. 0,
  35065. 0,
  35066. 0,
  35067. 0,
  35068. 0,
  35069. 0,
  35070. 0,
  35071. 0,
  35072. 0,
  35073. 0,
  35074. 0,
  35075. 0,
  35076. 0,
  35077. 0,
  35078. 0,
  35079. 0,
  35080. 2,
  35081. 0,
  35082. 2,
  35083. 0,
  35084. 0,
  35085. 0,
  35086. 0,
  35087. 0,
  35088. 0,
  35089. 0,
  35090. 0,
  35091. 0,
  35092. 0,
  35093. 0,
  35094. 0,
  35095. 0,
  35096. 0,
  35097. 0,
  35098. 0,
  35099. 0,
  35100. 0,
  35101. 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. ];
  35214. function toHexDigit(ch) {
  35215. if (ch >= 0x30 && ch <= 0x39) {
  35216. return ch & 0x0F;
  35217. }
  35218. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  35219. return (ch & 0x0F) + 9;
  35220. }
  35221. return -1;
  35222. }
  35223. Lexer.prototype = {
  35224. nextChar: function Lexer_nextChar() {
  35225. return this.currentChar = this.stream.getByte();
  35226. },
  35227. peekChar: function Lexer_peekChar() {
  35228. return this.stream.peekByte();
  35229. },
  35230. getNumber: function Lexer_getNumber() {
  35231. var ch = this.currentChar;
  35232. var eNotation = false;
  35233. var divideBy = 0;
  35234. var sign = 1;
  35235. if (ch === 0x2D) {
  35236. sign = -1;
  35237. ch = this.nextChar();
  35238. if (ch === 0x2D) {
  35239. ch = this.nextChar();
  35240. }
  35241. } else if (ch === 0x2B) {
  35242. ch = this.nextChar();
  35243. }
  35244. if (ch === 0x2E) {
  35245. divideBy = 10;
  35246. ch = this.nextChar();
  35247. }
  35248. if (ch < 0x30 || ch > 0x39) {
  35249. error('Invalid number: ' + String.fromCharCode(ch));
  35250. return 0;
  35251. }
  35252. var baseValue = ch - 0x30;
  35253. var powerValue = 0;
  35254. var powerValueSign = 1;
  35255. while ((ch = this.nextChar()) >= 0) {
  35256. if (0x30 <= ch && ch <= 0x39) {
  35257. var currentDigit = ch - 0x30;
  35258. if (eNotation) {
  35259. powerValue = powerValue * 10 + currentDigit;
  35260. } else {
  35261. if (divideBy !== 0) {
  35262. divideBy *= 10;
  35263. }
  35264. baseValue = baseValue * 10 + currentDigit;
  35265. }
  35266. } else if (ch === 0x2E) {
  35267. if (divideBy === 0) {
  35268. divideBy = 1;
  35269. } else {
  35270. break;
  35271. }
  35272. } else if (ch === 0x2D) {
  35273. warn('Badly formatted number');
  35274. } else if (ch === 0x45 || ch === 0x65) {
  35275. ch = this.peekChar();
  35276. if (ch === 0x2B || ch === 0x2D) {
  35277. powerValueSign = ch === 0x2D ? -1 : 1;
  35278. this.nextChar();
  35279. } else if (ch < 0x30 || ch > 0x39) {
  35280. break;
  35281. }
  35282. eNotation = true;
  35283. } else {
  35284. break;
  35285. }
  35286. }
  35287. if (divideBy !== 0) {
  35288. baseValue /= divideBy;
  35289. }
  35290. if (eNotation) {
  35291. baseValue *= Math.pow(10, powerValueSign * powerValue);
  35292. }
  35293. return sign * baseValue;
  35294. },
  35295. getString: function Lexer_getString() {
  35296. var numParen = 1;
  35297. var done = false;
  35298. var strBuf = this.strBuf;
  35299. strBuf.length = 0;
  35300. var ch = this.nextChar();
  35301. while (true) {
  35302. var charBuffered = false;
  35303. switch (ch | 0) {
  35304. case -1:
  35305. warn('Unterminated string');
  35306. done = true;
  35307. break;
  35308. case 0x28:
  35309. ++numParen;
  35310. strBuf.push('(');
  35311. break;
  35312. case 0x29:
  35313. if (--numParen === 0) {
  35314. this.nextChar();
  35315. done = true;
  35316. } else {
  35317. strBuf.push(')');
  35318. }
  35319. break;
  35320. case 0x5C:
  35321. ch = this.nextChar();
  35322. switch (ch) {
  35323. case -1:
  35324. warn('Unterminated string');
  35325. done = true;
  35326. break;
  35327. case 0x6E:
  35328. strBuf.push('\n');
  35329. break;
  35330. case 0x72:
  35331. strBuf.push('\r');
  35332. break;
  35333. case 0x74:
  35334. strBuf.push('\t');
  35335. break;
  35336. case 0x62:
  35337. strBuf.push('\b');
  35338. break;
  35339. case 0x66:
  35340. strBuf.push('\f');
  35341. break;
  35342. case 0x5C:
  35343. case 0x28:
  35344. case 0x29:
  35345. strBuf.push(String.fromCharCode(ch));
  35346. break;
  35347. case 0x30:
  35348. case 0x31:
  35349. case 0x32:
  35350. case 0x33:
  35351. case 0x34:
  35352. case 0x35:
  35353. case 0x36:
  35354. case 0x37:
  35355. var x = ch & 0x0F;
  35356. ch = this.nextChar();
  35357. charBuffered = true;
  35358. if (ch >= 0x30 && ch <= 0x37) {
  35359. x = (x << 3) + (ch & 0x0F);
  35360. ch = this.nextChar();
  35361. if (ch >= 0x30 && ch <= 0x37) {
  35362. charBuffered = false;
  35363. x = (x << 3) + (ch & 0x0F);
  35364. }
  35365. }
  35366. strBuf.push(String.fromCharCode(x));
  35367. break;
  35368. case 0x0D:
  35369. if (this.peekChar() === 0x0A) {
  35370. this.nextChar();
  35371. }
  35372. break;
  35373. case 0x0A:
  35374. break;
  35375. default:
  35376. strBuf.push(String.fromCharCode(ch));
  35377. break;
  35378. }
  35379. break;
  35380. default:
  35381. strBuf.push(String.fromCharCode(ch));
  35382. break;
  35383. }
  35384. if (done) {
  35385. break;
  35386. }
  35387. if (!charBuffered) {
  35388. ch = this.nextChar();
  35389. }
  35390. }
  35391. return strBuf.join('');
  35392. },
  35393. getName: function Lexer_getName() {
  35394. var ch, previousCh;
  35395. var strBuf = this.strBuf;
  35396. strBuf.length = 0;
  35397. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  35398. if (ch === 0x23) {
  35399. ch = this.nextChar();
  35400. if (specialChars[ch]) {
  35401. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  35402. strBuf.push('#');
  35403. break;
  35404. }
  35405. var x = toHexDigit(ch);
  35406. if (x !== -1) {
  35407. previousCh = ch;
  35408. ch = this.nextChar();
  35409. var x2 = toHexDigit(ch);
  35410. if (x2 === -1) {
  35411. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  35412. strBuf.push('#', String.fromCharCode(previousCh));
  35413. if (specialChars[ch]) {
  35414. break;
  35415. }
  35416. strBuf.push(String.fromCharCode(ch));
  35417. continue;
  35418. }
  35419. strBuf.push(String.fromCharCode(x << 4 | x2));
  35420. } else {
  35421. strBuf.push('#', String.fromCharCode(ch));
  35422. }
  35423. } else {
  35424. strBuf.push(String.fromCharCode(ch));
  35425. }
  35426. }
  35427. if (strBuf.length > 127) {
  35428. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  35429. }
  35430. return Name.get(strBuf.join(''));
  35431. },
  35432. getHexString: function Lexer_getHexString() {
  35433. var strBuf = this.strBuf;
  35434. strBuf.length = 0;
  35435. var ch = this.currentChar;
  35436. var isFirstHex = true;
  35437. var firstDigit;
  35438. var secondDigit;
  35439. while (true) {
  35440. if (ch < 0) {
  35441. warn('Unterminated hex string');
  35442. break;
  35443. } else if (ch === 0x3E) {
  35444. this.nextChar();
  35445. break;
  35446. } else if (specialChars[ch] === 1) {
  35447. ch = this.nextChar();
  35448. continue;
  35449. } else {
  35450. if (isFirstHex) {
  35451. firstDigit = toHexDigit(ch);
  35452. if (firstDigit === -1) {
  35453. warn('Ignoring invalid character "' + ch + '" in hex string');
  35454. ch = this.nextChar();
  35455. continue;
  35456. }
  35457. } else {
  35458. secondDigit = toHexDigit(ch);
  35459. if (secondDigit === -1) {
  35460. warn('Ignoring invalid character "' + ch + '" in hex string');
  35461. ch = this.nextChar();
  35462. continue;
  35463. }
  35464. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  35465. }
  35466. isFirstHex = !isFirstHex;
  35467. ch = this.nextChar();
  35468. }
  35469. }
  35470. return strBuf.join('');
  35471. },
  35472. getObj: function Lexer_getObj() {
  35473. var comment = false;
  35474. var ch = this.currentChar;
  35475. while (true) {
  35476. if (ch < 0) {
  35477. return EOF;
  35478. }
  35479. if (comment) {
  35480. if (ch === 0x0A || ch === 0x0D) {
  35481. comment = false;
  35482. }
  35483. } else if (ch === 0x25) {
  35484. comment = true;
  35485. } else if (specialChars[ch] !== 1) {
  35486. break;
  35487. }
  35488. ch = this.nextChar();
  35489. }
  35490. switch (ch | 0) {
  35491. case 0x30:
  35492. case 0x31:
  35493. case 0x32:
  35494. case 0x33:
  35495. case 0x34:
  35496. case 0x35:
  35497. case 0x36:
  35498. case 0x37:
  35499. case 0x38:
  35500. case 0x39:
  35501. case 0x2B:
  35502. case 0x2D:
  35503. case 0x2E:
  35504. return this.getNumber();
  35505. case 0x28:
  35506. return this.getString();
  35507. case 0x2F:
  35508. return this.getName();
  35509. case 0x5B:
  35510. this.nextChar();
  35511. return Cmd.get('[');
  35512. case 0x5D:
  35513. this.nextChar();
  35514. return Cmd.get(']');
  35515. case 0x3C:
  35516. ch = this.nextChar();
  35517. if (ch === 0x3C) {
  35518. this.nextChar();
  35519. return Cmd.get('<<');
  35520. }
  35521. return this.getHexString();
  35522. case 0x3E:
  35523. ch = this.nextChar();
  35524. if (ch === 0x3E) {
  35525. this.nextChar();
  35526. return Cmd.get('>>');
  35527. }
  35528. return Cmd.get('>');
  35529. case 0x7B:
  35530. this.nextChar();
  35531. return Cmd.get('{');
  35532. case 0x7D:
  35533. this.nextChar();
  35534. return Cmd.get('}');
  35535. case 0x29:
  35536. error('Illegal character: ' + ch);
  35537. break;
  35538. }
  35539. var str = String.fromCharCode(ch);
  35540. var knownCommands = this.knownCommands;
  35541. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  35542. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  35543. var possibleCommand = str + String.fromCharCode(ch);
  35544. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  35545. break;
  35546. }
  35547. if (str.length === 128) {
  35548. error('Command token too long: ' + str.length);
  35549. }
  35550. str = possibleCommand;
  35551. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  35552. }
  35553. if (str === 'true') {
  35554. return true;
  35555. }
  35556. if (str === 'false') {
  35557. return false;
  35558. }
  35559. if (str === 'null') {
  35560. return null;
  35561. }
  35562. return Cmd.get(str);
  35563. },
  35564. skipToNextLine: function Lexer_skipToNextLine() {
  35565. var ch = this.currentChar;
  35566. while (ch >= 0) {
  35567. if (ch === 0x0D) {
  35568. ch = this.nextChar();
  35569. if (ch === 0x0A) {
  35570. this.nextChar();
  35571. }
  35572. break;
  35573. } else if (ch === 0x0A) {
  35574. this.nextChar();
  35575. break;
  35576. }
  35577. ch = this.nextChar();
  35578. }
  35579. }
  35580. };
  35581. return Lexer;
  35582. }();
  35583. var Linearization = {
  35584. create: function LinearizationCreate(stream) {
  35585. function getInt(name, allowZeroValue) {
  35586. var obj = linDict.get(name);
  35587. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  35588. return obj;
  35589. }
  35590. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  35591. }
  35592. function getHints() {
  35593. var hints = linDict.get('H'), hintsLength, item;
  35594. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  35595. for (var index = 0; index < hintsLength; index++) {
  35596. if (!(isInt(item = hints[index]) && item > 0)) {
  35597. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  35598. }
  35599. }
  35600. return hints;
  35601. }
  35602. throw new Error('Hint array in the linearization dictionary is invalid.');
  35603. }
  35604. var parser = new Parser(new Lexer(stream), false, null);
  35605. var obj1 = parser.getObj();
  35606. var obj2 = parser.getObj();
  35607. var obj3 = parser.getObj();
  35608. var linDict = parser.getObj();
  35609. var obj, length;
  35610. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  35611. return null;
  35612. } else if ((length = getInt('L')) !== stream.length) {
  35613. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  35614. }
  35615. return {
  35616. length: length,
  35617. hints: getHints(),
  35618. objectNumberFirst: getInt('O'),
  35619. endFirst: getInt('E'),
  35620. numPages: getInt('N'),
  35621. mainXRefEntriesOffset: getInt('T'),
  35622. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  35623. };
  35624. }
  35625. };
  35626. exports.EOF = EOF;
  35627. exports.Lexer = Lexer;
  35628. exports.Linearization = Linearization;
  35629. exports.Parser = Parser;
  35630. exports.isEOF = isEOF;
  35631. }));
  35632. (function (root, factory) {
  35633. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  35634. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  35635. var warn = sharedUtil.warn;
  35636. var isSpace = sharedUtil.isSpace;
  35637. var Stream = coreStream.Stream;
  35638. var getEncoding = coreEncodings.getEncoding;
  35639. var HINTING_ENABLED = false;
  35640. var Type1CharString = function Type1CharStringClosure() {
  35641. var COMMAND_MAP = {
  35642. 'hstem': [1],
  35643. 'vstem': [3],
  35644. 'vmoveto': [4],
  35645. 'rlineto': [5],
  35646. 'hlineto': [6],
  35647. 'vlineto': [7],
  35648. 'rrcurveto': [8],
  35649. 'callsubr': [10],
  35650. 'flex': [
  35651. 12,
  35652. 35
  35653. ],
  35654. 'drop': [
  35655. 12,
  35656. 18
  35657. ],
  35658. 'endchar': [14],
  35659. 'rmoveto': [21],
  35660. 'hmoveto': [22],
  35661. 'vhcurveto': [30],
  35662. 'hvcurveto': [31]
  35663. };
  35664. function Type1CharString() {
  35665. this.width = 0;
  35666. this.lsb = 0;
  35667. this.flexing = false;
  35668. this.output = [];
  35669. this.stack = [];
  35670. }
  35671. Type1CharString.prototype = {
  35672. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  35673. var count = encoded.length;
  35674. var error = false;
  35675. var wx, sbx, subrNumber;
  35676. for (var i = 0; i < count; i++) {
  35677. var value = encoded[i];
  35678. if (value < 32) {
  35679. if (value === 12) {
  35680. value = (value << 8) + encoded[++i];
  35681. }
  35682. switch (value) {
  35683. case 1:
  35684. if (!HINTING_ENABLED) {
  35685. this.stack = [];
  35686. break;
  35687. }
  35688. error = this.executeCommand(2, COMMAND_MAP.hstem);
  35689. break;
  35690. case 3:
  35691. if (!HINTING_ENABLED) {
  35692. this.stack = [];
  35693. break;
  35694. }
  35695. error = this.executeCommand(2, COMMAND_MAP.vstem);
  35696. break;
  35697. case 4:
  35698. if (this.flexing) {
  35699. if (this.stack.length < 1) {
  35700. error = true;
  35701. break;
  35702. }
  35703. var dy = this.stack.pop();
  35704. this.stack.push(0, dy);
  35705. break;
  35706. }
  35707. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  35708. break;
  35709. case 5:
  35710. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  35711. break;
  35712. case 6:
  35713. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  35714. break;
  35715. case 7:
  35716. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  35717. break;
  35718. case 8:
  35719. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  35720. break;
  35721. case 9:
  35722. this.stack = [];
  35723. break;
  35724. case 10:
  35725. if (this.stack.length < 1) {
  35726. error = true;
  35727. break;
  35728. }
  35729. subrNumber = this.stack.pop();
  35730. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  35731. break;
  35732. case 11:
  35733. return error;
  35734. case 13:
  35735. if (this.stack.length < 2) {
  35736. error = true;
  35737. break;
  35738. }
  35739. wx = this.stack.pop();
  35740. sbx = this.stack.pop();
  35741. this.lsb = sbx;
  35742. this.width = wx;
  35743. this.stack.push(wx, sbx);
  35744. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  35745. break;
  35746. case 14:
  35747. this.output.push(COMMAND_MAP.endchar[0]);
  35748. break;
  35749. case 21:
  35750. if (this.flexing) {
  35751. break;
  35752. }
  35753. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  35754. break;
  35755. case 22:
  35756. if (this.flexing) {
  35757. this.stack.push(0);
  35758. break;
  35759. }
  35760. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  35761. break;
  35762. case 30:
  35763. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  35764. break;
  35765. case 31:
  35766. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  35767. break;
  35768. case (12 << 8) + 0:
  35769. this.stack = [];
  35770. break;
  35771. case (12 << 8) + 1:
  35772. if (!HINTING_ENABLED) {
  35773. this.stack = [];
  35774. break;
  35775. }
  35776. error = this.executeCommand(2, COMMAND_MAP.vstem);
  35777. break;
  35778. case (12 << 8) + 2:
  35779. if (!HINTING_ENABLED) {
  35780. this.stack = [];
  35781. break;
  35782. }
  35783. error = this.executeCommand(2, COMMAND_MAP.hstem);
  35784. break;
  35785. case (12 << 8) + 6:
  35786. if (seacAnalysisEnabled) {
  35787. this.seac = this.stack.splice(-4, 4);
  35788. error = this.executeCommand(0, COMMAND_MAP.endchar);
  35789. } else {
  35790. error = this.executeCommand(4, COMMAND_MAP.endchar);
  35791. }
  35792. break;
  35793. case (12 << 8) + 7:
  35794. if (this.stack.length < 4) {
  35795. error = true;
  35796. break;
  35797. }
  35798. var wy = this.stack.pop();
  35799. wx = this.stack.pop();
  35800. var sby = this.stack.pop();
  35801. sbx = this.stack.pop();
  35802. this.lsb = sbx;
  35803. this.width = wx;
  35804. this.stack.push(wx, sbx, sby);
  35805. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  35806. break;
  35807. case (12 << 8) + 12:
  35808. if (this.stack.length < 2) {
  35809. error = true;
  35810. break;
  35811. }
  35812. var num2 = this.stack.pop();
  35813. var num1 = this.stack.pop();
  35814. this.stack.push(num1 / num2);
  35815. break;
  35816. case (12 << 8) + 16:
  35817. if (this.stack.length < 2) {
  35818. error = true;
  35819. break;
  35820. }
  35821. subrNumber = this.stack.pop();
  35822. var numArgs = this.stack.pop();
  35823. if (subrNumber === 0 && numArgs === 3) {
  35824. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  35825. 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]);
  35826. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  35827. this.flexing = false;
  35828. this.stack.push(flexArgs[15], flexArgs[16]);
  35829. } else if (subrNumber === 1 && numArgs === 0) {
  35830. this.flexing = true;
  35831. }
  35832. break;
  35833. case (12 << 8) + 17:
  35834. break;
  35835. case (12 << 8) + 33:
  35836. this.stack = [];
  35837. break;
  35838. default:
  35839. warn('Unknown type 1 charstring command of "' + value + '"');
  35840. break;
  35841. }
  35842. if (error) {
  35843. break;
  35844. }
  35845. continue;
  35846. } else if (value <= 246) {
  35847. value = value - 139;
  35848. } else if (value <= 250) {
  35849. value = (value - 247) * 256 + encoded[++i] + 108;
  35850. } else if (value <= 254) {
  35851. value = -((value - 251) * 256) - encoded[++i] - 108;
  35852. } else {
  35853. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  35854. }
  35855. this.stack.push(value);
  35856. }
  35857. return error;
  35858. },
  35859. executeCommand: function (howManyArgs, command, keepStack) {
  35860. var stackLength = this.stack.length;
  35861. if (howManyArgs > stackLength) {
  35862. return true;
  35863. }
  35864. var start = stackLength - howManyArgs;
  35865. for (var i = start; i < stackLength; i++) {
  35866. var value = this.stack[i];
  35867. if (value === (value | 0)) {
  35868. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  35869. } else {
  35870. value = 65536 * value | 0;
  35871. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  35872. }
  35873. }
  35874. this.output.push.apply(this.output, command);
  35875. if (keepStack) {
  35876. this.stack.splice(start, howManyArgs);
  35877. } else {
  35878. this.stack.length = 0;
  35879. }
  35880. return false;
  35881. }
  35882. };
  35883. return Type1CharString;
  35884. }();
  35885. var Type1Parser = function Type1ParserClosure() {
  35886. var EEXEC_ENCRYPT_KEY = 55665;
  35887. var CHAR_STRS_ENCRYPT_KEY = 4330;
  35888. function isHexDigit(code) {
  35889. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  35890. }
  35891. function decrypt(data, key, discardNumber) {
  35892. if (discardNumber >= data.length) {
  35893. return new Uint8Array(0);
  35894. }
  35895. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  35896. for (i = 0; i < discardNumber; i++) {
  35897. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  35898. }
  35899. var count = data.length - discardNumber;
  35900. var decrypted = new Uint8Array(count);
  35901. for (i = discardNumber, j = 0; j < count; i++, j++) {
  35902. var value = data[i];
  35903. decrypted[j] = value ^ r >> 8;
  35904. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  35905. }
  35906. return decrypted;
  35907. }
  35908. function decryptAscii(data, key, discardNumber) {
  35909. var r = key | 0, c1 = 52845, c2 = 22719;
  35910. var count = data.length, maybeLength = count >>> 1;
  35911. var decrypted = new Uint8Array(maybeLength);
  35912. var i, j;
  35913. for (i = 0, j = 0; i < count; i++) {
  35914. var digit1 = data[i];
  35915. if (!isHexDigit(digit1)) {
  35916. continue;
  35917. }
  35918. i++;
  35919. var digit2;
  35920. while (i < count && !isHexDigit(digit2 = data[i])) {
  35921. i++;
  35922. }
  35923. if (i < count) {
  35924. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  35925. decrypted[j++] = value ^ r >> 8;
  35926. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  35927. }
  35928. }
  35929. return Array.prototype.slice.call(decrypted, discardNumber, j);
  35930. }
  35931. function isSpecial(c) {
  35932. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  35933. }
  35934. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  35935. if (encrypted) {
  35936. var data = stream.getBytes();
  35937. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  35938. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  35939. }
  35940. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  35941. this.stream = stream;
  35942. this.nextChar();
  35943. }
  35944. Type1Parser.prototype = {
  35945. readNumberArray: function Type1Parser_readNumberArray() {
  35946. this.getToken();
  35947. var array = [];
  35948. while (true) {
  35949. var token = this.getToken();
  35950. if (token === null || token === ']' || token === '}') {
  35951. break;
  35952. }
  35953. array.push(parseFloat(token || 0));
  35954. }
  35955. return array;
  35956. },
  35957. readNumber: function Type1Parser_readNumber() {
  35958. var token = this.getToken();
  35959. return parseFloat(token || 0);
  35960. },
  35961. readInt: function Type1Parser_readInt() {
  35962. var token = this.getToken();
  35963. return parseInt(token || 0, 10) | 0;
  35964. },
  35965. readBoolean: function Type1Parser_readBoolean() {
  35966. var token = this.getToken();
  35967. return token === 'true' ? 1 : 0;
  35968. },
  35969. nextChar: function Type1_nextChar() {
  35970. return this.currentChar = this.stream.getByte();
  35971. },
  35972. getToken: function Type1Parser_getToken() {
  35973. var comment = false;
  35974. var ch = this.currentChar;
  35975. while (true) {
  35976. if (ch === -1) {
  35977. return null;
  35978. }
  35979. if (comment) {
  35980. if (ch === 0x0A || ch === 0x0D) {
  35981. comment = false;
  35982. }
  35983. } else if (ch === 0x25) {
  35984. comment = true;
  35985. } else if (!isSpace(ch)) {
  35986. break;
  35987. }
  35988. ch = this.nextChar();
  35989. }
  35990. if (isSpecial(ch)) {
  35991. this.nextChar();
  35992. return String.fromCharCode(ch);
  35993. }
  35994. var token = '';
  35995. do {
  35996. token += String.fromCharCode(ch);
  35997. ch = this.nextChar();
  35998. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  35999. return token;
  36000. },
  36001. extractFontProgram: function Type1Parser_extractFontProgram() {
  36002. var stream = this.stream;
  36003. var subrs = [], charstrings = [];
  36004. var privateData = Object.create(null);
  36005. privateData['lenIV'] = 4;
  36006. var program = {
  36007. subrs: [],
  36008. charstrings: [],
  36009. properties: { 'privateData': privateData }
  36010. };
  36011. var token, length, data, lenIV, encoded;
  36012. while ((token = this.getToken()) !== null) {
  36013. if (token !== '/') {
  36014. continue;
  36015. }
  36016. token = this.getToken();
  36017. switch (token) {
  36018. case 'CharStrings':
  36019. this.getToken();
  36020. this.getToken();
  36021. this.getToken();
  36022. this.getToken();
  36023. while (true) {
  36024. token = this.getToken();
  36025. if (token === null || token === 'end') {
  36026. break;
  36027. }
  36028. if (token !== '/') {
  36029. continue;
  36030. }
  36031. var glyph = this.getToken();
  36032. length = this.readInt();
  36033. this.getToken();
  36034. data = stream.makeSubStream(stream.pos, length);
  36035. lenIV = program.properties.privateData['lenIV'];
  36036. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  36037. stream.skip(length);
  36038. this.nextChar();
  36039. token = this.getToken();
  36040. if (token === 'noaccess') {
  36041. this.getToken();
  36042. }
  36043. charstrings.push({
  36044. glyph: glyph,
  36045. encoded: encoded
  36046. });
  36047. }
  36048. break;
  36049. case 'Subrs':
  36050. var num = this.readInt();
  36051. this.getToken();
  36052. while ((token = this.getToken()) === 'dup') {
  36053. var index = this.readInt();
  36054. length = this.readInt();
  36055. this.getToken();
  36056. data = stream.makeSubStream(stream.pos, length);
  36057. lenIV = program.properties.privateData['lenIV'];
  36058. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  36059. stream.skip(length);
  36060. this.nextChar();
  36061. token = this.getToken();
  36062. if (token === 'noaccess') {
  36063. this.getToken();
  36064. }
  36065. subrs[index] = encoded;
  36066. }
  36067. break;
  36068. case 'BlueValues':
  36069. case 'OtherBlues':
  36070. case 'FamilyBlues':
  36071. case 'FamilyOtherBlues':
  36072. var blueArray = this.readNumberArray();
  36073. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  36074. program.properties.privateData[token] = blueArray;
  36075. }
  36076. break;
  36077. case 'StemSnapH':
  36078. case 'StemSnapV':
  36079. program.properties.privateData[token] = this.readNumberArray();
  36080. break;
  36081. case 'StdHW':
  36082. case 'StdVW':
  36083. program.properties.privateData[token] = this.readNumberArray()[0];
  36084. break;
  36085. case 'BlueShift':
  36086. case 'lenIV':
  36087. case 'BlueFuzz':
  36088. case 'BlueScale':
  36089. case 'LanguageGroup':
  36090. case 'ExpansionFactor':
  36091. program.properties.privateData[token] = this.readNumber();
  36092. break;
  36093. case 'ForceBold':
  36094. program.properties.privateData[token] = this.readBoolean();
  36095. break;
  36096. }
  36097. }
  36098. for (var i = 0; i < charstrings.length; i++) {
  36099. glyph = charstrings[i].glyph;
  36100. encoded = charstrings[i].encoded;
  36101. var charString = new Type1CharString();
  36102. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  36103. var output = charString.output;
  36104. if (error) {
  36105. output = [14];
  36106. }
  36107. program.charstrings.push({
  36108. glyphName: glyph,
  36109. charstring: output,
  36110. width: charString.width,
  36111. lsb: charString.lsb,
  36112. seac: charString.seac
  36113. });
  36114. }
  36115. return program;
  36116. },
  36117. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  36118. var token;
  36119. while ((token = this.getToken()) !== null) {
  36120. if (token !== '/') {
  36121. continue;
  36122. }
  36123. token = this.getToken();
  36124. switch (token) {
  36125. case 'FontMatrix':
  36126. var matrix = this.readNumberArray();
  36127. properties.fontMatrix = matrix;
  36128. break;
  36129. case 'Encoding':
  36130. var encodingArg = this.getToken();
  36131. var encoding;
  36132. if (!/^\d+$/.test(encodingArg)) {
  36133. encoding = getEncoding(encodingArg);
  36134. } else {
  36135. encoding = [];
  36136. var size = parseInt(encodingArg, 10) | 0;
  36137. this.getToken();
  36138. for (var j = 0; j < size; j++) {
  36139. token = this.getToken();
  36140. while (token !== 'dup' && token !== 'def') {
  36141. token = this.getToken();
  36142. if (token === null) {
  36143. return;
  36144. }
  36145. }
  36146. if (token === 'def') {
  36147. break;
  36148. }
  36149. var index = this.readInt();
  36150. this.getToken();
  36151. var glyph = this.getToken();
  36152. encoding[index] = glyph;
  36153. this.getToken();
  36154. }
  36155. }
  36156. properties.builtInEncoding = encoding;
  36157. break;
  36158. case 'FontBBox':
  36159. var fontBBox = this.readNumberArray();
  36160. properties.ascent = fontBBox[3];
  36161. properties.descent = fontBBox[1];
  36162. properties.ascentScaled = true;
  36163. break;
  36164. }
  36165. }
  36166. }
  36167. };
  36168. return Type1Parser;
  36169. }();
  36170. exports.Type1Parser = Type1Parser;
  36171. }));
  36172. (function (root, factory) {
  36173. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  36174. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  36175. var Util = sharedUtil.Util;
  36176. var assert = sharedUtil.assert;
  36177. var warn = sharedUtil.warn;
  36178. var error = sharedUtil.error;
  36179. var isInt = sharedUtil.isInt;
  36180. var isString = sharedUtil.isString;
  36181. var MissingDataException = sharedUtil.MissingDataException;
  36182. var isName = corePrimitives.isName;
  36183. var isCmd = corePrimitives.isCmd;
  36184. var isStream = corePrimitives.isStream;
  36185. var StringStream = coreStream.StringStream;
  36186. var Lexer = coreParser.Lexer;
  36187. var isEOF = coreParser.isEOF;
  36188. var BUILT_IN_CMAPS = [
  36189. 'Adobe-GB1-UCS2',
  36190. 'Adobe-CNS1-UCS2',
  36191. 'Adobe-Japan1-UCS2',
  36192. 'Adobe-Korea1-UCS2',
  36193. '78-EUC-H',
  36194. '78-EUC-V',
  36195. '78-H',
  36196. '78-RKSJ-H',
  36197. '78-RKSJ-V',
  36198. '78-V',
  36199. '78ms-RKSJ-H',
  36200. '78ms-RKSJ-V',
  36201. '83pv-RKSJ-H',
  36202. '90ms-RKSJ-H',
  36203. '90ms-RKSJ-V',
  36204. '90msp-RKSJ-H',
  36205. '90msp-RKSJ-V',
  36206. '90pv-RKSJ-H',
  36207. '90pv-RKSJ-V',
  36208. 'Add-H',
  36209. 'Add-RKSJ-H',
  36210. 'Add-RKSJ-V',
  36211. 'Add-V',
  36212. 'Adobe-CNS1-0',
  36213. 'Adobe-CNS1-1',
  36214. 'Adobe-CNS1-2',
  36215. 'Adobe-CNS1-3',
  36216. 'Adobe-CNS1-4',
  36217. 'Adobe-CNS1-5',
  36218. 'Adobe-CNS1-6',
  36219. 'Adobe-GB1-0',
  36220. 'Adobe-GB1-1',
  36221. 'Adobe-GB1-2',
  36222. 'Adobe-GB1-3',
  36223. 'Adobe-GB1-4',
  36224. 'Adobe-GB1-5',
  36225. 'Adobe-Japan1-0',
  36226. 'Adobe-Japan1-1',
  36227. 'Adobe-Japan1-2',
  36228. 'Adobe-Japan1-3',
  36229. 'Adobe-Japan1-4',
  36230. 'Adobe-Japan1-5',
  36231. 'Adobe-Japan1-6',
  36232. 'Adobe-Korea1-0',
  36233. 'Adobe-Korea1-1',
  36234. 'Adobe-Korea1-2',
  36235. 'B5-H',
  36236. 'B5-V',
  36237. 'B5pc-H',
  36238. 'B5pc-V',
  36239. 'CNS-EUC-H',
  36240. 'CNS-EUC-V',
  36241. 'CNS1-H',
  36242. 'CNS1-V',
  36243. 'CNS2-H',
  36244. 'CNS2-V',
  36245. 'ETHK-B5-H',
  36246. 'ETHK-B5-V',
  36247. 'ETen-B5-H',
  36248. 'ETen-B5-V',
  36249. 'ETenms-B5-H',
  36250. 'ETenms-B5-V',
  36251. 'EUC-H',
  36252. 'EUC-V',
  36253. 'Ext-H',
  36254. 'Ext-RKSJ-H',
  36255. 'Ext-RKSJ-V',
  36256. 'Ext-V',
  36257. 'GB-EUC-H',
  36258. 'GB-EUC-V',
  36259. 'GB-H',
  36260. 'GB-V',
  36261. 'GBK-EUC-H',
  36262. 'GBK-EUC-V',
  36263. 'GBK2K-H',
  36264. 'GBK2K-V',
  36265. 'GBKp-EUC-H',
  36266. 'GBKp-EUC-V',
  36267. 'GBT-EUC-H',
  36268. 'GBT-EUC-V',
  36269. 'GBT-H',
  36270. 'GBT-V',
  36271. 'GBTpc-EUC-H',
  36272. 'GBTpc-EUC-V',
  36273. 'GBpc-EUC-H',
  36274. 'GBpc-EUC-V',
  36275. 'H',
  36276. 'HKdla-B5-H',
  36277. 'HKdla-B5-V',
  36278. 'HKdlb-B5-H',
  36279. 'HKdlb-B5-V',
  36280. 'HKgccs-B5-H',
  36281. 'HKgccs-B5-V',
  36282. 'HKm314-B5-H',
  36283. 'HKm314-B5-V',
  36284. 'HKm471-B5-H',
  36285. 'HKm471-B5-V',
  36286. 'HKscs-B5-H',
  36287. 'HKscs-B5-V',
  36288. 'Hankaku',
  36289. 'Hiragana',
  36290. 'KSC-EUC-H',
  36291. 'KSC-EUC-V',
  36292. 'KSC-H',
  36293. 'KSC-Johab-H',
  36294. 'KSC-Johab-V',
  36295. 'KSC-V',
  36296. 'KSCms-UHC-H',
  36297. 'KSCms-UHC-HW-H',
  36298. 'KSCms-UHC-HW-V',
  36299. 'KSCms-UHC-V',
  36300. 'KSCpc-EUC-H',
  36301. 'KSCpc-EUC-V',
  36302. 'Katakana',
  36303. 'NWP-H',
  36304. 'NWP-V',
  36305. 'RKSJ-H',
  36306. 'RKSJ-V',
  36307. 'Roman',
  36308. 'UniCNS-UCS2-H',
  36309. 'UniCNS-UCS2-V',
  36310. 'UniCNS-UTF16-H',
  36311. 'UniCNS-UTF16-V',
  36312. 'UniCNS-UTF32-H',
  36313. 'UniCNS-UTF32-V',
  36314. 'UniCNS-UTF8-H',
  36315. 'UniCNS-UTF8-V',
  36316. 'UniGB-UCS2-H',
  36317. 'UniGB-UCS2-V',
  36318. 'UniGB-UTF16-H',
  36319. 'UniGB-UTF16-V',
  36320. 'UniGB-UTF32-H',
  36321. 'UniGB-UTF32-V',
  36322. 'UniGB-UTF8-H',
  36323. 'UniGB-UTF8-V',
  36324. 'UniJIS-UCS2-H',
  36325. 'UniJIS-UCS2-HW-H',
  36326. 'UniJIS-UCS2-HW-V',
  36327. 'UniJIS-UCS2-V',
  36328. 'UniJIS-UTF16-H',
  36329. 'UniJIS-UTF16-V',
  36330. 'UniJIS-UTF32-H',
  36331. 'UniJIS-UTF32-V',
  36332. 'UniJIS-UTF8-H',
  36333. 'UniJIS-UTF8-V',
  36334. 'UniJIS2004-UTF16-H',
  36335. 'UniJIS2004-UTF16-V',
  36336. 'UniJIS2004-UTF32-H',
  36337. 'UniJIS2004-UTF32-V',
  36338. 'UniJIS2004-UTF8-H',
  36339. 'UniJIS2004-UTF8-V',
  36340. 'UniJISPro-UCS2-HW-V',
  36341. 'UniJISPro-UCS2-V',
  36342. 'UniJISPro-UTF8-V',
  36343. 'UniJISX0213-UTF32-H',
  36344. 'UniJISX0213-UTF32-V',
  36345. 'UniJISX02132004-UTF32-H',
  36346. 'UniJISX02132004-UTF32-V',
  36347. 'UniKS-UCS2-H',
  36348. 'UniKS-UCS2-V',
  36349. 'UniKS-UTF16-H',
  36350. 'UniKS-UTF16-V',
  36351. 'UniKS-UTF32-H',
  36352. 'UniKS-UTF32-V',
  36353. 'UniKS-UTF8-H',
  36354. 'UniKS-UTF8-V',
  36355. 'V',
  36356. 'WP-Symbol'
  36357. ];
  36358. var CMap = function CMapClosure() {
  36359. function CMap(builtInCMap) {
  36360. this.codespaceRanges = [
  36361. [],
  36362. [],
  36363. [],
  36364. []
  36365. ];
  36366. this.numCodespaceRanges = 0;
  36367. this._map = [];
  36368. this.name = '';
  36369. this.vertical = false;
  36370. this.useCMap = null;
  36371. this.builtInCMap = builtInCMap;
  36372. }
  36373. CMap.prototype = {
  36374. addCodespaceRange: function (n, low, high) {
  36375. this.codespaceRanges[n - 1].push(low, high);
  36376. this.numCodespaceRanges++;
  36377. },
  36378. mapCidRange: function (low, high, dstLow) {
  36379. while (low <= high) {
  36380. this._map[low++] = dstLow++;
  36381. }
  36382. },
  36383. mapBfRange: function (low, high, dstLow) {
  36384. var lastByte = dstLow.length - 1;
  36385. while (low <= high) {
  36386. this._map[low++] = dstLow;
  36387. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  36388. }
  36389. },
  36390. mapBfRangeToArray: function (low, high, array) {
  36391. var i = 0, ii = array.length;
  36392. while (low <= high && i < ii) {
  36393. this._map[low] = array[i++];
  36394. ++low;
  36395. }
  36396. },
  36397. mapOne: function (src, dst) {
  36398. this._map[src] = dst;
  36399. },
  36400. lookup: function (code) {
  36401. return this._map[code];
  36402. },
  36403. contains: function (code) {
  36404. return this._map[code] !== undefined;
  36405. },
  36406. forEach: function (callback) {
  36407. var map = this._map;
  36408. var length = map.length;
  36409. var i;
  36410. if (length <= 0x10000) {
  36411. for (i = 0; i < length; i++) {
  36412. if (map[i] !== undefined) {
  36413. callback(i, map[i]);
  36414. }
  36415. }
  36416. } else {
  36417. for (i in this._map) {
  36418. callback(i, map[i]);
  36419. }
  36420. }
  36421. },
  36422. charCodeOf: function (value) {
  36423. return this._map.indexOf(value);
  36424. },
  36425. getMap: function () {
  36426. return this._map;
  36427. },
  36428. readCharCode: function (str, offset, out) {
  36429. var c = 0;
  36430. var codespaceRanges = this.codespaceRanges;
  36431. var codespaceRangesLen = this.codespaceRanges.length;
  36432. for (var n = 0; n < codespaceRangesLen; n++) {
  36433. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  36434. var codespaceRange = codespaceRanges[n];
  36435. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  36436. var low = codespaceRange[k++];
  36437. var high = codespaceRange[k++];
  36438. if (c >= low && c <= high) {
  36439. out.charcode = c;
  36440. out.length = n + 1;
  36441. return;
  36442. }
  36443. }
  36444. }
  36445. out.charcode = 0;
  36446. out.length = 1;
  36447. },
  36448. get length() {
  36449. return this._map.length;
  36450. },
  36451. get isIdentityCMap() {
  36452. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  36453. return false;
  36454. }
  36455. if (this._map.length !== 0x10000) {
  36456. return false;
  36457. }
  36458. for (var i = 0; i < 0x10000; i++) {
  36459. if (this._map[i] !== i) {
  36460. return false;
  36461. }
  36462. }
  36463. return true;
  36464. }
  36465. };
  36466. return CMap;
  36467. }();
  36468. var IdentityCMap = function IdentityCMapClosure() {
  36469. function IdentityCMap(vertical, n) {
  36470. CMap.call(this);
  36471. this.vertical = vertical;
  36472. this.addCodespaceRange(n, 0, 0xffff);
  36473. }
  36474. Util.inherit(IdentityCMap, CMap, {});
  36475. IdentityCMap.prototype = {
  36476. addCodespaceRange: CMap.prototype.addCodespaceRange,
  36477. mapCidRange: function (low, high, dstLow) {
  36478. error('should not call mapCidRange');
  36479. },
  36480. mapBfRange: function (low, high, dstLow) {
  36481. error('should not call mapBfRange');
  36482. },
  36483. mapBfRangeToArray: function (low, high, array) {
  36484. error('should not call mapBfRangeToArray');
  36485. },
  36486. mapOne: function (src, dst) {
  36487. error('should not call mapCidOne');
  36488. },
  36489. lookup: function (code) {
  36490. return isInt(code) && code <= 0xffff ? code : undefined;
  36491. },
  36492. contains: function (code) {
  36493. return isInt(code) && code <= 0xffff;
  36494. },
  36495. forEach: function (callback) {
  36496. for (var i = 0; i <= 0xffff; i++) {
  36497. callback(i, i);
  36498. }
  36499. },
  36500. charCodeOf: function (value) {
  36501. return isInt(value) && value <= 0xffff ? value : -1;
  36502. },
  36503. getMap: function () {
  36504. var map = new Array(0x10000);
  36505. for (var i = 0; i <= 0xffff; i++) {
  36506. map[i] = i;
  36507. }
  36508. return map;
  36509. },
  36510. readCharCode: CMap.prototype.readCharCode,
  36511. get length() {
  36512. return 0x10000;
  36513. },
  36514. get isIdentityCMap() {
  36515. error('should not access .isIdentityCMap');
  36516. }
  36517. };
  36518. return IdentityCMap;
  36519. }();
  36520. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  36521. function fetchBinaryData(url) {
  36522. return new Promise(function (resolve, reject) {
  36523. var request = new XMLHttpRequest();
  36524. request.open('GET', url, true);
  36525. request.responseType = 'arraybuffer';
  36526. request.onreadystatechange = function () {
  36527. if (request.readyState === XMLHttpRequest.DONE) {
  36528. if (!request.response || request.status !== 200 && request.status !== 0) {
  36529. reject(new Error('Unable to get binary cMap at: ' + url));
  36530. } else {
  36531. resolve(new Uint8Array(request.response));
  36532. }
  36533. }
  36534. };
  36535. request.send(null);
  36536. });
  36537. }
  36538. function hexToInt(a, size) {
  36539. var n = 0;
  36540. for (var i = 0; i <= size; i++) {
  36541. n = n << 8 | a[i];
  36542. }
  36543. return n >>> 0;
  36544. }
  36545. function hexToStr(a, size) {
  36546. if (size === 1) {
  36547. return String.fromCharCode(a[0], a[1]);
  36548. }
  36549. if (size === 3) {
  36550. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  36551. }
  36552. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  36553. }
  36554. function addHex(a, b, size) {
  36555. var c = 0;
  36556. for (var i = size; i >= 0; i--) {
  36557. c += a[i] + b[i];
  36558. a[i] = c & 255;
  36559. c >>= 8;
  36560. }
  36561. }
  36562. function incHex(a, size) {
  36563. var c = 1;
  36564. for (var i = size; i >= 0 && c > 0; i--) {
  36565. c += a[i];
  36566. a[i] = c & 255;
  36567. c >>= 8;
  36568. }
  36569. }
  36570. var MAX_NUM_SIZE = 16;
  36571. var MAX_ENCODED_NUM_SIZE = 19;
  36572. function BinaryCMapStream(data) {
  36573. this.buffer = data;
  36574. this.pos = 0;
  36575. this.end = data.length;
  36576. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  36577. }
  36578. BinaryCMapStream.prototype = {
  36579. readByte: function () {
  36580. if (this.pos >= this.end) {
  36581. return -1;
  36582. }
  36583. return this.buffer[this.pos++];
  36584. },
  36585. readNumber: function () {
  36586. var n = 0;
  36587. var last;
  36588. do {
  36589. var b = this.readByte();
  36590. if (b < 0) {
  36591. error('unexpected EOF in bcmap');
  36592. }
  36593. last = !(b & 0x80);
  36594. n = n << 7 | b & 0x7F;
  36595. } while (!last);
  36596. return n;
  36597. },
  36598. readSigned: function () {
  36599. var n = this.readNumber();
  36600. return n & 1 ? ~(n >>> 1) : n >>> 1;
  36601. },
  36602. readHex: function (num, size) {
  36603. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  36604. this.pos += size + 1;
  36605. },
  36606. readHexNumber: function (num, size) {
  36607. var last;
  36608. var stack = this.tmpBuf, sp = 0;
  36609. do {
  36610. var b = this.readByte();
  36611. if (b < 0) {
  36612. error('unexpected EOF in bcmap');
  36613. }
  36614. last = !(b & 0x80);
  36615. stack[sp++] = b & 0x7F;
  36616. } while (!last);
  36617. var i = size, buffer = 0, bufferSize = 0;
  36618. while (i >= 0) {
  36619. while (bufferSize < 8 && stack.length > 0) {
  36620. buffer = stack[--sp] << bufferSize | buffer;
  36621. bufferSize += 7;
  36622. }
  36623. num[i] = buffer & 255;
  36624. i--;
  36625. buffer >>= 8;
  36626. bufferSize -= 8;
  36627. }
  36628. },
  36629. readHexSigned: function (num, size) {
  36630. this.readHexNumber(num, size);
  36631. var sign = num[size] & 1 ? 255 : 0;
  36632. var c = 0;
  36633. for (var i = 0; i <= size; i++) {
  36634. c = (c & 1) << 8 | num[i];
  36635. num[i] = c >> 1 ^ sign;
  36636. }
  36637. },
  36638. readString: function () {
  36639. var len = this.readNumber();
  36640. var s = '';
  36641. for (var i = 0; i < len; i++) {
  36642. s += String.fromCharCode(this.readNumber());
  36643. }
  36644. return s;
  36645. }
  36646. };
  36647. function processBinaryCMap(url, cMap, extend) {
  36648. return fetchBinaryData(url).then(function (data) {
  36649. var stream = new BinaryCMapStream(data);
  36650. var header = stream.readByte();
  36651. cMap.vertical = !!(header & 1);
  36652. var useCMap = null;
  36653. var start = new Uint8Array(MAX_NUM_SIZE);
  36654. var end = new Uint8Array(MAX_NUM_SIZE);
  36655. var char = new Uint8Array(MAX_NUM_SIZE);
  36656. var charCode = new Uint8Array(MAX_NUM_SIZE);
  36657. var tmp = new Uint8Array(MAX_NUM_SIZE);
  36658. var code;
  36659. var b;
  36660. while ((b = stream.readByte()) >= 0) {
  36661. var type = b >> 5;
  36662. if (type === 7) {
  36663. switch (b & 0x1F) {
  36664. case 0:
  36665. stream.readString();
  36666. break;
  36667. case 1:
  36668. useCMap = stream.readString();
  36669. break;
  36670. }
  36671. continue;
  36672. }
  36673. var sequence = !!(b & 0x10);
  36674. var dataSize = b & 15;
  36675. assert(dataSize + 1 <= MAX_NUM_SIZE);
  36676. var ucs2DataSize = 1;
  36677. var subitemsCount = stream.readNumber();
  36678. var i;
  36679. switch (type) {
  36680. case 0:
  36681. stream.readHex(start, dataSize);
  36682. stream.readHexNumber(end, dataSize);
  36683. addHex(end, start, dataSize);
  36684. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  36685. for (i = 1; i < subitemsCount; i++) {
  36686. incHex(end, dataSize);
  36687. stream.readHexNumber(start, dataSize);
  36688. addHex(start, end, dataSize);
  36689. stream.readHexNumber(end, dataSize);
  36690. addHex(end, start, dataSize);
  36691. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  36692. }
  36693. break;
  36694. case 1:
  36695. stream.readHex(start, dataSize);
  36696. stream.readHexNumber(end, dataSize);
  36697. addHex(end, start, dataSize);
  36698. code = stream.readNumber();
  36699. for (i = 1; i < subitemsCount; i++) {
  36700. incHex(end, dataSize);
  36701. stream.readHexNumber(start, dataSize);
  36702. addHex(start, end, dataSize);
  36703. stream.readHexNumber(end, dataSize);
  36704. addHex(end, start, dataSize);
  36705. code = stream.readNumber();
  36706. }
  36707. break;
  36708. case 2:
  36709. stream.readHex(char, dataSize);
  36710. code = stream.readNumber();
  36711. cMap.mapOne(hexToInt(char, dataSize), code);
  36712. for (i = 1; i < subitemsCount; i++) {
  36713. incHex(char, dataSize);
  36714. if (!sequence) {
  36715. stream.readHexNumber(tmp, dataSize);
  36716. addHex(char, tmp, dataSize);
  36717. }
  36718. code = stream.readSigned() + (code + 1);
  36719. cMap.mapOne(hexToInt(char, dataSize), code);
  36720. }
  36721. break;
  36722. case 3:
  36723. stream.readHex(start, dataSize);
  36724. stream.readHexNumber(end, dataSize);
  36725. addHex(end, start, dataSize);
  36726. code = stream.readNumber();
  36727. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  36728. for (i = 1; i < subitemsCount; i++) {
  36729. incHex(end, dataSize);
  36730. if (!sequence) {
  36731. stream.readHexNumber(start, dataSize);
  36732. addHex(start, end, dataSize);
  36733. } else {
  36734. start.set(end);
  36735. }
  36736. stream.readHexNumber(end, dataSize);
  36737. addHex(end, start, dataSize);
  36738. code = stream.readNumber();
  36739. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  36740. }
  36741. break;
  36742. case 4:
  36743. stream.readHex(char, ucs2DataSize);
  36744. stream.readHex(charCode, dataSize);
  36745. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  36746. for (i = 1; i < subitemsCount; i++) {
  36747. incHex(char, ucs2DataSize);
  36748. if (!sequence) {
  36749. stream.readHexNumber(tmp, ucs2DataSize);
  36750. addHex(char, tmp, ucs2DataSize);
  36751. }
  36752. incHex(charCode, dataSize);
  36753. stream.readHexSigned(tmp, dataSize);
  36754. addHex(charCode, tmp, dataSize);
  36755. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  36756. }
  36757. break;
  36758. case 5:
  36759. stream.readHex(start, ucs2DataSize);
  36760. stream.readHexNumber(end, ucs2DataSize);
  36761. addHex(end, start, ucs2DataSize);
  36762. stream.readHex(charCode, dataSize);
  36763. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  36764. for (i = 1; i < subitemsCount; i++) {
  36765. incHex(end, ucs2DataSize);
  36766. if (!sequence) {
  36767. stream.readHexNumber(start, ucs2DataSize);
  36768. addHex(start, end, ucs2DataSize);
  36769. } else {
  36770. start.set(end);
  36771. }
  36772. stream.readHexNumber(end, ucs2DataSize);
  36773. addHex(end, start, ucs2DataSize);
  36774. stream.readHex(charCode, dataSize);
  36775. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  36776. }
  36777. break;
  36778. default:
  36779. error('Unknown type: ' + type);
  36780. break;
  36781. }
  36782. }
  36783. if (useCMap) {
  36784. return extend(useCMap);
  36785. }
  36786. return cMap;
  36787. });
  36788. }
  36789. function BinaryCMapReader() {
  36790. }
  36791. BinaryCMapReader.prototype = { read: processBinaryCMap };
  36792. return BinaryCMapReader;
  36793. }();
  36794. var CMapFactory = function CMapFactoryClosure() {
  36795. function strToInt(str) {
  36796. var a = 0;
  36797. for (var i = 0; i < str.length; i++) {
  36798. a = a << 8 | str.charCodeAt(i);
  36799. }
  36800. return a >>> 0;
  36801. }
  36802. function expectString(obj) {
  36803. if (!isString(obj)) {
  36804. error('Malformed CMap: expected string.');
  36805. }
  36806. }
  36807. function expectInt(obj) {
  36808. if (!isInt(obj)) {
  36809. error('Malformed CMap: expected int.');
  36810. }
  36811. }
  36812. function parseBfChar(cMap, lexer) {
  36813. while (true) {
  36814. var obj = lexer.getObj();
  36815. if (isEOF(obj)) {
  36816. break;
  36817. }
  36818. if (isCmd(obj, 'endbfchar')) {
  36819. return;
  36820. }
  36821. expectString(obj);
  36822. var src = strToInt(obj);
  36823. obj = lexer.getObj();
  36824. expectString(obj);
  36825. var dst = obj;
  36826. cMap.mapOne(src, dst);
  36827. }
  36828. }
  36829. function parseBfRange(cMap, lexer) {
  36830. while (true) {
  36831. var obj = lexer.getObj();
  36832. if (isEOF(obj)) {
  36833. break;
  36834. }
  36835. if (isCmd(obj, 'endbfrange')) {
  36836. return;
  36837. }
  36838. expectString(obj);
  36839. var low = strToInt(obj);
  36840. obj = lexer.getObj();
  36841. expectString(obj);
  36842. var high = strToInt(obj);
  36843. obj = lexer.getObj();
  36844. if (isInt(obj) || isString(obj)) {
  36845. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  36846. cMap.mapBfRange(low, high, dstLow);
  36847. } else if (isCmd(obj, '[')) {
  36848. obj = lexer.getObj();
  36849. var array = [];
  36850. while (!isCmd(obj, ']') && !isEOF(obj)) {
  36851. array.push(obj);
  36852. obj = lexer.getObj();
  36853. }
  36854. cMap.mapBfRangeToArray(low, high, array);
  36855. } else {
  36856. break;
  36857. }
  36858. }
  36859. error('Invalid bf range.');
  36860. }
  36861. function parseCidChar(cMap, lexer) {
  36862. while (true) {
  36863. var obj = lexer.getObj();
  36864. if (isEOF(obj)) {
  36865. break;
  36866. }
  36867. if (isCmd(obj, 'endcidchar')) {
  36868. return;
  36869. }
  36870. expectString(obj);
  36871. var src = strToInt(obj);
  36872. obj = lexer.getObj();
  36873. expectInt(obj);
  36874. var dst = obj;
  36875. cMap.mapOne(src, dst);
  36876. }
  36877. }
  36878. function parseCidRange(cMap, lexer) {
  36879. while (true) {
  36880. var obj = lexer.getObj();
  36881. if (isEOF(obj)) {
  36882. break;
  36883. }
  36884. if (isCmd(obj, 'endcidrange')) {
  36885. return;
  36886. }
  36887. expectString(obj);
  36888. var low = strToInt(obj);
  36889. obj = lexer.getObj();
  36890. expectString(obj);
  36891. var high = strToInt(obj);
  36892. obj = lexer.getObj();
  36893. expectInt(obj);
  36894. var dstLow = obj;
  36895. cMap.mapCidRange(low, high, dstLow);
  36896. }
  36897. }
  36898. function parseCodespaceRange(cMap, lexer) {
  36899. while (true) {
  36900. var obj = lexer.getObj();
  36901. if (isEOF(obj)) {
  36902. break;
  36903. }
  36904. if (isCmd(obj, 'endcodespacerange')) {
  36905. return;
  36906. }
  36907. if (!isString(obj)) {
  36908. break;
  36909. }
  36910. var low = strToInt(obj);
  36911. obj = lexer.getObj();
  36912. if (!isString(obj)) {
  36913. break;
  36914. }
  36915. var high = strToInt(obj);
  36916. cMap.addCodespaceRange(obj.length, low, high);
  36917. }
  36918. error('Invalid codespace range.');
  36919. }
  36920. function parseWMode(cMap, lexer) {
  36921. var obj = lexer.getObj();
  36922. if (isInt(obj)) {
  36923. cMap.vertical = !!obj;
  36924. }
  36925. }
  36926. function parseCMapName(cMap, lexer) {
  36927. var obj = lexer.getObj();
  36928. if (isName(obj) && isString(obj.name)) {
  36929. cMap.name = obj.name;
  36930. }
  36931. }
  36932. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  36933. var previous;
  36934. var embededUseCMap;
  36935. objLoop:
  36936. while (true) {
  36937. try {
  36938. var obj = lexer.getObj();
  36939. if (isEOF(obj)) {
  36940. break;
  36941. } else if (isName(obj)) {
  36942. if (obj.name === 'WMode') {
  36943. parseWMode(cMap, lexer);
  36944. } else if (obj.name === 'CMapName') {
  36945. parseCMapName(cMap, lexer);
  36946. }
  36947. previous = obj;
  36948. } else if (isCmd(obj)) {
  36949. switch (obj.cmd) {
  36950. case 'endcmap':
  36951. break objLoop;
  36952. case 'usecmap':
  36953. if (isName(previous)) {
  36954. embededUseCMap = previous.name;
  36955. }
  36956. break;
  36957. case 'begincodespacerange':
  36958. parseCodespaceRange(cMap, lexer);
  36959. break;
  36960. case 'beginbfchar':
  36961. parseBfChar(cMap, lexer);
  36962. break;
  36963. case 'begincidchar':
  36964. parseCidChar(cMap, lexer);
  36965. break;
  36966. case 'beginbfrange':
  36967. parseBfRange(cMap, lexer);
  36968. break;
  36969. case 'begincidrange':
  36970. parseCidRange(cMap, lexer);
  36971. break;
  36972. }
  36973. }
  36974. } catch (ex) {
  36975. if (ex instanceof MissingDataException) {
  36976. throw ex;
  36977. }
  36978. warn('Invalid cMap data: ' + ex);
  36979. continue;
  36980. }
  36981. }
  36982. if (!useCMap && embededUseCMap) {
  36983. useCMap = embededUseCMap;
  36984. }
  36985. if (useCMap) {
  36986. return extendCMap(cMap, builtInCMapParams, useCMap);
  36987. }
  36988. return Promise.resolve(cMap);
  36989. }
  36990. function extendCMap(cMap, builtInCMapParams, useCMap) {
  36991. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  36992. cMap.useCMap = newCMap;
  36993. if (cMap.numCodespaceRanges === 0) {
  36994. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  36995. for (var i = 0; i < useCodespaceRanges.length; i++) {
  36996. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  36997. }
  36998. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  36999. }
  37000. cMap.useCMap.forEach(function (key, value) {
  37001. if (!cMap.contains(key)) {
  37002. cMap.mapOne(key, cMap.useCMap.lookup(key));
  37003. }
  37004. });
  37005. return cMap;
  37006. });
  37007. }
  37008. function parseBinaryCMap(name, builtInCMapParams) {
  37009. var url = builtInCMapParams.url + name + '.bcmap';
  37010. var cMap = new CMap(true);
  37011. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  37012. return extendCMap(cMap, builtInCMapParams, useCMap);
  37013. });
  37014. }
  37015. function createBuiltInCMap(name, builtInCMapParams) {
  37016. if (name === 'Identity-H') {
  37017. return Promise.resolve(new IdentityCMap(false, 2));
  37018. } else if (name === 'Identity-V') {
  37019. return Promise.resolve(new IdentityCMap(true, 2));
  37020. }
  37021. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  37022. return Promise.reject(new Error('Unknown cMap name: ' + name));
  37023. }
  37024. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  37025. if (builtInCMapParams.packed) {
  37026. return parseBinaryCMap(name, builtInCMapParams);
  37027. }
  37028. return new Promise(function (resolve, reject) {
  37029. var url = builtInCMapParams.url + name;
  37030. var request = new XMLHttpRequest();
  37031. request.onreadystatechange = function () {
  37032. if (request.readyState === XMLHttpRequest.DONE) {
  37033. if (request.status === 200 || request.status === 0) {
  37034. var cMap = new CMap(true);
  37035. var lexer = new Lexer(new StringStream(request.responseText));
  37036. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  37037. resolve(parsedCMap);
  37038. });
  37039. } else {
  37040. reject(new Error('Unable to get cMap at: ' + url));
  37041. }
  37042. }
  37043. };
  37044. request.open('GET', url, true);
  37045. request.send(null);
  37046. });
  37047. }
  37048. return {
  37049. create: function (encoding, builtInCMapParams, useCMap) {
  37050. if (isName(encoding)) {
  37051. return createBuiltInCMap(encoding.name, builtInCMapParams);
  37052. } else if (isStream(encoding)) {
  37053. var cMap = new CMap();
  37054. var lexer = new Lexer(encoding);
  37055. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  37056. if (parsedCMap.isIdentityCMap) {
  37057. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  37058. }
  37059. return parsedCMap;
  37060. });
  37061. }
  37062. return Promise.reject(new Error('Encoding required.'));
  37063. }
  37064. };
  37065. }();
  37066. exports.CMap = CMap;
  37067. exports.CMapFactory = CMapFactory;
  37068. exports.IdentityCMap = IdentityCMap;
  37069. }));
  37070. (function (root, factory) {
  37071. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  37072. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  37073. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  37074. var FontType = sharedUtil.FontType;
  37075. var assert = sharedUtil.assert;
  37076. var bytesToString = sharedUtil.bytesToString;
  37077. var error = sharedUtil.error;
  37078. var info = sharedUtil.info;
  37079. var isArray = sharedUtil.isArray;
  37080. var isInt = sharedUtil.isInt;
  37081. var isNum = sharedUtil.isNum;
  37082. var readUint32 = sharedUtil.readUint32;
  37083. var shadow = sharedUtil.shadow;
  37084. var string32 = sharedUtil.string32;
  37085. var warn = sharedUtil.warn;
  37086. var MissingDataException = sharedUtil.MissingDataException;
  37087. var isSpace = sharedUtil.isSpace;
  37088. var Stream = coreStream.Stream;
  37089. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  37090. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  37091. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  37092. var StandardEncoding = coreEncodings.StandardEncoding;
  37093. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  37094. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  37095. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  37096. var getEncoding = coreEncodings.getEncoding;
  37097. var getStdFontMap = coreStandardFonts.getStdFontMap;
  37098. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  37099. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  37100. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  37101. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  37102. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  37103. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  37104. var Type1Parser = coreType1Parser.Type1Parser;
  37105. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  37106. var CFFParser = coreCFFParser.CFFParser;
  37107. var CFFCompiler = coreCFFParser.CFFCompiler;
  37108. var CFF = coreCFFParser.CFF;
  37109. var CFFHeader = coreCFFParser.CFFHeader;
  37110. var CFFTopDict = coreCFFParser.CFFTopDict;
  37111. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  37112. var CFFStrings = coreCFFParser.CFFStrings;
  37113. var CFFIndex = coreCFFParser.CFFIndex;
  37114. var CFFCharset = coreCFFParser.CFFCharset;
  37115. var PRIVATE_USE_OFFSET_START = 0xE000;
  37116. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  37117. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  37118. var PDF_GLYPH_SPACE_UNITS = 1000;
  37119. var SEAC_ANALYSIS_ENABLED = false;
  37120. var FontFlags = {
  37121. FixedPitch: 1,
  37122. Serif: 2,
  37123. Symbolic: 4,
  37124. Script: 8,
  37125. Nonsymbolic: 32,
  37126. Italic: 64,
  37127. AllCap: 65536,
  37128. SmallCap: 131072,
  37129. ForceBold: 262144
  37130. };
  37131. var MacStandardGlyphOrdering = [
  37132. '.notdef',
  37133. '.null',
  37134. 'nonmarkingreturn',
  37135. 'space',
  37136. 'exclam',
  37137. 'quotedbl',
  37138. 'numbersign',
  37139. 'dollar',
  37140. 'percent',
  37141. 'ampersand',
  37142. 'quotesingle',
  37143. 'parenleft',
  37144. 'parenright',
  37145. 'asterisk',
  37146. 'plus',
  37147. 'comma',
  37148. 'hyphen',
  37149. 'period',
  37150. 'slash',
  37151. 'zero',
  37152. 'one',
  37153. 'two',
  37154. 'three',
  37155. 'four',
  37156. 'five',
  37157. 'six',
  37158. 'seven',
  37159. 'eight',
  37160. 'nine',
  37161. 'colon',
  37162. 'semicolon',
  37163. 'less',
  37164. 'equal',
  37165. 'greater',
  37166. 'question',
  37167. 'at',
  37168. 'A',
  37169. 'B',
  37170. 'C',
  37171. 'D',
  37172. 'E',
  37173. 'F',
  37174. 'G',
  37175. 'H',
  37176. 'I',
  37177. 'J',
  37178. 'K',
  37179. 'L',
  37180. 'M',
  37181. 'N',
  37182. 'O',
  37183. 'P',
  37184. 'Q',
  37185. 'R',
  37186. 'S',
  37187. 'T',
  37188. 'U',
  37189. 'V',
  37190. 'W',
  37191. 'X',
  37192. 'Y',
  37193. 'Z',
  37194. 'bracketleft',
  37195. 'backslash',
  37196. 'bracketright',
  37197. 'asciicircum',
  37198. 'underscore',
  37199. 'grave',
  37200. 'a',
  37201. 'b',
  37202. 'c',
  37203. 'd',
  37204. 'e',
  37205. 'f',
  37206. 'g',
  37207. 'h',
  37208. 'i',
  37209. 'j',
  37210. 'k',
  37211. 'l',
  37212. 'm',
  37213. 'n',
  37214. 'o',
  37215. 'p',
  37216. 'q',
  37217. 'r',
  37218. 's',
  37219. 't',
  37220. 'u',
  37221. 'v',
  37222. 'w',
  37223. 'x',
  37224. 'y',
  37225. 'z',
  37226. 'braceleft',
  37227. 'bar',
  37228. 'braceright',
  37229. 'asciitilde',
  37230. 'Adieresis',
  37231. 'Aring',
  37232. 'Ccedilla',
  37233. 'Eacute',
  37234. 'Ntilde',
  37235. 'Odieresis',
  37236. 'Udieresis',
  37237. 'aacute',
  37238. 'agrave',
  37239. 'acircumflex',
  37240. 'adieresis',
  37241. 'atilde',
  37242. 'aring',
  37243. 'ccedilla',
  37244. 'eacute',
  37245. 'egrave',
  37246. 'ecircumflex',
  37247. 'edieresis',
  37248. 'iacute',
  37249. 'igrave',
  37250. 'icircumflex',
  37251. 'idieresis',
  37252. 'ntilde',
  37253. 'oacute',
  37254. 'ograve',
  37255. 'ocircumflex',
  37256. 'odieresis',
  37257. 'otilde',
  37258. 'uacute',
  37259. 'ugrave',
  37260. 'ucircumflex',
  37261. 'udieresis',
  37262. 'dagger',
  37263. 'degree',
  37264. 'cent',
  37265. 'sterling',
  37266. 'section',
  37267. 'bullet',
  37268. 'paragraph',
  37269. 'germandbls',
  37270. 'registered',
  37271. 'copyright',
  37272. 'trademark',
  37273. 'acute',
  37274. 'dieresis',
  37275. 'notequal',
  37276. 'AE',
  37277. 'Oslash',
  37278. 'infinity',
  37279. 'plusminus',
  37280. 'lessequal',
  37281. 'greaterequal',
  37282. 'yen',
  37283. 'mu',
  37284. 'partialdiff',
  37285. 'summation',
  37286. 'product',
  37287. 'pi',
  37288. 'integral',
  37289. 'ordfeminine',
  37290. 'ordmasculine',
  37291. 'Omega',
  37292. 'ae',
  37293. 'oslash',
  37294. 'questiondown',
  37295. 'exclamdown',
  37296. 'logicalnot',
  37297. 'radical',
  37298. 'florin',
  37299. 'approxequal',
  37300. 'Delta',
  37301. 'guillemotleft',
  37302. 'guillemotright',
  37303. 'ellipsis',
  37304. 'nonbreakingspace',
  37305. 'Agrave',
  37306. 'Atilde',
  37307. 'Otilde',
  37308. 'OE',
  37309. 'oe',
  37310. 'endash',
  37311. 'emdash',
  37312. 'quotedblleft',
  37313. 'quotedblright',
  37314. 'quoteleft',
  37315. 'quoteright',
  37316. 'divide',
  37317. 'lozenge',
  37318. 'ydieresis',
  37319. 'Ydieresis',
  37320. 'fraction',
  37321. 'currency',
  37322. 'guilsinglleft',
  37323. 'guilsinglright',
  37324. 'fi',
  37325. 'fl',
  37326. 'daggerdbl',
  37327. 'periodcentered',
  37328. 'quotesinglbase',
  37329. 'quotedblbase',
  37330. 'perthousand',
  37331. 'Acircumflex',
  37332. 'Ecircumflex',
  37333. 'Aacute',
  37334. 'Edieresis',
  37335. 'Egrave',
  37336. 'Iacute',
  37337. 'Icircumflex',
  37338. 'Idieresis',
  37339. 'Igrave',
  37340. 'Oacute',
  37341. 'Ocircumflex',
  37342. 'apple',
  37343. 'Ograve',
  37344. 'Uacute',
  37345. 'Ucircumflex',
  37346. 'Ugrave',
  37347. 'dotlessi',
  37348. 'circumflex',
  37349. 'tilde',
  37350. 'macron',
  37351. 'breve',
  37352. 'dotaccent',
  37353. 'ring',
  37354. 'cedilla',
  37355. 'hungarumlaut',
  37356. 'ogonek',
  37357. 'caron',
  37358. 'Lslash',
  37359. 'lslash',
  37360. 'Scaron',
  37361. 'scaron',
  37362. 'Zcaron',
  37363. 'zcaron',
  37364. 'brokenbar',
  37365. 'Eth',
  37366. 'eth',
  37367. 'Yacute',
  37368. 'yacute',
  37369. 'Thorn',
  37370. 'thorn',
  37371. 'minus',
  37372. 'multiply',
  37373. 'onesuperior',
  37374. 'twosuperior',
  37375. 'threesuperior',
  37376. 'onehalf',
  37377. 'onequarter',
  37378. 'threequarters',
  37379. 'franc',
  37380. 'Gbreve',
  37381. 'gbreve',
  37382. 'Idotaccent',
  37383. 'Scedilla',
  37384. 'scedilla',
  37385. 'Cacute',
  37386. 'cacute',
  37387. 'Ccaron',
  37388. 'ccaron',
  37389. 'dcroat'
  37390. ];
  37391. function adjustWidths(properties) {
  37392. if (!properties.fontMatrix) {
  37393. return;
  37394. }
  37395. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  37396. return;
  37397. }
  37398. var scale = 0.001 / properties.fontMatrix[0];
  37399. var glyphsWidths = properties.widths;
  37400. for (var glyph in glyphsWidths) {
  37401. glyphsWidths[glyph] *= scale;
  37402. }
  37403. properties.defaultWidth *= scale;
  37404. }
  37405. function adjustToUnicode(properties, builtInEncoding) {
  37406. if (properties.hasIncludedToUnicodeMap) {
  37407. return;
  37408. }
  37409. if (properties.hasEncoding) {
  37410. return;
  37411. }
  37412. if (builtInEncoding === properties.defaultEncoding) {
  37413. return;
  37414. }
  37415. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  37416. return;
  37417. }
  37418. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  37419. for (var charCode in builtInEncoding) {
  37420. var glyphName = builtInEncoding[charCode];
  37421. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  37422. if (unicode !== -1) {
  37423. toUnicode[charCode] = String.fromCharCode(unicode);
  37424. }
  37425. }
  37426. properties.toUnicode.amend(toUnicode);
  37427. }
  37428. function getFontType(type, subtype) {
  37429. switch (type) {
  37430. case 'Type1':
  37431. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  37432. case 'CIDFontType0':
  37433. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  37434. case 'OpenType':
  37435. return FontType.OPENTYPE;
  37436. case 'TrueType':
  37437. return FontType.TRUETYPE;
  37438. case 'CIDFontType2':
  37439. return FontType.CIDFONTTYPE2;
  37440. case 'MMType1':
  37441. return FontType.MMTYPE1;
  37442. case 'Type0':
  37443. return FontType.TYPE0;
  37444. default:
  37445. return FontType.UNKNOWN;
  37446. }
  37447. }
  37448. function recoverGlyphName(name, glyphsUnicodeMap) {
  37449. if (glyphsUnicodeMap[name] !== undefined) {
  37450. return name;
  37451. }
  37452. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  37453. if (unicode !== -1) {
  37454. for (var key in glyphsUnicodeMap) {
  37455. if (glyphsUnicodeMap[key] === unicode) {
  37456. return key;
  37457. }
  37458. }
  37459. }
  37460. info('Unable to recover a standard glyph name for: ' + name);
  37461. return name;
  37462. }
  37463. var Glyph = function GlyphClosure() {
  37464. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  37465. this.fontChar = fontChar;
  37466. this.unicode = unicode;
  37467. this.accent = accent;
  37468. this.width = width;
  37469. this.vmetric = vmetric;
  37470. this.operatorListId = operatorListId;
  37471. this.isSpace = isSpace;
  37472. this.isInFont = isInFont;
  37473. }
  37474. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  37475. 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;
  37476. };
  37477. return Glyph;
  37478. }();
  37479. var ToUnicodeMap = function ToUnicodeMapClosure() {
  37480. function ToUnicodeMap(cmap) {
  37481. this._map = cmap;
  37482. }
  37483. ToUnicodeMap.prototype = {
  37484. get length() {
  37485. return this._map.length;
  37486. },
  37487. forEach: function (callback) {
  37488. for (var charCode in this._map) {
  37489. callback(charCode, this._map[charCode].charCodeAt(0));
  37490. }
  37491. },
  37492. has: function (i) {
  37493. return this._map[i] !== undefined;
  37494. },
  37495. get: function (i) {
  37496. return this._map[i];
  37497. },
  37498. charCodeOf: function (v) {
  37499. return this._map.indexOf(v);
  37500. },
  37501. amend: function (map) {
  37502. for (var charCode in map) {
  37503. this._map[charCode] = map[charCode];
  37504. }
  37505. }
  37506. };
  37507. return ToUnicodeMap;
  37508. }();
  37509. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  37510. function IdentityToUnicodeMap(firstChar, lastChar) {
  37511. this.firstChar = firstChar;
  37512. this.lastChar = lastChar;
  37513. }
  37514. IdentityToUnicodeMap.prototype = {
  37515. get length() {
  37516. return this.lastChar + 1 - this.firstChar;
  37517. },
  37518. forEach: function (callback) {
  37519. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  37520. callback(i, i);
  37521. }
  37522. },
  37523. has: function (i) {
  37524. return this.firstChar <= i && i <= this.lastChar;
  37525. },
  37526. get: function (i) {
  37527. if (this.firstChar <= i && i <= this.lastChar) {
  37528. return String.fromCharCode(i);
  37529. }
  37530. return undefined;
  37531. },
  37532. charCodeOf: function (v) {
  37533. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  37534. },
  37535. amend: function (map) {
  37536. error('Should not call amend()');
  37537. }
  37538. };
  37539. return IdentityToUnicodeMap;
  37540. }();
  37541. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  37542. function writeInt16(dest, offset, num) {
  37543. dest[offset] = num >> 8 & 0xFF;
  37544. dest[offset + 1] = num & 0xFF;
  37545. }
  37546. function writeInt32(dest, offset, num) {
  37547. dest[offset] = num >> 24 & 0xFF;
  37548. dest[offset + 1] = num >> 16 & 0xFF;
  37549. dest[offset + 2] = num >> 8 & 0xFF;
  37550. dest[offset + 3] = num & 0xFF;
  37551. }
  37552. function writeData(dest, offset, data) {
  37553. var i, ii;
  37554. if (data instanceof Uint8Array) {
  37555. dest.set(data, offset);
  37556. } else if (typeof data === 'string') {
  37557. for (i = 0, ii = data.length; i < ii; i++) {
  37558. dest[offset++] = data.charCodeAt(i) & 0xFF;
  37559. }
  37560. } else {
  37561. for (i = 0, ii = data.length; i < ii; i++) {
  37562. dest[offset++] = data[i] & 0xFF;
  37563. }
  37564. }
  37565. }
  37566. function OpenTypeFileBuilder(sfnt) {
  37567. this.sfnt = sfnt;
  37568. this.tables = Object.create(null);
  37569. }
  37570. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  37571. var maxPower2 = 1, log2 = 0;
  37572. while ((maxPower2 ^ entriesCount) > maxPower2) {
  37573. maxPower2 <<= 1;
  37574. log2++;
  37575. }
  37576. var searchRange = maxPower2 * entrySize;
  37577. return {
  37578. range: searchRange,
  37579. entry: log2,
  37580. rangeShift: entrySize * entriesCount - searchRange
  37581. };
  37582. };
  37583. var OTF_HEADER_SIZE = 12;
  37584. var OTF_TABLE_ENTRY_SIZE = 16;
  37585. OpenTypeFileBuilder.prototype = {
  37586. toArray: function OpenTypeFileBuilder_toArray() {
  37587. var sfnt = this.sfnt;
  37588. var tables = this.tables;
  37589. var tablesNames = Object.keys(tables);
  37590. tablesNames.sort();
  37591. var numTables = tablesNames.length;
  37592. var i, j, jj, table, tableName;
  37593. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  37594. var tableOffsets = [offset];
  37595. for (i = 0; i < numTables; i++) {
  37596. table = tables[tablesNames[i]];
  37597. var paddedLength = (table.length + 3 & ~3) >>> 0;
  37598. offset += paddedLength;
  37599. tableOffsets.push(offset);
  37600. }
  37601. var file = new Uint8Array(offset);
  37602. for (i = 0; i < numTables; i++) {
  37603. table = tables[tablesNames[i]];
  37604. writeData(file, tableOffsets[i], table);
  37605. }
  37606. if (sfnt === 'true') {
  37607. sfnt = string32(0x00010000);
  37608. }
  37609. file[0] = sfnt.charCodeAt(0) & 0xFF;
  37610. file[1] = sfnt.charCodeAt(1) & 0xFF;
  37611. file[2] = sfnt.charCodeAt(2) & 0xFF;
  37612. file[3] = sfnt.charCodeAt(3) & 0xFF;
  37613. writeInt16(file, 4, numTables);
  37614. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  37615. writeInt16(file, 6, searchParams.range);
  37616. writeInt16(file, 8, searchParams.entry);
  37617. writeInt16(file, 10, searchParams.rangeShift);
  37618. offset = OTF_HEADER_SIZE;
  37619. for (i = 0; i < numTables; i++) {
  37620. tableName = tablesNames[i];
  37621. file[offset] = tableName.charCodeAt(0) & 0xFF;
  37622. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  37623. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  37624. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  37625. var checksum = 0;
  37626. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  37627. var quad = readUint32(file, j);
  37628. checksum = checksum + quad >>> 0;
  37629. }
  37630. writeInt32(file, offset + 4, checksum);
  37631. writeInt32(file, offset + 8, tableOffsets[i]);
  37632. writeInt32(file, offset + 12, tables[tableName].length);
  37633. offset += OTF_TABLE_ENTRY_SIZE;
  37634. }
  37635. return file;
  37636. },
  37637. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  37638. if (tag in this.tables) {
  37639. throw new Error('Table ' + tag + ' already exists');
  37640. }
  37641. this.tables[tag] = data;
  37642. }
  37643. };
  37644. return OpenTypeFileBuilder;
  37645. }();
  37646. var ProblematicCharRanges = new Int32Array([
  37647. 0x0000,
  37648. 0x0020,
  37649. 0x007F,
  37650. 0x00A1,
  37651. 0x00AD,
  37652. 0x00AE,
  37653. 0x0600,
  37654. 0x0780,
  37655. 0x08A0,
  37656. 0x10A0,
  37657. 0x1780,
  37658. 0x1800,
  37659. 0x1C00,
  37660. 0x1C50,
  37661. 0x2000,
  37662. 0x2010,
  37663. 0x2011,
  37664. 0x2012,
  37665. 0x2028,
  37666. 0x2030,
  37667. 0x205F,
  37668. 0x2070,
  37669. 0x25CC,
  37670. 0x25CD,
  37671. 0x3000,
  37672. 0x3001,
  37673. 0xAA60,
  37674. 0xAA80,
  37675. 0xFFF0,
  37676. 0x10000
  37677. ]);
  37678. var Font = function FontClosure() {
  37679. function Font(name, file, properties) {
  37680. var charCode, glyphName, unicode;
  37681. this.name = name;
  37682. this.loadedName = properties.loadedName;
  37683. this.isType3Font = properties.isType3Font;
  37684. this.sizes = [];
  37685. this.missingFile = false;
  37686. this.glyphCache = Object.create(null);
  37687. var names = name.split('+');
  37688. names = names.length > 1 ? names[1] : names[0];
  37689. names = names.split(/[-,_]/g)[0];
  37690. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  37691. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  37692. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  37693. var type = properties.type;
  37694. var subtype = properties.subtype;
  37695. this.type = type;
  37696. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  37697. this.differences = properties.differences;
  37698. this.widths = properties.widths;
  37699. this.defaultWidth = properties.defaultWidth;
  37700. this.composite = properties.composite;
  37701. this.wideChars = properties.wideChars;
  37702. this.cMap = properties.cMap;
  37703. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  37704. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  37705. this.fontMatrix = properties.fontMatrix;
  37706. this.bbox = properties.bbox;
  37707. this.toUnicode = properties.toUnicode;
  37708. this.toFontChar = [];
  37709. if (properties.type === 'Type3') {
  37710. for (charCode = 0; charCode < 256; charCode++) {
  37711. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  37712. }
  37713. this.fontType = FontType.TYPE3;
  37714. return;
  37715. }
  37716. this.cidEncoding = properties.cidEncoding;
  37717. this.vertical = properties.vertical;
  37718. if (this.vertical) {
  37719. this.vmetrics = properties.vmetrics;
  37720. this.defaultVMetrics = properties.defaultVMetrics;
  37721. }
  37722. var glyphsUnicodeMap;
  37723. if (!file || file.isEmpty) {
  37724. if (file) {
  37725. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  37726. }
  37727. this.missingFile = true;
  37728. var fontName = name.replace(/[,_]/g, '-');
  37729. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  37730. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  37731. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  37732. this.bold = fontName.search(/bold/gi) !== -1;
  37733. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  37734. this.black = name.search(/Black/g) !== -1;
  37735. this.remeasure = Object.keys(this.widths).length > 0;
  37736. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  37737. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  37738. var map = [];
  37739. for (charCode in GlyphMapForStandardFonts) {
  37740. map[+charCode] = GlyphMapForStandardFonts[charCode];
  37741. }
  37742. if (/Arial-?Black/i.test(name)) {
  37743. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  37744. for (charCode in SupplementalGlyphMapForArialBlack) {
  37745. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  37746. }
  37747. }
  37748. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  37749. if (!isIdentityUnicode) {
  37750. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  37751. map[+charCode] = unicodeCharCode;
  37752. });
  37753. }
  37754. this.toFontChar = map;
  37755. this.toUnicode = new ToUnicodeMap(map);
  37756. } else if (/Symbol/i.test(fontName)) {
  37757. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  37758. } else if (/Dingbats/i.test(fontName)) {
  37759. if (/Wingdings/i.test(name)) {
  37760. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  37761. }
  37762. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  37763. } else if (isStandardFont) {
  37764. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  37765. } else {
  37766. glyphsUnicodeMap = getGlyphsUnicode();
  37767. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  37768. if (!this.composite) {
  37769. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  37770. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  37771. if (unicode !== -1) {
  37772. unicodeCharCode = unicode;
  37773. }
  37774. }
  37775. this.toFontChar[charCode] = unicodeCharCode;
  37776. }.bind(this));
  37777. }
  37778. this.loadedName = fontName.split('-')[0];
  37779. this.loading = false;
  37780. this.fontType = getFontType(type, subtype);
  37781. return;
  37782. }
  37783. if (subtype === 'Type1C') {
  37784. if (type !== 'Type1' && type !== 'MMType1') {
  37785. if (isTrueTypeFile(file)) {
  37786. subtype = 'TrueType';
  37787. } else {
  37788. type = 'Type1';
  37789. }
  37790. } else if (isOpenTypeFile(file)) {
  37791. type = subtype = 'OpenType';
  37792. }
  37793. }
  37794. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  37795. type = 'CIDFontType0';
  37796. }
  37797. if (subtype === 'OpenType') {
  37798. type = 'OpenType';
  37799. }
  37800. if (type === 'CIDFontType0') {
  37801. if (isType1File(file)) {
  37802. subtype = 'CIDFontType0';
  37803. } else if (isOpenTypeFile(file)) {
  37804. type = subtype = 'OpenType';
  37805. } else {
  37806. subtype = 'CIDFontType0C';
  37807. }
  37808. }
  37809. var data;
  37810. switch (type) {
  37811. case 'MMType1':
  37812. info('MMType1 font (' + name + '), falling back to Type1.');
  37813. case 'Type1':
  37814. case 'CIDFontType0':
  37815. this.mimetype = 'font/opentype';
  37816. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  37817. adjustWidths(properties);
  37818. data = this.convert(name, cff, properties);
  37819. break;
  37820. case 'OpenType':
  37821. case 'TrueType':
  37822. case 'CIDFontType2':
  37823. this.mimetype = 'font/opentype';
  37824. data = this.checkAndRepair(name, file, properties);
  37825. if (this.isOpenType) {
  37826. adjustWidths(properties);
  37827. type = 'OpenType';
  37828. }
  37829. break;
  37830. default:
  37831. error('Font ' + type + ' is not supported');
  37832. break;
  37833. }
  37834. this.data = data;
  37835. this.fontType = getFontType(type, subtype);
  37836. this.fontMatrix = properties.fontMatrix;
  37837. this.widths = properties.widths;
  37838. this.defaultWidth = properties.defaultWidth;
  37839. this.toUnicode = properties.toUnicode;
  37840. this.encoding = properties.baseEncoding;
  37841. this.seacMap = properties.seacMap;
  37842. this.loading = true;
  37843. }
  37844. Font.getFontID = function () {
  37845. var ID = 1;
  37846. return function Font_getFontID() {
  37847. return String(ID++);
  37848. };
  37849. }();
  37850. function int16(b0, b1) {
  37851. return (b0 << 8) + b1;
  37852. }
  37853. function signedInt16(b0, b1) {
  37854. var value = (b0 << 8) + b1;
  37855. return value & 1 << 15 ? value - 0x10000 : value;
  37856. }
  37857. function int32(b0, b1, b2, b3) {
  37858. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  37859. }
  37860. function string16(value) {
  37861. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  37862. }
  37863. function safeString16(value) {
  37864. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  37865. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  37866. }
  37867. function isTrueTypeFile(file) {
  37868. var header = file.peekBytes(4);
  37869. return readUint32(header, 0) === 0x00010000;
  37870. }
  37871. function isOpenTypeFile(file) {
  37872. var header = file.peekBytes(4);
  37873. return bytesToString(header) === 'OTTO';
  37874. }
  37875. function isType1File(file) {
  37876. var header = file.peekBytes(2);
  37877. if (header[0] === 0x25 && header[1] === 0x21) {
  37878. return true;
  37879. }
  37880. if (header[0] === 0x80 && header[1] === 0x01) {
  37881. return true;
  37882. }
  37883. return false;
  37884. }
  37885. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  37886. var toFontChar = [], unicode;
  37887. for (var i = 0, ii = encoding.length; i < ii; i++) {
  37888. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  37889. if (unicode !== -1) {
  37890. toFontChar[i] = unicode;
  37891. }
  37892. }
  37893. for (var charCode in differences) {
  37894. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  37895. if (unicode !== -1) {
  37896. toFontChar[+charCode] = unicode;
  37897. }
  37898. }
  37899. return toFontChar;
  37900. }
  37901. function isProblematicUnicodeLocation(code) {
  37902. var i = 0, j = ProblematicCharRanges.length - 1;
  37903. while (i < j) {
  37904. var c = i + j + 1 >> 1;
  37905. if (code < ProblematicCharRanges[c]) {
  37906. j = c - 1;
  37907. } else {
  37908. i = c;
  37909. }
  37910. }
  37911. return !(i & 1);
  37912. }
  37913. function adjustMapping(charCodeToGlyphId, properties) {
  37914. var toUnicode = properties.toUnicode;
  37915. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  37916. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  37917. var newMap = Object.create(null);
  37918. var toFontChar = [];
  37919. var usedFontCharCodes = [];
  37920. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  37921. for (var originalCharCode in charCodeToGlyphId) {
  37922. originalCharCode |= 0;
  37923. var glyphId = charCodeToGlyphId[originalCharCode];
  37924. var fontCharCode = originalCharCode;
  37925. var hasUnicodeValue = false;
  37926. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  37927. hasUnicodeValue = true;
  37928. var unicode = toUnicode.get(fontCharCode);
  37929. if (unicode.length === 1) {
  37930. fontCharCode = unicode.charCodeAt(0);
  37931. }
  37932. }
  37933. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && !hasUnicodeValue) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  37934. do {
  37935. fontCharCode = nextAvailableFontCharCode++;
  37936. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  37937. fontCharCode = 0xF020;
  37938. nextAvailableFontCharCode = fontCharCode + 1;
  37939. }
  37940. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  37941. }
  37942. newMap[fontCharCode] = glyphId;
  37943. toFontChar[originalCharCode] = fontCharCode;
  37944. usedFontCharCodes[fontCharCode] = true;
  37945. }
  37946. return {
  37947. toFontChar: toFontChar,
  37948. charCodeToGlyphId: newMap,
  37949. nextAvailableFontCharCode: nextAvailableFontCharCode
  37950. };
  37951. }
  37952. function getRanges(glyphs, numGlyphs) {
  37953. var codes = [];
  37954. for (var charCode in glyphs) {
  37955. if (glyphs[charCode] >= numGlyphs) {
  37956. continue;
  37957. }
  37958. codes.push({
  37959. fontCharCode: charCode | 0,
  37960. glyphId: glyphs[charCode]
  37961. });
  37962. }
  37963. codes.sort(function fontGetRangesSort(a, b) {
  37964. return a.fontCharCode - b.fontCharCode;
  37965. });
  37966. var ranges = [];
  37967. var length = codes.length;
  37968. for (var n = 0; n < length;) {
  37969. var start = codes[n].fontCharCode;
  37970. var codeIndices = [codes[n].glyphId];
  37971. ++n;
  37972. var end = start;
  37973. while (n < length && end + 1 === codes[n].fontCharCode) {
  37974. codeIndices.push(codes[n].glyphId);
  37975. ++end;
  37976. ++n;
  37977. if (end === 0xFFFF) {
  37978. break;
  37979. }
  37980. }
  37981. ranges.push([
  37982. start,
  37983. end,
  37984. codeIndices
  37985. ]);
  37986. }
  37987. return ranges;
  37988. }
  37989. function createCmapTable(glyphs, numGlyphs) {
  37990. var ranges = getRanges(glyphs, numGlyphs);
  37991. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  37992. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  37993. var i, ii, j, jj;
  37994. for (i = ranges.length - 1; i >= 0; --i) {
  37995. if (ranges[i][0] <= 0xFFFF) {
  37996. break;
  37997. }
  37998. }
  37999. var bmpLength = i + 1;
  38000. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  38001. ranges[i][1] = 0xFFFE;
  38002. }
  38003. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  38004. var segCount = bmpLength + trailingRangesCount;
  38005. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  38006. var startCount = '';
  38007. var endCount = '';
  38008. var idDeltas = '';
  38009. var idRangeOffsets = '';
  38010. var glyphsIds = '';
  38011. var bias = 0;
  38012. var range, start, end, codes;
  38013. for (i = 0, ii = bmpLength; i < ii; i++) {
  38014. range = ranges[i];
  38015. start = range[0];
  38016. end = range[1];
  38017. startCount += string16(start);
  38018. endCount += string16(end);
  38019. codes = range[2];
  38020. var contiguous = true;
  38021. for (j = 1, jj = codes.length; j < jj; ++j) {
  38022. if (codes[j] !== codes[j - 1] + 1) {
  38023. contiguous = false;
  38024. break;
  38025. }
  38026. }
  38027. if (!contiguous) {
  38028. var offset = (segCount - i) * 2 + bias * 2;
  38029. bias += end - start + 1;
  38030. idDeltas += string16(0);
  38031. idRangeOffsets += string16(offset);
  38032. for (j = 0, jj = codes.length; j < jj; ++j) {
  38033. glyphsIds += string16(codes[j]);
  38034. }
  38035. } else {
  38036. var startCode = codes[0];
  38037. idDeltas += string16(startCode - start & 0xFFFF);
  38038. idRangeOffsets += string16(0);
  38039. }
  38040. }
  38041. if (trailingRangesCount > 0) {
  38042. endCount += '\xFF\xFF';
  38043. startCount += '\xFF\xFF';
  38044. idDeltas += '\x00\x01';
  38045. idRangeOffsets += '\x00\x00';
  38046. }
  38047. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  38048. var format31012 = '';
  38049. var header31012 = '';
  38050. if (numTables > 1) {
  38051. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  38052. format31012 = '';
  38053. for (i = 0, ii = ranges.length; i < ii; i++) {
  38054. range = ranges[i];
  38055. start = range[0];
  38056. codes = range[2];
  38057. var code = codes[0];
  38058. for (j = 1, jj = codes.length; j < jj; ++j) {
  38059. if (codes[j] !== codes[j - 1] + 1) {
  38060. end = range[0] + j - 1;
  38061. format31012 += string32(start) + string32(end) + string32(code);
  38062. start = end + 1;
  38063. code = codes[j];
  38064. }
  38065. }
  38066. format31012 += string32(start) + string32(range[1]) + string32(code);
  38067. }
  38068. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  38069. }
  38070. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  38071. }
  38072. function validateOS2Table(os2) {
  38073. var stream = new Stream(os2.data);
  38074. var version = stream.getUint16();
  38075. stream.getBytes(60);
  38076. var selection = stream.getUint16();
  38077. if (version < 4 && selection & 0x0300) {
  38078. return false;
  38079. }
  38080. var firstChar = stream.getUint16();
  38081. var lastChar = stream.getUint16();
  38082. if (firstChar > lastChar) {
  38083. return false;
  38084. }
  38085. stream.getBytes(6);
  38086. var usWinAscent = stream.getUint16();
  38087. if (usWinAscent === 0) {
  38088. return false;
  38089. }
  38090. os2.data[8] = os2.data[9] = 0;
  38091. return true;
  38092. }
  38093. function createOS2Table(properties, charstrings, override) {
  38094. override = override || {
  38095. unitsPerEm: 0,
  38096. yMax: 0,
  38097. yMin: 0,
  38098. ascent: 0,
  38099. descent: 0
  38100. };
  38101. var ulUnicodeRange1 = 0;
  38102. var ulUnicodeRange2 = 0;
  38103. var ulUnicodeRange3 = 0;
  38104. var ulUnicodeRange4 = 0;
  38105. var firstCharIndex = null;
  38106. var lastCharIndex = 0;
  38107. if (charstrings) {
  38108. for (var code in charstrings) {
  38109. code |= 0;
  38110. if (firstCharIndex > code || !firstCharIndex) {
  38111. firstCharIndex = code;
  38112. }
  38113. if (lastCharIndex < code) {
  38114. lastCharIndex = code;
  38115. }
  38116. var position = getUnicodeRangeFor(code);
  38117. if (position < 32) {
  38118. ulUnicodeRange1 |= 1 << position;
  38119. } else if (position < 64) {
  38120. ulUnicodeRange2 |= 1 << position - 32;
  38121. } else if (position < 96) {
  38122. ulUnicodeRange3 |= 1 << position - 64;
  38123. } else if (position < 123) {
  38124. ulUnicodeRange4 |= 1 << position - 96;
  38125. } else {
  38126. error('Unicode ranges Bits > 123 are reserved for internal usage');
  38127. }
  38128. }
  38129. } else {
  38130. firstCharIndex = 0;
  38131. lastCharIndex = 255;
  38132. }
  38133. var bbox = properties.bbox || [
  38134. 0,
  38135. 0,
  38136. 0,
  38137. 0
  38138. ];
  38139. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  38140. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  38141. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  38142. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  38143. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  38144. typoDescent = -typoDescent;
  38145. }
  38146. var winAscent = override.yMax || typoAscent;
  38147. var winDescent = -override.yMin || -typoDescent;
  38148. 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';
  38149. }
  38150. function createPostTable(properties) {
  38151. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  38152. 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';
  38153. }
  38154. function createNameTable(name, proto) {
  38155. if (!proto) {
  38156. proto = [
  38157. [],
  38158. []
  38159. ];
  38160. }
  38161. var strings = [
  38162. proto[0][0] || 'Original licence',
  38163. proto[0][1] || name,
  38164. proto[0][2] || 'Unknown',
  38165. proto[0][3] || 'uniqueID',
  38166. proto[0][4] || name,
  38167. proto[0][5] || 'Version 0.11',
  38168. proto[0][6] || '',
  38169. proto[0][7] || 'Unknown',
  38170. proto[0][8] || 'Unknown',
  38171. proto[0][9] || 'Unknown'
  38172. ];
  38173. var stringsUnicode = [];
  38174. var i, ii, j, jj, str;
  38175. for (i = 0, ii = strings.length; i < ii; i++) {
  38176. str = proto[1][i] || strings[i];
  38177. var strBufUnicode = [];
  38178. for (j = 0, jj = str.length; j < jj; j++) {
  38179. strBufUnicode.push(string16(str.charCodeAt(j)));
  38180. }
  38181. stringsUnicode.push(strBufUnicode.join(''));
  38182. }
  38183. var names = [
  38184. strings,
  38185. stringsUnicode
  38186. ];
  38187. var platforms = [
  38188. '\x00\x01',
  38189. '\x00\x03'
  38190. ];
  38191. var encodings = [
  38192. '\x00\x00',
  38193. '\x00\x01'
  38194. ];
  38195. var languages = [
  38196. '\x00\x00',
  38197. '\x04\x09'
  38198. ];
  38199. var namesRecordCount = strings.length * platforms.length;
  38200. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  38201. var strOffset = 0;
  38202. for (i = 0, ii = platforms.length; i < ii; i++) {
  38203. var strs = names[i];
  38204. for (j = 0, jj = strs.length; j < jj; j++) {
  38205. str = strs[j];
  38206. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  38207. nameTable += nameRecord;
  38208. strOffset += str.length;
  38209. }
  38210. }
  38211. nameTable += strings.join('') + stringsUnicode.join('');
  38212. return nameTable;
  38213. }
  38214. Font.prototype = {
  38215. name: null,
  38216. font: null,
  38217. mimetype: null,
  38218. encoding: null,
  38219. get renderer() {
  38220. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  38221. return shadow(this, 'renderer', renderer);
  38222. },
  38223. exportData: function Font_exportData() {
  38224. var data = {};
  38225. for (var i in this) {
  38226. if (this.hasOwnProperty(i)) {
  38227. data[i] = this[i];
  38228. }
  38229. }
  38230. return data;
  38231. },
  38232. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  38233. function readTableEntry(file) {
  38234. var tag = bytesToString(file.getBytes(4));
  38235. var checksum = file.getInt32() >>> 0;
  38236. var offset = file.getInt32() >>> 0;
  38237. var length = file.getInt32() >>> 0;
  38238. var previousPosition = file.pos;
  38239. file.pos = file.start ? file.start : 0;
  38240. file.skip(offset);
  38241. var data = file.getBytes(length);
  38242. file.pos = previousPosition;
  38243. if (tag === 'head') {
  38244. data[8] = data[9] = data[10] = data[11] = 0;
  38245. data[17] |= 0x20;
  38246. }
  38247. return {
  38248. tag: tag,
  38249. checksum: checksum,
  38250. length: length,
  38251. offset: offset,
  38252. data: data
  38253. };
  38254. }
  38255. function readOpenTypeHeader(ttf) {
  38256. return {
  38257. version: bytesToString(ttf.getBytes(4)),
  38258. numTables: ttf.getUint16(),
  38259. searchRange: ttf.getUint16(),
  38260. entrySelector: ttf.getUint16(),
  38261. rangeShift: ttf.getUint16()
  38262. };
  38263. }
  38264. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  38265. if (!cmap) {
  38266. warn('No cmap table available.');
  38267. return {
  38268. platformId: -1,
  38269. encodingId: -1,
  38270. mappings: [],
  38271. hasShortCmap: false
  38272. };
  38273. }
  38274. var segment;
  38275. var start = (font.start ? font.start : 0) + cmap.offset;
  38276. font.pos = start;
  38277. var version = font.getUint16();
  38278. var numTables = font.getUint16();
  38279. var potentialTable;
  38280. var canBreak = false;
  38281. for (var i = 0; i < numTables; i++) {
  38282. var platformId = font.getUint16();
  38283. var encodingId = font.getUint16();
  38284. var offset = font.getInt32() >>> 0;
  38285. var useTable = false;
  38286. if (platformId === 0 && encodingId === 0) {
  38287. useTable = true;
  38288. } else if (platformId === 1 && encodingId === 0) {
  38289. useTable = true;
  38290. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  38291. useTable = true;
  38292. if (!isSymbolicFont) {
  38293. canBreak = true;
  38294. }
  38295. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  38296. useTable = true;
  38297. canBreak = true;
  38298. }
  38299. if (useTable) {
  38300. potentialTable = {
  38301. platformId: platformId,
  38302. encodingId: encodingId,
  38303. offset: offset
  38304. };
  38305. }
  38306. if (canBreak) {
  38307. break;
  38308. }
  38309. }
  38310. if (potentialTable) {
  38311. font.pos = start + potentialTable.offset;
  38312. }
  38313. if (!potentialTable || font.peekByte() === -1) {
  38314. warn('Could not find a preferred cmap table.');
  38315. return {
  38316. platformId: -1,
  38317. encodingId: -1,
  38318. mappings: [],
  38319. hasShortCmap: false
  38320. };
  38321. }
  38322. var format = font.getUint16();
  38323. var length = font.getUint16();
  38324. var language = font.getUint16();
  38325. var hasShortCmap = false;
  38326. var mappings = [];
  38327. var j, glyphId;
  38328. if (format === 0) {
  38329. for (j = 0; j < 256; j++) {
  38330. var index = font.getByte();
  38331. if (!index) {
  38332. continue;
  38333. }
  38334. mappings.push({
  38335. charCode: j,
  38336. glyphId: index
  38337. });
  38338. }
  38339. hasShortCmap = true;
  38340. } else if (format === 4) {
  38341. var segCount = font.getUint16() >> 1;
  38342. font.getBytes(6);
  38343. var segIndex, segments = [];
  38344. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38345. segments.push({ end: font.getUint16() });
  38346. }
  38347. font.getUint16();
  38348. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38349. segments[segIndex].start = font.getUint16();
  38350. }
  38351. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38352. segments[segIndex].delta = font.getUint16();
  38353. }
  38354. var offsetsCount = 0;
  38355. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38356. segment = segments[segIndex];
  38357. var rangeOffset = font.getUint16();
  38358. if (!rangeOffset) {
  38359. segment.offsetIndex = -1;
  38360. continue;
  38361. }
  38362. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  38363. segment.offsetIndex = offsetIndex;
  38364. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  38365. }
  38366. var offsets = [];
  38367. for (j = 0; j < offsetsCount; j++) {
  38368. offsets.push(font.getUint16());
  38369. }
  38370. for (segIndex = 0; segIndex < segCount; segIndex++) {
  38371. segment = segments[segIndex];
  38372. start = segment.start;
  38373. var end = segment.end;
  38374. var delta = segment.delta;
  38375. offsetIndex = segment.offsetIndex;
  38376. for (j = start; j <= end; j++) {
  38377. if (j === 0xFFFF) {
  38378. continue;
  38379. }
  38380. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  38381. glyphId = glyphId + delta & 0xFFFF;
  38382. if (glyphId === 0) {
  38383. continue;
  38384. }
  38385. mappings.push({
  38386. charCode: j,
  38387. glyphId: glyphId
  38388. });
  38389. }
  38390. }
  38391. } else if (format === 6) {
  38392. var firstCode = font.getUint16();
  38393. var entryCount = font.getUint16();
  38394. for (j = 0; j < entryCount; j++) {
  38395. glyphId = font.getUint16();
  38396. var charCode = firstCode + j;
  38397. mappings.push({
  38398. charCode: charCode,
  38399. glyphId: glyphId
  38400. });
  38401. }
  38402. } else {
  38403. warn('cmap table has unsupported format: ' + format);
  38404. return {
  38405. platformId: -1,
  38406. encodingId: -1,
  38407. mappings: [],
  38408. hasShortCmap: false
  38409. };
  38410. }
  38411. mappings.sort(function (a, b) {
  38412. return a.charCode - b.charCode;
  38413. });
  38414. for (i = 1; i < mappings.length; i++) {
  38415. if (mappings[i - 1].charCode === mappings[i].charCode) {
  38416. mappings.splice(i, 1);
  38417. i--;
  38418. }
  38419. }
  38420. return {
  38421. platformId: potentialTable.platformId,
  38422. encodingId: potentialTable.encodingId,
  38423. mappings: mappings,
  38424. hasShortCmap: hasShortCmap
  38425. };
  38426. }
  38427. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  38428. if (!header) {
  38429. if (metrics) {
  38430. metrics.data = null;
  38431. }
  38432. return;
  38433. }
  38434. font.pos = (font.start ? font.start : 0) + header.offset;
  38435. font.pos += header.length - 2;
  38436. var numOfMetrics = font.getUint16();
  38437. if (numOfMetrics > numGlyphs) {
  38438. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  38439. numOfMetrics = numGlyphs;
  38440. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  38441. header.data[35] = numOfMetrics & 0x00ff;
  38442. }
  38443. var numOfSidebearings = numGlyphs - numOfMetrics;
  38444. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  38445. if (numMissing > 0) {
  38446. var entries = new Uint8Array(metrics.length + numMissing * 2);
  38447. entries.set(metrics.data);
  38448. metrics.data = entries;
  38449. }
  38450. }
  38451. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  38452. if (sourceEnd - sourceStart <= 12) {
  38453. return 0;
  38454. }
  38455. var glyf = source.subarray(sourceStart, sourceEnd);
  38456. var contoursCount = glyf[0] << 8 | glyf[1];
  38457. if (contoursCount & 0x8000) {
  38458. dest.set(glyf, destStart);
  38459. return glyf.length;
  38460. }
  38461. var i, j = 10, flagsCount = 0;
  38462. for (i = 0; i < contoursCount; i++) {
  38463. var endPoint = glyf[j] << 8 | glyf[j + 1];
  38464. flagsCount = endPoint + 1;
  38465. j += 2;
  38466. }
  38467. var instructionsStart = j;
  38468. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  38469. j += 2 + instructionsLength;
  38470. var instructionsEnd = j;
  38471. var coordinatesLength = 0;
  38472. for (i = 0; i < flagsCount; i++) {
  38473. var flag = glyf[j++];
  38474. if (flag & 0xC0) {
  38475. glyf[j - 1] = flag & 0x3F;
  38476. }
  38477. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  38478. coordinatesLength += xyLength;
  38479. if (flag & 8) {
  38480. var repeat = glyf[j++];
  38481. i += repeat;
  38482. coordinatesLength += repeat * xyLength;
  38483. }
  38484. }
  38485. if (coordinatesLength === 0) {
  38486. return 0;
  38487. }
  38488. var glyphDataLength = j + coordinatesLength;
  38489. if (glyphDataLength > glyf.length) {
  38490. return 0;
  38491. }
  38492. if (!hintsValid && instructionsLength > 0) {
  38493. dest.set(glyf.subarray(0, instructionsStart), destStart);
  38494. dest.set([
  38495. 0,
  38496. 0
  38497. ], destStart + instructionsStart);
  38498. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  38499. glyphDataLength -= instructionsLength;
  38500. if (glyf.length - glyphDataLength > 3) {
  38501. glyphDataLength = glyphDataLength + 3 & ~3;
  38502. }
  38503. return glyphDataLength;
  38504. }
  38505. if (glyf.length - glyphDataLength > 3) {
  38506. glyphDataLength = glyphDataLength + 3 & ~3;
  38507. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  38508. return glyphDataLength;
  38509. }
  38510. dest.set(glyf, destStart);
  38511. return glyf.length;
  38512. }
  38513. function sanitizeHead(head, numGlyphs, locaLength) {
  38514. var data = head.data;
  38515. var version = int32(data[0], data[1], data[2], data[3]);
  38516. if (version >> 16 !== 1) {
  38517. info('Attempting to fix invalid version in head table: ' + version);
  38518. data[0] = 0;
  38519. data[1] = 1;
  38520. data[2] = 0;
  38521. data[3] = 0;
  38522. }
  38523. var indexToLocFormat = int16(data[50], data[51]);
  38524. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  38525. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  38526. var numGlyphsPlusOne = numGlyphs + 1;
  38527. if (locaLength === numGlyphsPlusOne << 1) {
  38528. data[50] = 0;
  38529. data[51] = 0;
  38530. } else if (locaLength === numGlyphsPlusOne << 2) {
  38531. data[50] = 0;
  38532. data[51] = 1;
  38533. } else {
  38534. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  38535. }
  38536. }
  38537. }
  38538. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  38539. var itemSize, itemDecode, itemEncode;
  38540. if (isGlyphLocationsLong) {
  38541. itemSize = 4;
  38542. itemDecode = function fontItemDecodeLong(data, offset) {
  38543. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  38544. };
  38545. itemEncode = function fontItemEncodeLong(data, offset, value) {
  38546. data[offset] = value >>> 24 & 0xFF;
  38547. data[offset + 1] = value >> 16 & 0xFF;
  38548. data[offset + 2] = value >> 8 & 0xFF;
  38549. data[offset + 3] = value & 0xFF;
  38550. };
  38551. } else {
  38552. itemSize = 2;
  38553. itemDecode = function fontItemDecode(data, offset) {
  38554. return data[offset] << 9 | data[offset + 1] << 1;
  38555. };
  38556. itemEncode = function fontItemEncode(data, offset, value) {
  38557. data[offset] = value >> 9 & 0xFF;
  38558. data[offset + 1] = value >> 1 & 0xFF;
  38559. };
  38560. }
  38561. var locaData = loca.data;
  38562. var locaDataSize = itemSize * (1 + numGlyphs);
  38563. if (locaData.length !== locaDataSize) {
  38564. locaData = new Uint8Array(locaDataSize);
  38565. locaData.set(loca.data.subarray(0, locaDataSize));
  38566. loca.data = locaData;
  38567. }
  38568. var oldGlyfData = glyf.data;
  38569. var oldGlyfDataLength = oldGlyfData.length;
  38570. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  38571. var startOffset = itemDecode(locaData, 0);
  38572. var writeOffset = 0;
  38573. var missingGlyphData = Object.create(null);
  38574. itemEncode(locaData, 0, writeOffset);
  38575. var i, j;
  38576. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  38577. var endOffset = itemDecode(locaData, j);
  38578. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  38579. endOffset = oldGlyfDataLength;
  38580. }
  38581. if (endOffset > oldGlyfDataLength) {
  38582. itemEncode(locaData, j, writeOffset);
  38583. startOffset = endOffset;
  38584. continue;
  38585. }
  38586. if (startOffset === endOffset) {
  38587. missingGlyphData[i] = true;
  38588. }
  38589. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  38590. writeOffset += newLength;
  38591. itemEncode(locaData, j, writeOffset);
  38592. startOffset = endOffset;
  38593. }
  38594. if (writeOffset === 0) {
  38595. var simpleGlyph = new Uint8Array([
  38596. 0,
  38597. 1,
  38598. 0,
  38599. 0,
  38600. 0,
  38601. 0,
  38602. 0,
  38603. 0,
  38604. 0,
  38605. 0,
  38606. 0,
  38607. 0,
  38608. 0,
  38609. 0,
  38610. 49,
  38611. 0
  38612. ]);
  38613. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  38614. itemEncode(locaData, j, simpleGlyph.length);
  38615. }
  38616. glyf.data = simpleGlyph;
  38617. return missingGlyphData;
  38618. }
  38619. if (dupFirstEntry) {
  38620. var firstEntryLength = itemDecode(locaData, itemSize);
  38621. if (newGlyfData.length > firstEntryLength + writeOffset) {
  38622. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  38623. } else {
  38624. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  38625. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  38626. }
  38627. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  38628. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  38629. } else {
  38630. glyf.data = newGlyfData.subarray(0, writeOffset);
  38631. }
  38632. return missingGlyphData;
  38633. }
  38634. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  38635. var start = (font.start ? font.start : 0) + post.offset;
  38636. font.pos = start;
  38637. var length = post.length, end = start + length;
  38638. var version = font.getInt32();
  38639. font.getBytes(28);
  38640. var glyphNames;
  38641. var valid = true;
  38642. var i;
  38643. switch (version) {
  38644. case 0x00010000:
  38645. glyphNames = MacStandardGlyphOrdering;
  38646. break;
  38647. case 0x00020000:
  38648. var numGlyphs = font.getUint16();
  38649. if (numGlyphs !== maxpNumGlyphs) {
  38650. valid = false;
  38651. break;
  38652. }
  38653. var glyphNameIndexes = [];
  38654. for (i = 0; i < numGlyphs; ++i) {
  38655. var index = font.getUint16();
  38656. if (index >= 32768) {
  38657. valid = false;
  38658. break;
  38659. }
  38660. glyphNameIndexes.push(index);
  38661. }
  38662. if (!valid) {
  38663. break;
  38664. }
  38665. var customNames = [];
  38666. var strBuf = [];
  38667. while (font.pos < end) {
  38668. var stringLength = font.getByte();
  38669. strBuf.length = stringLength;
  38670. for (i = 0; i < stringLength; ++i) {
  38671. strBuf[i] = String.fromCharCode(font.getByte());
  38672. }
  38673. customNames.push(strBuf.join(''));
  38674. }
  38675. glyphNames = [];
  38676. for (i = 0; i < numGlyphs; ++i) {
  38677. var j = glyphNameIndexes[i];
  38678. if (j < 258) {
  38679. glyphNames.push(MacStandardGlyphOrdering[j]);
  38680. continue;
  38681. }
  38682. glyphNames.push(customNames[j - 258]);
  38683. }
  38684. break;
  38685. case 0x00030000:
  38686. break;
  38687. default:
  38688. warn('Unknown/unsupported post table version ' + version);
  38689. valid = false;
  38690. if (properties.defaultEncoding) {
  38691. glyphNames = properties.defaultEncoding;
  38692. }
  38693. break;
  38694. }
  38695. properties.glyphNames = glyphNames;
  38696. return valid;
  38697. }
  38698. function readNameTable(nameTable) {
  38699. var start = (font.start ? font.start : 0) + nameTable.offset;
  38700. font.pos = start;
  38701. var names = [
  38702. [],
  38703. []
  38704. ];
  38705. var length = nameTable.length, end = start + length;
  38706. var format = font.getUint16();
  38707. var FORMAT_0_HEADER_LENGTH = 6;
  38708. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  38709. return names;
  38710. }
  38711. var numRecords = font.getUint16();
  38712. var stringsStart = font.getUint16();
  38713. var records = [];
  38714. var NAME_RECORD_LENGTH = 12;
  38715. var i, ii;
  38716. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  38717. var r = {
  38718. platform: font.getUint16(),
  38719. encoding: font.getUint16(),
  38720. language: font.getUint16(),
  38721. name: font.getUint16(),
  38722. length: font.getUint16(),
  38723. offset: font.getUint16()
  38724. };
  38725. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  38726. records.push(r);
  38727. }
  38728. }
  38729. for (i = 0, ii = records.length; i < ii; i++) {
  38730. var record = records[i];
  38731. if (record.length <= 0) {
  38732. continue;
  38733. }
  38734. var pos = start + stringsStart + record.offset;
  38735. if (pos + record.length > end) {
  38736. continue;
  38737. }
  38738. font.pos = pos;
  38739. var nameIndex = record.name;
  38740. if (record.encoding) {
  38741. var str = '';
  38742. for (var j = 0, jj = record.length; j < jj; j += 2) {
  38743. str += String.fromCharCode(font.getUint16());
  38744. }
  38745. names[1][nameIndex] = str;
  38746. } else {
  38747. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  38748. }
  38749. }
  38750. return names;
  38751. }
  38752. var TTOpsStackDeltas = [
  38753. 0,
  38754. 0,
  38755. 0,
  38756. 0,
  38757. 0,
  38758. 0,
  38759. 0,
  38760. 0,
  38761. -2,
  38762. -2,
  38763. -2,
  38764. -2,
  38765. 0,
  38766. 0,
  38767. -2,
  38768. -5,
  38769. -1,
  38770. -1,
  38771. -1,
  38772. -1,
  38773. -1,
  38774. -1,
  38775. -1,
  38776. -1,
  38777. 0,
  38778. 0,
  38779. -1,
  38780. 0,
  38781. -1,
  38782. -1,
  38783. -1,
  38784. -1,
  38785. 1,
  38786. -1,
  38787. -999,
  38788. 0,
  38789. 1,
  38790. 0,
  38791. -1,
  38792. -2,
  38793. 0,
  38794. -1,
  38795. -2,
  38796. -1,
  38797. -1,
  38798. 0,
  38799. -1,
  38800. -1,
  38801. 0,
  38802. 0,
  38803. -999,
  38804. -999,
  38805. -1,
  38806. -1,
  38807. -1,
  38808. -1,
  38809. -2,
  38810. -999,
  38811. -2,
  38812. -2,
  38813. -999,
  38814. 0,
  38815. -2,
  38816. -2,
  38817. 0,
  38818. 0,
  38819. -2,
  38820. 0,
  38821. -2,
  38822. 0,
  38823. 0,
  38824. 0,
  38825. -2,
  38826. -1,
  38827. -1,
  38828. 1,
  38829. 1,
  38830. 0,
  38831. 0,
  38832. -1,
  38833. -1,
  38834. -1,
  38835. -1,
  38836. -1,
  38837. -1,
  38838. -1,
  38839. 0,
  38840. 0,
  38841. -1,
  38842. 0,
  38843. -1,
  38844. -1,
  38845. 0,
  38846. -999,
  38847. -1,
  38848. -1,
  38849. -1,
  38850. -1,
  38851. -1,
  38852. -1,
  38853. 0,
  38854. 0,
  38855. 0,
  38856. 0,
  38857. 0,
  38858. 0,
  38859. 0,
  38860. 0,
  38861. 0,
  38862. 0,
  38863. 0,
  38864. 0,
  38865. -2,
  38866. -999,
  38867. -999,
  38868. -999,
  38869. -999,
  38870. -999,
  38871. -1,
  38872. -1,
  38873. -2,
  38874. -2,
  38875. 0,
  38876. 0,
  38877. 0,
  38878. 0,
  38879. -1,
  38880. -1,
  38881. -999,
  38882. -2,
  38883. -2,
  38884. 0,
  38885. 0,
  38886. -1,
  38887. -2,
  38888. -2,
  38889. 0,
  38890. 0,
  38891. 0,
  38892. -1,
  38893. -1,
  38894. -1,
  38895. -2
  38896. ];
  38897. function sanitizeTTProgram(table, ttContext) {
  38898. var data = table.data;
  38899. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  38900. var stack = [];
  38901. var callstack = [];
  38902. var functionsCalled = [];
  38903. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  38904. var inFDEF = false, ifLevel = 0, inELSE = 0;
  38905. for (var ii = data.length; i < ii;) {
  38906. var op = data[i++];
  38907. if (op === 0x40) {
  38908. n = data[i++];
  38909. if (inFDEF || inELSE) {
  38910. i += n;
  38911. } else {
  38912. for (j = 0; j < n; j++) {
  38913. stack.push(data[i++]);
  38914. }
  38915. }
  38916. } else if (op === 0x41) {
  38917. n = data[i++];
  38918. if (inFDEF || inELSE) {
  38919. i += n * 2;
  38920. } else {
  38921. for (j = 0; j < n; j++) {
  38922. b = data[i++];
  38923. stack.push(b << 8 | data[i++]);
  38924. }
  38925. }
  38926. } else if ((op & 0xF8) === 0xB0) {
  38927. n = op - 0xB0 + 1;
  38928. if (inFDEF || inELSE) {
  38929. i += n;
  38930. } else {
  38931. for (j = 0; j < n; j++) {
  38932. stack.push(data[i++]);
  38933. }
  38934. }
  38935. } else if ((op & 0xF8) === 0xB8) {
  38936. n = op - 0xB8 + 1;
  38937. if (inFDEF || inELSE) {
  38938. i += n * 2;
  38939. } else {
  38940. for (j = 0; j < n; j++) {
  38941. b = data[i++];
  38942. stack.push(b << 8 | data[i++]);
  38943. }
  38944. }
  38945. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  38946. if (!inFDEF && !inELSE) {
  38947. funcId = stack[stack.length - 1];
  38948. ttContext.functionsUsed[funcId] = true;
  38949. if (funcId in ttContext.functionsStackDeltas) {
  38950. stack.length += ttContext.functionsStackDeltas[funcId];
  38951. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  38952. callstack.push({
  38953. data: data,
  38954. i: i,
  38955. stackTop: stack.length - 1
  38956. });
  38957. functionsCalled.push(funcId);
  38958. pc = ttContext.functionsDefined[funcId];
  38959. if (!pc) {
  38960. warn('TT: CALL non-existent function');
  38961. ttContext.hintsValid = false;
  38962. return;
  38963. }
  38964. data = pc.data;
  38965. i = pc.i;
  38966. }
  38967. }
  38968. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  38969. if (inFDEF || inELSE) {
  38970. warn('TT: nested FDEFs not allowed');
  38971. tooComplexToFollowFunctions = true;
  38972. }
  38973. inFDEF = true;
  38974. lastDeff = i;
  38975. funcId = stack.pop();
  38976. ttContext.functionsDefined[funcId] = {
  38977. data: data,
  38978. i: i
  38979. };
  38980. } else if (op === 0x2D) {
  38981. if (inFDEF) {
  38982. inFDEF = false;
  38983. lastEndf = i;
  38984. } else {
  38985. pc = callstack.pop();
  38986. if (!pc) {
  38987. warn('TT: ENDF bad stack');
  38988. ttContext.hintsValid = false;
  38989. return;
  38990. }
  38991. funcId = functionsCalled.pop();
  38992. data = pc.data;
  38993. i = pc.i;
  38994. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  38995. }
  38996. } else if (op === 0x89) {
  38997. if (inFDEF || inELSE) {
  38998. warn('TT: nested IDEFs not allowed');
  38999. tooComplexToFollowFunctions = true;
  39000. }
  39001. inFDEF = true;
  39002. lastDeff = i;
  39003. } else if (op === 0x58) {
  39004. ++ifLevel;
  39005. } else if (op === 0x1B) {
  39006. inELSE = ifLevel;
  39007. } else if (op === 0x59) {
  39008. if (inELSE === ifLevel) {
  39009. inELSE = 0;
  39010. }
  39011. --ifLevel;
  39012. } else if (op === 0x1C) {
  39013. if (!inFDEF && !inELSE) {
  39014. var offset = stack[stack.length - 1];
  39015. if (offset > 0) {
  39016. i += offset - 1;
  39017. }
  39018. }
  39019. }
  39020. if (!inFDEF && !inELSE) {
  39021. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  39022. if (op >= 0x71 && op <= 0x75) {
  39023. n = stack.pop();
  39024. if (n === n) {
  39025. stackDelta = -n * 2;
  39026. }
  39027. }
  39028. while (stackDelta < 0 && stack.length > 0) {
  39029. stack.pop();
  39030. stackDelta++;
  39031. }
  39032. while (stackDelta > 0) {
  39033. stack.push(NaN);
  39034. stackDelta--;
  39035. }
  39036. }
  39037. }
  39038. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  39039. var content = [data];
  39040. if (i > data.length) {
  39041. content.push(new Uint8Array(i - data.length));
  39042. }
  39043. if (lastDeff > lastEndf) {
  39044. warn('TT: complementing a missing function tail');
  39045. content.push(new Uint8Array([
  39046. 0x22,
  39047. 0x2D
  39048. ]));
  39049. }
  39050. foldTTTable(table, content);
  39051. }
  39052. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  39053. if (ttContext.tooComplexToFollowFunctions) {
  39054. return;
  39055. }
  39056. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  39057. warn('TT: more functions defined than expected');
  39058. ttContext.hintsValid = false;
  39059. return;
  39060. }
  39061. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  39062. if (j > maxFunctionDefs) {
  39063. warn('TT: invalid function id: ' + j);
  39064. ttContext.hintsValid = false;
  39065. return;
  39066. }
  39067. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  39068. warn('TT: undefined function: ' + j);
  39069. ttContext.hintsValid = false;
  39070. return;
  39071. }
  39072. }
  39073. }
  39074. function foldTTTable(table, content) {
  39075. if (content.length > 1) {
  39076. var newLength = 0;
  39077. var j, jj;
  39078. for (j = 0, jj = content.length; j < jj; j++) {
  39079. newLength += content[j].length;
  39080. }
  39081. newLength = newLength + 3 & ~3;
  39082. var result = new Uint8Array(newLength);
  39083. var pos = 0;
  39084. for (j = 0, jj = content.length; j < jj; j++) {
  39085. result.set(content[j], pos);
  39086. pos += content[j].length;
  39087. }
  39088. table.data = result;
  39089. table.length = newLength;
  39090. }
  39091. }
  39092. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  39093. var ttContext = {
  39094. functionsDefined: [],
  39095. functionsUsed: [],
  39096. functionsStackDeltas: [],
  39097. tooComplexToFollowFunctions: false,
  39098. hintsValid: true
  39099. };
  39100. if (fpgm) {
  39101. sanitizeTTProgram(fpgm, ttContext);
  39102. }
  39103. if (prep) {
  39104. sanitizeTTProgram(prep, ttContext);
  39105. }
  39106. if (fpgm) {
  39107. checkInvalidFunctions(ttContext, maxFunctionDefs);
  39108. }
  39109. if (cvt && cvt.length & 1) {
  39110. var cvtData = new Uint8Array(cvt.length + 1);
  39111. cvtData.set(cvt.data);
  39112. cvt.data = cvtData;
  39113. }
  39114. return ttContext.hintsValid;
  39115. }
  39116. font = new Stream(new Uint8Array(font.getBytes()));
  39117. var VALID_TABLES = [
  39118. 'OS/2',
  39119. 'cmap',
  39120. 'head',
  39121. 'hhea',
  39122. 'hmtx',
  39123. 'maxp',
  39124. 'name',
  39125. 'post',
  39126. 'loca',
  39127. 'glyf',
  39128. 'fpgm',
  39129. 'prep',
  39130. 'cvt ',
  39131. 'CFF '
  39132. ];
  39133. var header = readOpenTypeHeader(font);
  39134. var numTables = header.numTables;
  39135. var cff, cffFile;
  39136. var tables = Object.create(null);
  39137. tables['OS/2'] = null;
  39138. tables['cmap'] = null;
  39139. tables['head'] = null;
  39140. tables['hhea'] = null;
  39141. tables['hmtx'] = null;
  39142. tables['maxp'] = null;
  39143. tables['name'] = null;
  39144. tables['post'] = null;
  39145. var table;
  39146. for (var i = 0; i < numTables; i++) {
  39147. table = readTableEntry(font);
  39148. if (VALID_TABLES.indexOf(table.tag) < 0) {
  39149. continue;
  39150. }
  39151. if (table.length === 0) {
  39152. continue;
  39153. }
  39154. tables[table.tag] = table;
  39155. }
  39156. var isTrueType = !tables['CFF '];
  39157. if (!isTrueType) {
  39158. if (header.version === 'OTTO' && properties.type !== 'CIDFontType2' || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  39159. cffFile = new Stream(tables['CFF '].data);
  39160. cff = new CFFFont(cffFile, properties);
  39161. adjustWidths(properties);
  39162. return this.convert(name, cff, properties);
  39163. }
  39164. delete tables['glyf'];
  39165. delete tables['loca'];
  39166. delete tables['fpgm'];
  39167. delete tables['prep'];
  39168. delete tables['cvt '];
  39169. this.isOpenType = true;
  39170. } else {
  39171. if (!tables['loca']) {
  39172. error('Required "loca" table is not found');
  39173. }
  39174. if (!tables['glyf']) {
  39175. warn('Required "glyf" table is not found -- trying to recover.');
  39176. tables['glyf'] = {
  39177. tag: 'glyf',
  39178. data: new Uint8Array(0)
  39179. };
  39180. }
  39181. this.isOpenType = false;
  39182. }
  39183. if (!tables['maxp']) {
  39184. error('Required "maxp" table is not found');
  39185. }
  39186. font.pos = (font.start || 0) + tables['maxp'].offset;
  39187. var version = font.getInt32();
  39188. var numGlyphs = font.getUint16();
  39189. var maxFunctionDefs = 0;
  39190. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  39191. font.pos += 8;
  39192. var maxZones = font.getUint16();
  39193. if (maxZones > 2) {
  39194. tables['maxp'].data[14] = 0;
  39195. tables['maxp'].data[15] = 2;
  39196. }
  39197. font.pos += 4;
  39198. maxFunctionDefs = font.getUint16();
  39199. }
  39200. var dupFirstEntry = false;
  39201. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  39202. dupFirstEntry = true;
  39203. numGlyphs++;
  39204. tables['maxp'].data[4] = numGlyphs >> 8;
  39205. tables['maxp'].data[5] = numGlyphs & 255;
  39206. }
  39207. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  39208. if (!hintsValid) {
  39209. delete tables['fpgm'];
  39210. delete tables['prep'];
  39211. delete tables['cvt '];
  39212. }
  39213. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  39214. if (!tables['head']) {
  39215. error('Required "head" table is not found');
  39216. }
  39217. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  39218. var missingGlyphs = Object.create(null);
  39219. if (isTrueType) {
  39220. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  39221. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  39222. }
  39223. if (!tables['hhea']) {
  39224. error('Required "hhea" table is not found');
  39225. }
  39226. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  39227. tables['hhea'].data[10] = 0xFF;
  39228. tables['hhea'].data[11] = 0xFF;
  39229. }
  39230. var metricsOverride = {
  39231. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  39232. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  39233. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  39234. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  39235. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  39236. };
  39237. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  39238. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  39239. if (tables['post']) {
  39240. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  39241. if (!valid) {
  39242. tables['post'] = null;
  39243. }
  39244. }
  39245. var charCodeToGlyphId = [], charCode;
  39246. var toUnicode = properties.toUnicode, widths = properties.widths;
  39247. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  39248. function hasGlyph(glyphId, charCode, widthCode) {
  39249. if (!missingGlyphs[glyphId]) {
  39250. return true;
  39251. }
  39252. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  39253. return true;
  39254. }
  39255. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  39256. return true;
  39257. }
  39258. return false;
  39259. }
  39260. if (properties.type === 'CIDFontType2') {
  39261. var cidToGidMap = properties.cidToGidMap || [];
  39262. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  39263. properties.cMap.forEach(function (charCode, cid) {
  39264. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  39265. var glyphId = -1;
  39266. if (isCidToGidMapEmpty) {
  39267. glyphId = cid;
  39268. } else if (cidToGidMap[cid] !== undefined) {
  39269. glyphId = cidToGidMap[cid];
  39270. }
  39271. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  39272. charCodeToGlyphId[charCode] = glyphId;
  39273. }
  39274. });
  39275. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  39276. charCodeToGlyphId[0] = numGlyphs - 1;
  39277. }
  39278. } else {
  39279. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  39280. var cmapPlatformId = cmapTable.platformId;
  39281. var cmapEncodingId = cmapTable.encodingId;
  39282. var cmapMappings = cmapTable.mappings;
  39283. var cmapMappingsLength = cmapMappings.length;
  39284. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  39285. var baseEncoding = [];
  39286. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  39287. baseEncoding = getEncoding(properties.baseEncodingName);
  39288. }
  39289. var glyphsUnicodeMap = getGlyphsUnicode();
  39290. for (charCode = 0; charCode < 256; charCode++) {
  39291. var glyphName, standardGlyphName;
  39292. if (this.differences && charCode in this.differences) {
  39293. glyphName = this.differences[charCode];
  39294. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  39295. glyphName = baseEncoding[charCode];
  39296. } else {
  39297. glyphName = StandardEncoding[charCode];
  39298. }
  39299. if (!glyphName) {
  39300. continue;
  39301. }
  39302. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  39303. var unicodeOrCharCode, isUnicode = false;
  39304. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  39305. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  39306. isUnicode = true;
  39307. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  39308. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  39309. }
  39310. var found = false;
  39311. for (i = 0; i < cmapMappingsLength; ++i) {
  39312. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  39313. continue;
  39314. }
  39315. var code = isUnicode ? charCode : unicodeOrCharCode;
  39316. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  39317. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  39318. found = true;
  39319. break;
  39320. }
  39321. }
  39322. if (!found && properties.glyphNames) {
  39323. var glyphId = properties.glyphNames.indexOf(glyphName);
  39324. if (glyphId === -1 && standardGlyphName !== glyphName) {
  39325. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  39326. }
  39327. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  39328. charCodeToGlyphId[charCode] = glyphId;
  39329. found = true;
  39330. }
  39331. }
  39332. if (!found) {
  39333. charCodeToGlyphId[charCode] = 0;
  39334. }
  39335. }
  39336. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  39337. for (i = 0; i < cmapMappingsLength; ++i) {
  39338. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  39339. }
  39340. } else {
  39341. for (i = 0; i < cmapMappingsLength; ++i) {
  39342. charCode = cmapMappings[i].charCode & 0xFF;
  39343. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  39344. }
  39345. }
  39346. }
  39347. if (charCodeToGlyphId.length === 0) {
  39348. charCodeToGlyphId[0] = 0;
  39349. }
  39350. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  39351. this.toFontChar = newMapping.toFontChar;
  39352. tables['cmap'] = {
  39353. tag: 'cmap',
  39354. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  39355. };
  39356. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  39357. tables['OS/2'] = {
  39358. tag: 'OS/2',
  39359. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  39360. };
  39361. }
  39362. if (!tables['post']) {
  39363. tables['post'] = {
  39364. tag: 'post',
  39365. data: createPostTable(properties)
  39366. };
  39367. }
  39368. if (!isTrueType) {
  39369. try {
  39370. cffFile = new Stream(tables['CFF '].data);
  39371. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  39372. cff = parser.parse();
  39373. var compiler = new CFFCompiler(cff);
  39374. tables['CFF '].data = compiler.compile();
  39375. } catch (e) {
  39376. warn('Failed to compile font ' + properties.loadedName);
  39377. }
  39378. }
  39379. if (!tables['name']) {
  39380. tables['name'] = {
  39381. tag: 'name',
  39382. data: createNameTable(this.name)
  39383. };
  39384. } else {
  39385. var namePrototype = readNameTable(tables['name']);
  39386. tables['name'].data = createNameTable(name, namePrototype);
  39387. }
  39388. var builder = new OpenTypeFileBuilder(header.version);
  39389. for (var tableTag in tables) {
  39390. builder.addTable(tableTag, tables[tableTag].data);
  39391. }
  39392. return builder.toArray();
  39393. },
  39394. convert: function Font_convert(fontName, font, properties) {
  39395. properties.fixedPitch = false;
  39396. if (properties.builtInEncoding) {
  39397. adjustToUnicode(properties, properties.builtInEncoding);
  39398. }
  39399. var mapping = font.getGlyphMapping(properties);
  39400. var newMapping = adjustMapping(mapping, properties);
  39401. this.toFontChar = newMapping.toFontChar;
  39402. var numGlyphs = font.numGlyphs;
  39403. function getCharCodes(charCodeToGlyphId, glyphId) {
  39404. var charCodes = null;
  39405. for (var charCode in charCodeToGlyphId) {
  39406. if (glyphId === charCodeToGlyphId[charCode]) {
  39407. if (!charCodes) {
  39408. charCodes = [];
  39409. }
  39410. charCodes.push(charCode | 0);
  39411. }
  39412. }
  39413. return charCodes;
  39414. }
  39415. function createCharCode(charCodeToGlyphId, glyphId) {
  39416. for (var charCode in charCodeToGlyphId) {
  39417. if (glyphId === charCodeToGlyphId[charCode]) {
  39418. return charCode | 0;
  39419. }
  39420. }
  39421. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  39422. return newMapping.nextAvailableFontCharCode++;
  39423. }
  39424. var seacs = font.seacs;
  39425. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  39426. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  39427. var charset = font.getCharset();
  39428. var seacMap = Object.create(null);
  39429. for (var glyphId in seacs) {
  39430. glyphId |= 0;
  39431. var seac = seacs[glyphId];
  39432. var baseGlyphName = StandardEncoding[seac[2]];
  39433. var accentGlyphName = StandardEncoding[seac[3]];
  39434. var baseGlyphId = charset.indexOf(baseGlyphName);
  39435. var accentGlyphId = charset.indexOf(accentGlyphName);
  39436. if (baseGlyphId < 0 || accentGlyphId < 0) {
  39437. continue;
  39438. }
  39439. var accentOffset = {
  39440. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  39441. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  39442. };
  39443. var charCodes = getCharCodes(mapping, glyphId);
  39444. if (!charCodes) {
  39445. continue;
  39446. }
  39447. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  39448. var charCode = charCodes[i];
  39449. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  39450. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  39451. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  39452. seacMap[charCode] = {
  39453. baseFontCharCode: baseFontCharCode,
  39454. accentFontCharCode: accentFontCharCode,
  39455. accentOffset: accentOffset
  39456. };
  39457. }
  39458. }
  39459. properties.seacMap = seacMap;
  39460. }
  39461. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  39462. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  39463. builder.addTable('CFF ', font.data);
  39464. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  39465. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  39466. 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');
  39467. 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));
  39468. builder.addTable('hmtx', function fontFieldsHmtx() {
  39469. var charstrings = font.charstrings;
  39470. var cffWidths = font.cff ? font.cff.widths : null;
  39471. var hmtx = '\x00\x00\x00\x00';
  39472. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  39473. var width = 0;
  39474. if (charstrings) {
  39475. var charstring = charstrings[i - 1];
  39476. width = 'width' in charstring ? charstring.width : 0;
  39477. } else if (cffWidths) {
  39478. width = Math.ceil(cffWidths[i] || 0);
  39479. }
  39480. hmtx += string16(width) + string16(0);
  39481. }
  39482. return hmtx;
  39483. }());
  39484. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  39485. builder.addTable('name', createNameTable(fontName));
  39486. builder.addTable('post', createPostTable(properties));
  39487. return builder.toArray();
  39488. },
  39489. get spaceWidth() {
  39490. if ('_shadowWidth' in this) {
  39491. return this._shadowWidth;
  39492. }
  39493. var possibleSpaceReplacements = [
  39494. 'space',
  39495. 'minus',
  39496. 'one',
  39497. 'i',
  39498. 'I'
  39499. ];
  39500. var width;
  39501. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  39502. var glyphName = possibleSpaceReplacements[i];
  39503. if (glyphName in this.widths) {
  39504. width = this.widths[glyphName];
  39505. break;
  39506. }
  39507. var glyphsUnicodeMap = getGlyphsUnicode();
  39508. var glyphUnicode = glyphsUnicodeMap[glyphName];
  39509. var charcode = 0;
  39510. if (this.composite) {
  39511. if (this.cMap.contains(glyphUnicode)) {
  39512. charcode = this.cMap.lookup(glyphUnicode);
  39513. }
  39514. }
  39515. if (!charcode && this.toUnicode) {
  39516. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  39517. }
  39518. if (charcode <= 0) {
  39519. charcode = glyphUnicode;
  39520. }
  39521. width = this.widths[charcode];
  39522. if (width) {
  39523. break;
  39524. }
  39525. }
  39526. width = width || this.defaultWidth;
  39527. this._shadowWidth = width;
  39528. return width;
  39529. },
  39530. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  39531. var fontCharCode, width, operatorListId;
  39532. var widthCode = charcode;
  39533. if (this.cMap && this.cMap.contains(charcode)) {
  39534. widthCode = this.cMap.lookup(charcode);
  39535. }
  39536. width = this.widths[widthCode];
  39537. width = isNum(width) ? width : this.defaultWidth;
  39538. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  39539. var unicode = this.toUnicode.get(charcode) || charcode;
  39540. if (typeof unicode === 'number') {
  39541. unicode = String.fromCharCode(unicode);
  39542. }
  39543. var isInFont = charcode in this.toFontChar;
  39544. fontCharCode = this.toFontChar[charcode] || charcode;
  39545. if (this.missingFile) {
  39546. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  39547. }
  39548. if (this.isType3Font) {
  39549. operatorListId = fontCharCode;
  39550. }
  39551. var accent = null;
  39552. if (this.seacMap && this.seacMap[charcode]) {
  39553. isInFont = true;
  39554. var seac = this.seacMap[charcode];
  39555. fontCharCode = seac.baseFontCharCode;
  39556. accent = {
  39557. fontChar: String.fromCharCode(seac.accentFontCharCode),
  39558. offset: seac.accentOffset
  39559. };
  39560. }
  39561. var fontChar = String.fromCharCode(fontCharCode);
  39562. var glyph = this.glyphCache[charcode];
  39563. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  39564. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  39565. this.glyphCache[charcode] = glyph;
  39566. }
  39567. return glyph;
  39568. },
  39569. charsToGlyphs: function Font_charsToGlyphs(chars) {
  39570. var charsCache = this.charsCache;
  39571. var glyphs, glyph, charcode;
  39572. if (charsCache) {
  39573. glyphs = charsCache[chars];
  39574. if (glyphs) {
  39575. return glyphs;
  39576. }
  39577. }
  39578. if (!charsCache) {
  39579. charsCache = this.charsCache = Object.create(null);
  39580. }
  39581. glyphs = [];
  39582. var charsCacheKey = chars;
  39583. var i = 0, ii;
  39584. if (this.cMap) {
  39585. var c = Object.create(null);
  39586. while (i < chars.length) {
  39587. this.cMap.readCharCode(chars, i, c);
  39588. charcode = c.charcode;
  39589. var length = c.length;
  39590. i += length;
  39591. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  39592. glyph = this.charToGlyph(charcode, isSpace);
  39593. glyphs.push(glyph);
  39594. }
  39595. } else {
  39596. for (i = 0, ii = chars.length; i < ii; ++i) {
  39597. charcode = chars.charCodeAt(i);
  39598. glyph = this.charToGlyph(charcode, charcode === 0x20);
  39599. glyphs.push(glyph);
  39600. }
  39601. }
  39602. return charsCache[charsCacheKey] = glyphs;
  39603. }
  39604. };
  39605. return Font;
  39606. }();
  39607. var ErrorFont = function ErrorFontClosure() {
  39608. function ErrorFont(error) {
  39609. this.error = error;
  39610. this.loadedName = 'g_font_error';
  39611. this.loading = false;
  39612. }
  39613. ErrorFont.prototype = {
  39614. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  39615. return [];
  39616. },
  39617. exportData: function ErrorFont_exportData() {
  39618. return { error: this.error };
  39619. }
  39620. };
  39621. return ErrorFont;
  39622. }();
  39623. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  39624. var charCodeToGlyphId = Object.create(null);
  39625. var glyphId, charCode, baseEncoding;
  39626. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  39627. if (properties.baseEncodingName) {
  39628. baseEncoding = getEncoding(properties.baseEncodingName);
  39629. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  39630. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  39631. if (glyphId >= 0) {
  39632. charCodeToGlyphId[charCode] = glyphId;
  39633. } else {
  39634. charCodeToGlyphId[charCode] = 0;
  39635. }
  39636. }
  39637. } else if (isSymbolicFont) {
  39638. for (charCode in builtInEncoding) {
  39639. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  39640. }
  39641. } else {
  39642. baseEncoding = StandardEncoding;
  39643. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  39644. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  39645. if (glyphId >= 0) {
  39646. charCodeToGlyphId[charCode] = glyphId;
  39647. } else {
  39648. charCodeToGlyphId[charCode] = 0;
  39649. }
  39650. }
  39651. }
  39652. var differences = properties.differences, glyphsUnicodeMap;
  39653. if (differences) {
  39654. for (charCode in differences) {
  39655. var glyphName = differences[charCode];
  39656. glyphId = glyphNames.indexOf(glyphName);
  39657. if (glyphId === -1) {
  39658. if (!glyphsUnicodeMap) {
  39659. glyphsUnicodeMap = getGlyphsUnicode();
  39660. }
  39661. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  39662. if (standardGlyphName !== glyphName) {
  39663. glyphId = glyphNames.indexOf(standardGlyphName);
  39664. }
  39665. }
  39666. if (glyphId >= 0) {
  39667. charCodeToGlyphId[charCode] = glyphId;
  39668. } else {
  39669. charCodeToGlyphId[charCode] = 0;
  39670. }
  39671. }
  39672. }
  39673. return charCodeToGlyphId;
  39674. }
  39675. var Type1Font = function Type1FontClosure() {
  39676. function findBlock(streamBytes, signature, startIndex) {
  39677. var streamBytesLength = streamBytes.length;
  39678. var signatureLength = signature.length;
  39679. var scanLength = streamBytesLength - signatureLength;
  39680. var i = startIndex, j, found = false;
  39681. while (i < scanLength) {
  39682. j = 0;
  39683. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  39684. j++;
  39685. }
  39686. if (j >= signatureLength) {
  39687. i += j;
  39688. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  39689. i++;
  39690. }
  39691. found = true;
  39692. break;
  39693. }
  39694. i++;
  39695. }
  39696. return {
  39697. found: found,
  39698. length: i
  39699. };
  39700. }
  39701. function getHeaderBlock(stream, suggestedLength) {
  39702. var EEXEC_SIGNATURE = [
  39703. 0x65,
  39704. 0x65,
  39705. 0x78,
  39706. 0x65,
  39707. 0x63
  39708. ];
  39709. var streamStartPos = stream.pos;
  39710. var headerBytes, headerBytesLength, block;
  39711. try {
  39712. headerBytes = stream.getBytes(suggestedLength);
  39713. headerBytesLength = headerBytes.length;
  39714. } catch (ex) {
  39715. if (ex instanceof MissingDataException) {
  39716. throw ex;
  39717. }
  39718. }
  39719. if (headerBytesLength === suggestedLength) {
  39720. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  39721. if (block.found && block.length === suggestedLength) {
  39722. return {
  39723. stream: new Stream(headerBytes),
  39724. length: suggestedLength
  39725. };
  39726. }
  39727. }
  39728. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  39729. stream.pos = streamStartPos;
  39730. var SCAN_BLOCK_LENGTH = 2048;
  39731. var actualLength;
  39732. while (true) {
  39733. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  39734. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  39735. if (block.length === 0) {
  39736. break;
  39737. }
  39738. stream.pos += block.length;
  39739. if (block.found) {
  39740. actualLength = stream.pos - streamStartPos;
  39741. break;
  39742. }
  39743. }
  39744. stream.pos = streamStartPos;
  39745. if (actualLength) {
  39746. return {
  39747. stream: new Stream(stream.getBytes(actualLength)),
  39748. length: actualLength
  39749. };
  39750. }
  39751. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  39752. return {
  39753. stream: new Stream(stream.getBytes(suggestedLength)),
  39754. length: suggestedLength
  39755. };
  39756. }
  39757. function getEexecBlock(stream, suggestedLength) {
  39758. var eexecBytes = stream.getBytes();
  39759. return {
  39760. stream: new Stream(eexecBytes),
  39761. length: eexecBytes.length
  39762. };
  39763. }
  39764. function Type1Font(name, file, properties) {
  39765. var PFB_HEADER_SIZE = 6;
  39766. var headerBlockLength = properties.length1;
  39767. var eexecBlockLength = properties.length2;
  39768. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  39769. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  39770. if (pfbHeaderPresent) {
  39771. file.skip(PFB_HEADER_SIZE);
  39772. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  39773. }
  39774. var headerBlock = getHeaderBlock(file, headerBlockLength);
  39775. headerBlockLength = headerBlock.length;
  39776. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  39777. headerBlockParser.extractFontHeader(properties);
  39778. if (pfbHeaderPresent) {
  39779. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  39780. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  39781. }
  39782. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  39783. eexecBlockLength = eexecBlock.length;
  39784. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  39785. var data = eexecBlockParser.extractFontProgram();
  39786. for (var info in data.properties) {
  39787. properties[info] = data.properties[info];
  39788. }
  39789. var charstrings = data.charstrings;
  39790. var type2Charstrings = this.getType2Charstrings(charstrings);
  39791. var subrs = this.getType2Subrs(data.subrs);
  39792. this.charstrings = charstrings;
  39793. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  39794. this.seacs = this.getSeacs(data.charstrings);
  39795. }
  39796. Type1Font.prototype = {
  39797. get numGlyphs() {
  39798. return this.charstrings.length + 1;
  39799. },
  39800. getCharset: function Type1Font_getCharset() {
  39801. var charset = ['.notdef'];
  39802. var charstrings = this.charstrings;
  39803. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  39804. charset.push(charstrings[glyphId].glyphName);
  39805. }
  39806. return charset;
  39807. },
  39808. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  39809. var charstrings = this.charstrings;
  39810. var glyphNames = ['.notdef'], glyphId;
  39811. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  39812. glyphNames.push(charstrings[glyphId].glyphName);
  39813. }
  39814. var encoding = properties.builtInEncoding;
  39815. if (encoding) {
  39816. var builtInEncoding = Object.create(null);
  39817. for (var charCode in encoding) {
  39818. glyphId = glyphNames.indexOf(encoding[charCode]);
  39819. if (glyphId >= 0) {
  39820. builtInEncoding[charCode] = glyphId;
  39821. }
  39822. }
  39823. }
  39824. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  39825. },
  39826. getSeacs: function Type1Font_getSeacs(charstrings) {
  39827. var i, ii;
  39828. var seacMap = [];
  39829. for (i = 0, ii = charstrings.length; i < ii; i++) {
  39830. var charstring = charstrings[i];
  39831. if (charstring.seac) {
  39832. seacMap[i + 1] = charstring.seac;
  39833. }
  39834. }
  39835. return seacMap;
  39836. },
  39837. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  39838. var type2Charstrings = [];
  39839. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  39840. type2Charstrings.push(type1Charstrings[i].charstring);
  39841. }
  39842. return type2Charstrings;
  39843. },
  39844. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  39845. var bias = 0;
  39846. var count = type1Subrs.length;
  39847. if (count < 1133) {
  39848. bias = 107;
  39849. } else if (count < 33769) {
  39850. bias = 1131;
  39851. } else {
  39852. bias = 32768;
  39853. }
  39854. var type2Subrs = [];
  39855. var i;
  39856. for (i = 0; i < bias; i++) {
  39857. type2Subrs.push([0x0B]);
  39858. }
  39859. for (i = 0; i < count; i++) {
  39860. type2Subrs.push(type1Subrs[i]);
  39861. }
  39862. return type2Subrs;
  39863. },
  39864. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  39865. var cff = new CFF();
  39866. cff.header = new CFFHeader(1, 0, 4, 4);
  39867. cff.names = [name];
  39868. var topDict = new CFFTopDict();
  39869. topDict.setByName('version', 391);
  39870. topDict.setByName('Notice', 392);
  39871. topDict.setByName('FullName', 393);
  39872. topDict.setByName('FamilyName', 394);
  39873. topDict.setByName('Weight', 395);
  39874. topDict.setByName('Encoding', null);
  39875. topDict.setByName('FontMatrix', properties.fontMatrix);
  39876. topDict.setByName('FontBBox', properties.bbox);
  39877. topDict.setByName('charset', null);
  39878. topDict.setByName('CharStrings', null);
  39879. topDict.setByName('Private', null);
  39880. cff.topDict = topDict;
  39881. var strings = new CFFStrings();
  39882. strings.add('Version 0.11');
  39883. strings.add('See original notice');
  39884. strings.add(name);
  39885. strings.add(name);
  39886. strings.add('Medium');
  39887. cff.strings = strings;
  39888. cff.globalSubrIndex = new CFFIndex();
  39889. var count = glyphs.length;
  39890. var charsetArray = [0];
  39891. var i, ii;
  39892. for (i = 0; i < count; i++) {
  39893. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  39894. if (index === -1) {
  39895. index = 0;
  39896. }
  39897. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  39898. }
  39899. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  39900. var charStringsIndex = new CFFIndex();
  39901. charStringsIndex.add([
  39902. 0x8B,
  39903. 0x0E
  39904. ]);
  39905. for (i = 0; i < count; i++) {
  39906. var glyph = glyphs[i];
  39907. if (glyph.length === 0) {
  39908. charStringsIndex.add([
  39909. 0x8B,
  39910. 0x0E
  39911. ]);
  39912. continue;
  39913. }
  39914. charStringsIndex.add(glyph);
  39915. }
  39916. cff.charStrings = charStringsIndex;
  39917. var privateDict = new CFFPrivateDict();
  39918. privateDict.setByName('Subrs', null);
  39919. var fields = [
  39920. 'BlueValues',
  39921. 'OtherBlues',
  39922. 'FamilyBlues',
  39923. 'FamilyOtherBlues',
  39924. 'StemSnapH',
  39925. 'StemSnapV',
  39926. 'BlueShift',
  39927. 'BlueFuzz',
  39928. 'BlueScale',
  39929. 'LanguageGroup',
  39930. 'ExpansionFactor',
  39931. 'ForceBold',
  39932. 'StdHW',
  39933. 'StdVW'
  39934. ];
  39935. for (i = 0, ii = fields.length; i < ii; i++) {
  39936. var field = fields[i];
  39937. if (!(field in properties.privateData)) {
  39938. continue;
  39939. }
  39940. var value = properties.privateData[field];
  39941. if (isArray(value)) {
  39942. for (var j = value.length - 1; j > 0; j--) {
  39943. value[j] -= value[j - 1];
  39944. }
  39945. }
  39946. privateDict.setByName(field, value);
  39947. }
  39948. cff.topDict.privateDict = privateDict;
  39949. var subrIndex = new CFFIndex();
  39950. for (i = 0, ii = subrs.length; i < ii; i++) {
  39951. subrIndex.add(subrs[i]);
  39952. }
  39953. privateDict.subrsIndex = subrIndex;
  39954. var compiler = new CFFCompiler(cff);
  39955. return compiler.compile();
  39956. }
  39957. };
  39958. return Type1Font;
  39959. }();
  39960. var CFFFont = function CFFFontClosure() {
  39961. function CFFFont(file, properties) {
  39962. this.properties = properties;
  39963. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  39964. this.cff = parser.parse();
  39965. var compiler = new CFFCompiler(this.cff);
  39966. this.seacs = this.cff.seacs;
  39967. try {
  39968. this.data = compiler.compile();
  39969. } catch (e) {
  39970. warn('Failed to compile font ' + properties.loadedName);
  39971. this.data = file;
  39972. }
  39973. }
  39974. CFFFont.prototype = {
  39975. get numGlyphs() {
  39976. return this.cff.charStrings.count;
  39977. },
  39978. getCharset: function CFFFont_getCharset() {
  39979. return this.cff.charset.charset;
  39980. },
  39981. getGlyphMapping: function CFFFont_getGlyphMapping() {
  39982. var cff = this.cff;
  39983. var properties = this.properties;
  39984. var charsets = cff.charset.charset;
  39985. var charCodeToGlyphId;
  39986. var glyphId;
  39987. if (properties.composite) {
  39988. charCodeToGlyphId = Object.create(null);
  39989. if (cff.isCIDFont) {
  39990. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  39991. var cid = charsets[glyphId];
  39992. var charCode = properties.cMap.charCodeOf(cid);
  39993. charCodeToGlyphId[charCode] = glyphId;
  39994. }
  39995. } else {
  39996. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  39997. charCodeToGlyphId[glyphId] = glyphId;
  39998. }
  39999. }
  40000. return charCodeToGlyphId;
  40001. }
  40002. var encoding = cff.encoding ? cff.encoding.encoding : null;
  40003. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  40004. return charCodeToGlyphId;
  40005. }
  40006. };
  40007. return CFFFont;
  40008. }();
  40009. (function checkSeacSupport() {
  40010. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  40011. SEAC_ANALYSIS_ENABLED = true;
  40012. }
  40013. }());
  40014. (function checkChromeWindows() {
  40015. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  40016. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  40017. }
  40018. }());
  40019. exports.ErrorFont = ErrorFont;
  40020. exports.Font = Font;
  40021. exports.FontFlags = FontFlags;
  40022. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  40023. exports.ToUnicodeMap = ToUnicodeMap;
  40024. exports.getFontType = getFontType;
  40025. }));
  40026. (function (root, factory) {
  40027. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreParser);
  40028. }(this, function (exports, sharedUtil, coreParser) {
  40029. var error = sharedUtil.error;
  40030. var isSpace = sharedUtil.isSpace;
  40031. var EOF = coreParser.EOF;
  40032. var PostScriptParser = function PostScriptParserClosure() {
  40033. function PostScriptParser(lexer) {
  40034. this.lexer = lexer;
  40035. this.operators = [];
  40036. this.token = null;
  40037. this.prev = null;
  40038. }
  40039. PostScriptParser.prototype = {
  40040. nextToken: function PostScriptParser_nextToken() {
  40041. this.prev = this.token;
  40042. this.token = this.lexer.getToken();
  40043. },
  40044. accept: function PostScriptParser_accept(type) {
  40045. if (this.token.type === type) {
  40046. this.nextToken();
  40047. return true;
  40048. }
  40049. return false;
  40050. },
  40051. expect: function PostScriptParser_expect(type) {
  40052. if (this.accept(type)) {
  40053. return true;
  40054. }
  40055. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  40056. },
  40057. parse: function PostScriptParser_parse() {
  40058. this.nextToken();
  40059. this.expect(PostScriptTokenTypes.LBRACE);
  40060. this.parseBlock();
  40061. this.expect(PostScriptTokenTypes.RBRACE);
  40062. return this.operators;
  40063. },
  40064. parseBlock: function PostScriptParser_parseBlock() {
  40065. while (true) {
  40066. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  40067. this.operators.push(this.prev.value);
  40068. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  40069. this.operators.push(this.prev.value);
  40070. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  40071. this.parseCondition();
  40072. } else {
  40073. return;
  40074. }
  40075. }
  40076. },
  40077. parseCondition: function PostScriptParser_parseCondition() {
  40078. var conditionLocation = this.operators.length;
  40079. this.operators.push(null, null);
  40080. this.parseBlock();
  40081. this.expect(PostScriptTokenTypes.RBRACE);
  40082. if (this.accept(PostScriptTokenTypes.IF)) {
  40083. this.operators[conditionLocation] = this.operators.length;
  40084. this.operators[conditionLocation + 1] = 'jz';
  40085. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  40086. var jumpLocation = this.operators.length;
  40087. this.operators.push(null, null);
  40088. var endOfTrue = this.operators.length;
  40089. this.parseBlock();
  40090. this.expect(PostScriptTokenTypes.RBRACE);
  40091. this.expect(PostScriptTokenTypes.IFELSE);
  40092. this.operators[jumpLocation] = this.operators.length;
  40093. this.operators[jumpLocation + 1] = 'j';
  40094. this.operators[conditionLocation] = endOfTrue;
  40095. this.operators[conditionLocation + 1] = 'jz';
  40096. } else {
  40097. error('PS Function: error parsing conditional.');
  40098. }
  40099. }
  40100. };
  40101. return PostScriptParser;
  40102. }();
  40103. var PostScriptTokenTypes = {
  40104. LBRACE: 0,
  40105. RBRACE: 1,
  40106. NUMBER: 2,
  40107. OPERATOR: 3,
  40108. IF: 4,
  40109. IFELSE: 5
  40110. };
  40111. var PostScriptToken = function PostScriptTokenClosure() {
  40112. function PostScriptToken(type, value) {
  40113. this.type = type;
  40114. this.value = value;
  40115. }
  40116. var opCache = Object.create(null);
  40117. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  40118. var opValue = opCache[op];
  40119. if (opValue) {
  40120. return opValue;
  40121. }
  40122. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  40123. };
  40124. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  40125. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  40126. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  40127. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  40128. return PostScriptToken;
  40129. }();
  40130. var PostScriptLexer = function PostScriptLexerClosure() {
  40131. function PostScriptLexer(stream) {
  40132. this.stream = stream;
  40133. this.nextChar();
  40134. this.strBuf = [];
  40135. }
  40136. PostScriptLexer.prototype = {
  40137. nextChar: function PostScriptLexer_nextChar() {
  40138. return this.currentChar = this.stream.getByte();
  40139. },
  40140. getToken: function PostScriptLexer_getToken() {
  40141. var comment = false;
  40142. var ch = this.currentChar;
  40143. while (true) {
  40144. if (ch < 0) {
  40145. return EOF;
  40146. }
  40147. if (comment) {
  40148. if (ch === 0x0A || ch === 0x0D) {
  40149. comment = false;
  40150. }
  40151. } else if (ch === 0x25) {
  40152. comment = true;
  40153. } else if (!isSpace(ch)) {
  40154. break;
  40155. }
  40156. ch = this.nextChar();
  40157. }
  40158. switch (ch | 0) {
  40159. case 0x30:
  40160. case 0x31:
  40161. case 0x32:
  40162. case 0x33:
  40163. case 0x34:
  40164. case 0x35:
  40165. case 0x36:
  40166. case 0x37:
  40167. case 0x38:
  40168. case 0x39:
  40169. case 0x2B:
  40170. case 0x2D:
  40171. case 0x2E:
  40172. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  40173. case 0x7B:
  40174. this.nextChar();
  40175. return PostScriptToken.LBRACE;
  40176. case 0x7D:
  40177. this.nextChar();
  40178. return PostScriptToken.RBRACE;
  40179. }
  40180. var strBuf = this.strBuf;
  40181. strBuf.length = 0;
  40182. strBuf[0] = String.fromCharCode(ch);
  40183. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  40184. strBuf.push(String.fromCharCode(ch));
  40185. }
  40186. var str = strBuf.join('');
  40187. switch (str.toLowerCase()) {
  40188. case 'if':
  40189. return PostScriptToken.IF;
  40190. case 'ifelse':
  40191. return PostScriptToken.IFELSE;
  40192. default:
  40193. return PostScriptToken.getOperator(str);
  40194. }
  40195. },
  40196. getNumber: function PostScriptLexer_getNumber() {
  40197. var ch = this.currentChar;
  40198. var strBuf = this.strBuf;
  40199. strBuf.length = 0;
  40200. strBuf[0] = String.fromCharCode(ch);
  40201. while ((ch = this.nextChar()) >= 0) {
  40202. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  40203. strBuf.push(String.fromCharCode(ch));
  40204. } else {
  40205. break;
  40206. }
  40207. }
  40208. var value = parseFloat(strBuf.join(''));
  40209. if (isNaN(value)) {
  40210. error('Invalid floating point number: ' + value);
  40211. }
  40212. return value;
  40213. }
  40214. };
  40215. return PostScriptLexer;
  40216. }();
  40217. exports.PostScriptLexer = PostScriptLexer;
  40218. exports.PostScriptParser = PostScriptParser;
  40219. }));
  40220. (function (root, factory) {
  40221. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  40222. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  40223. var error = sharedUtil.error;
  40224. var info = sharedUtil.info;
  40225. var isArray = sharedUtil.isArray;
  40226. var isBool = sharedUtil.isBool;
  40227. var isDict = corePrimitives.isDict;
  40228. var isStream = corePrimitives.isStream;
  40229. var PostScriptLexer = corePsParser.PostScriptLexer;
  40230. var PostScriptParser = corePsParser.PostScriptParser;
  40231. var PDFFunction = function PDFFunctionClosure() {
  40232. var CONSTRUCT_SAMPLED = 0;
  40233. var CONSTRUCT_INTERPOLATED = 2;
  40234. var CONSTRUCT_STICHED = 3;
  40235. var CONSTRUCT_POSTSCRIPT = 4;
  40236. return {
  40237. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  40238. var i, ii;
  40239. var length = 1;
  40240. for (i = 0, ii = size.length; i < ii; i++) {
  40241. length *= size[i];
  40242. }
  40243. length *= outputSize;
  40244. var array = new Array(length);
  40245. var codeSize = 0;
  40246. var codeBuf = 0;
  40247. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  40248. var strBytes = str.getBytes((length * bps + 7) / 8);
  40249. var strIdx = 0;
  40250. for (i = 0; i < length; i++) {
  40251. while (codeSize < bps) {
  40252. codeBuf <<= 8;
  40253. codeBuf |= strBytes[strIdx++];
  40254. codeSize += 8;
  40255. }
  40256. codeSize -= bps;
  40257. array[i] = (codeBuf >> codeSize) * sampleMul;
  40258. codeBuf &= (1 << codeSize) - 1;
  40259. }
  40260. return array;
  40261. },
  40262. getIR: function PDFFunction_getIR(xref, fn) {
  40263. var dict = fn.dict;
  40264. if (!dict) {
  40265. dict = fn;
  40266. }
  40267. var types = [
  40268. this.constructSampled,
  40269. null,
  40270. this.constructInterpolated,
  40271. this.constructStiched,
  40272. this.constructPostScript
  40273. ];
  40274. var typeNum = dict.get('FunctionType');
  40275. var typeFn = types[typeNum];
  40276. if (!typeFn) {
  40277. error('Unknown type of function');
  40278. }
  40279. return typeFn.call(this, fn, dict, xref);
  40280. },
  40281. fromIR: function PDFFunction_fromIR(IR) {
  40282. var type = IR[0];
  40283. switch (type) {
  40284. case CONSTRUCT_SAMPLED:
  40285. return this.constructSampledFromIR(IR);
  40286. case CONSTRUCT_INTERPOLATED:
  40287. return this.constructInterpolatedFromIR(IR);
  40288. case CONSTRUCT_STICHED:
  40289. return this.constructStichedFromIR(IR);
  40290. default:
  40291. return this.constructPostScriptFromIR(IR);
  40292. }
  40293. },
  40294. parse: function PDFFunction_parse(xref, fn) {
  40295. var IR = this.getIR(xref, fn);
  40296. return this.fromIR(IR);
  40297. },
  40298. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  40299. if (!isArray(fnObj)) {
  40300. return this.parse(xref, fnObj);
  40301. }
  40302. var fnArray = [];
  40303. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  40304. var obj = xref.fetchIfRef(fnObj[j]);
  40305. fnArray.push(PDFFunction.parse(xref, obj));
  40306. }
  40307. return function (src, srcOffset, dest, destOffset) {
  40308. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  40309. fnArray[i](src, srcOffset, dest, destOffset + i);
  40310. }
  40311. };
  40312. },
  40313. constructSampled: function PDFFunction_constructSampled(str, dict) {
  40314. function toMultiArray(arr) {
  40315. var inputLength = arr.length;
  40316. var out = [];
  40317. var index = 0;
  40318. for (var i = 0; i < inputLength; i += 2) {
  40319. out[index] = [
  40320. arr[i],
  40321. arr[i + 1]
  40322. ];
  40323. ++index;
  40324. }
  40325. return out;
  40326. }
  40327. var domain = dict.getArray('Domain');
  40328. var range = dict.getArray('Range');
  40329. if (!domain || !range) {
  40330. error('No domain or range');
  40331. }
  40332. var inputSize = domain.length / 2;
  40333. var outputSize = range.length / 2;
  40334. domain = toMultiArray(domain);
  40335. range = toMultiArray(range);
  40336. var size = dict.get('Size');
  40337. var bps = dict.get('BitsPerSample');
  40338. var order = dict.get('Order') || 1;
  40339. if (order !== 1) {
  40340. info('No support for cubic spline interpolation: ' + order);
  40341. }
  40342. var encode = dict.getArray('Encode');
  40343. if (!encode) {
  40344. encode = [];
  40345. for (var i = 0; i < inputSize; ++i) {
  40346. encode.push(0);
  40347. encode.push(size[i] - 1);
  40348. }
  40349. }
  40350. encode = toMultiArray(encode);
  40351. var decode = dict.getArray('Decode');
  40352. if (!decode) {
  40353. decode = range;
  40354. } else {
  40355. decode = toMultiArray(decode);
  40356. }
  40357. var samples = this.getSampleArray(size, outputSize, bps, str);
  40358. return [
  40359. CONSTRUCT_SAMPLED,
  40360. inputSize,
  40361. domain,
  40362. encode,
  40363. decode,
  40364. samples,
  40365. size,
  40366. outputSize,
  40367. Math.pow(2, bps) - 1,
  40368. range
  40369. ];
  40370. },
  40371. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  40372. function interpolate(x, xmin, xmax, ymin, ymax) {
  40373. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  40374. }
  40375. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  40376. var m = IR[1];
  40377. var domain = IR[2];
  40378. var encode = IR[3];
  40379. var decode = IR[4];
  40380. var samples = IR[5];
  40381. var size = IR[6];
  40382. var n = IR[7];
  40383. var range = IR[9];
  40384. var cubeVertices = 1 << m;
  40385. var cubeN = new Float64Array(cubeVertices);
  40386. var cubeVertex = new Uint32Array(cubeVertices);
  40387. var i, j;
  40388. for (j = 0; j < cubeVertices; j++) {
  40389. cubeN[j] = 1;
  40390. }
  40391. var k = n, pos = 1;
  40392. for (i = 0; i < m; ++i) {
  40393. var domain_2i = domain[i][0];
  40394. var domain_2i_1 = domain[i][1];
  40395. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  40396. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  40397. var size_i = size[i];
  40398. e = Math.min(Math.max(e, 0), size_i - 1);
  40399. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  40400. var n0 = e0 + 1 - e;
  40401. var n1 = e - e0;
  40402. var offset0 = e0 * k;
  40403. var offset1 = offset0 + k;
  40404. for (j = 0; j < cubeVertices; j++) {
  40405. if (j & pos) {
  40406. cubeN[j] *= n1;
  40407. cubeVertex[j] += offset1;
  40408. } else {
  40409. cubeN[j] *= n0;
  40410. cubeVertex[j] += offset0;
  40411. }
  40412. }
  40413. k *= size_i;
  40414. pos <<= 1;
  40415. }
  40416. for (j = 0; j < n; ++j) {
  40417. var rj = 0;
  40418. for (i = 0; i < cubeVertices; i++) {
  40419. rj += samples[cubeVertex[i] + j] * cubeN[i];
  40420. }
  40421. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  40422. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  40423. }
  40424. };
  40425. },
  40426. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  40427. var c0 = dict.getArray('C0') || [0];
  40428. var c1 = dict.getArray('C1') || [1];
  40429. var n = dict.get('N');
  40430. if (!isArray(c0) || !isArray(c1)) {
  40431. error('Illegal dictionary for interpolated function');
  40432. }
  40433. var length = c0.length;
  40434. var diff = [];
  40435. for (var i = 0; i < length; ++i) {
  40436. diff.push(c1[i] - c0[i]);
  40437. }
  40438. return [
  40439. CONSTRUCT_INTERPOLATED,
  40440. c0,
  40441. diff,
  40442. n
  40443. ];
  40444. },
  40445. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  40446. var c0 = IR[1];
  40447. var diff = IR[2];
  40448. var n = IR[3];
  40449. var length = diff.length;
  40450. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  40451. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  40452. for (var j = 0; j < length; ++j) {
  40453. dest[destOffset + j] = c0[j] + x * diff[j];
  40454. }
  40455. };
  40456. },
  40457. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  40458. var domain = dict.getArray('Domain');
  40459. if (!domain) {
  40460. error('No domain');
  40461. }
  40462. var inputSize = domain.length / 2;
  40463. if (inputSize !== 1) {
  40464. error('Bad domain for stiched function');
  40465. }
  40466. var fnRefs = dict.get('Functions');
  40467. var fns = [];
  40468. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  40469. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  40470. }
  40471. var bounds = dict.getArray('Bounds');
  40472. var encode = dict.getArray('Encode');
  40473. return [
  40474. CONSTRUCT_STICHED,
  40475. domain,
  40476. bounds,
  40477. encode,
  40478. fns
  40479. ];
  40480. },
  40481. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  40482. var domain = IR[1];
  40483. var bounds = IR[2];
  40484. var encode = IR[3];
  40485. var fnsIR = IR[4];
  40486. var fns = [];
  40487. var tmpBuf = new Float32Array(1);
  40488. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  40489. fns.push(PDFFunction.fromIR(fnsIR[i]));
  40490. }
  40491. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  40492. var clip = function constructStichedFromIRClip(v, min, max) {
  40493. if (v > max) {
  40494. v = max;
  40495. } else if (v < min) {
  40496. v = min;
  40497. }
  40498. return v;
  40499. };
  40500. var v = clip(src[srcOffset], domain[0], domain[1]);
  40501. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  40502. if (v < bounds[i]) {
  40503. break;
  40504. }
  40505. }
  40506. var dmin = domain[0];
  40507. if (i > 0) {
  40508. dmin = bounds[i - 1];
  40509. }
  40510. var dmax = domain[1];
  40511. if (i < bounds.length) {
  40512. dmax = bounds[i];
  40513. }
  40514. var rmin = encode[2 * i];
  40515. var rmax = encode[2 * i + 1];
  40516. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  40517. fns[i](tmpBuf, 0, dest, destOffset);
  40518. };
  40519. },
  40520. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  40521. var domain = dict.getArray('Domain');
  40522. var range = dict.getArray('Range');
  40523. if (!domain) {
  40524. error('No domain.');
  40525. }
  40526. if (!range) {
  40527. error('No range.');
  40528. }
  40529. var lexer = new PostScriptLexer(fn);
  40530. var parser = new PostScriptParser(lexer);
  40531. var code = parser.parse();
  40532. return [
  40533. CONSTRUCT_POSTSCRIPT,
  40534. domain,
  40535. range,
  40536. code
  40537. ];
  40538. },
  40539. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  40540. var domain = IR[1];
  40541. var range = IR[2];
  40542. var code = IR[3];
  40543. var compiled = new PostScriptCompiler().compile(code, domain, range);
  40544. if (compiled) {
  40545. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  40546. }
  40547. info('Unable to compile PS function');
  40548. var numOutputs = range.length >> 1;
  40549. var numInputs = domain.length >> 1;
  40550. var evaluator = new PostScriptEvaluator(code);
  40551. var cache = Object.create(null);
  40552. var MAX_CACHE_SIZE = 2048 * 4;
  40553. var cache_available = MAX_CACHE_SIZE;
  40554. var tmpBuf = new Float32Array(numInputs);
  40555. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  40556. var i, value;
  40557. var key = '';
  40558. var input = tmpBuf;
  40559. for (i = 0; i < numInputs; i++) {
  40560. value = src[srcOffset + i];
  40561. input[i] = value;
  40562. key += value + '_';
  40563. }
  40564. var cachedValue = cache[key];
  40565. if (cachedValue !== undefined) {
  40566. dest.set(cachedValue, destOffset);
  40567. return;
  40568. }
  40569. var output = new Float32Array(numOutputs);
  40570. var stack = evaluator.execute(input);
  40571. var stackIndex = stack.length - numOutputs;
  40572. for (i = 0; i < numOutputs; i++) {
  40573. value = stack[stackIndex + i];
  40574. var bound = range[i * 2];
  40575. if (value < bound) {
  40576. value = bound;
  40577. } else {
  40578. bound = range[i * 2 + 1];
  40579. if (value > bound) {
  40580. value = bound;
  40581. }
  40582. }
  40583. output[i] = value;
  40584. }
  40585. if (cache_available > 0) {
  40586. cache_available--;
  40587. cache[key] = output;
  40588. }
  40589. dest.set(output, destOffset);
  40590. };
  40591. }
  40592. };
  40593. }();
  40594. function isPDFFunction(v) {
  40595. var fnDict;
  40596. if (typeof v !== 'object') {
  40597. return false;
  40598. } else if (isDict(v)) {
  40599. fnDict = v;
  40600. } else if (isStream(v)) {
  40601. fnDict = v.dict;
  40602. } else {
  40603. return false;
  40604. }
  40605. return fnDict.has('FunctionType');
  40606. }
  40607. var PostScriptStack = function PostScriptStackClosure() {
  40608. var MAX_STACK_SIZE = 100;
  40609. function PostScriptStack(initialStack) {
  40610. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  40611. }
  40612. PostScriptStack.prototype = {
  40613. push: function PostScriptStack_push(value) {
  40614. if (this.stack.length >= MAX_STACK_SIZE) {
  40615. error('PostScript function stack overflow.');
  40616. }
  40617. this.stack.push(value);
  40618. },
  40619. pop: function PostScriptStack_pop() {
  40620. if (this.stack.length <= 0) {
  40621. error('PostScript function stack underflow.');
  40622. }
  40623. return this.stack.pop();
  40624. },
  40625. copy: function PostScriptStack_copy(n) {
  40626. if (this.stack.length + n >= MAX_STACK_SIZE) {
  40627. error('PostScript function stack overflow.');
  40628. }
  40629. var stack = this.stack;
  40630. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  40631. stack.push(stack[i]);
  40632. }
  40633. },
  40634. index: function PostScriptStack_index(n) {
  40635. this.push(this.stack[this.stack.length - n - 1]);
  40636. },
  40637. roll: function PostScriptStack_roll(n, p) {
  40638. var stack = this.stack;
  40639. var l = stack.length - n;
  40640. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  40641. for (i = l, j = r; i < j; i++, j--) {
  40642. t = stack[i];
  40643. stack[i] = stack[j];
  40644. stack[j] = t;
  40645. }
  40646. for (i = l, j = c - 1; i < j; i++, j--) {
  40647. t = stack[i];
  40648. stack[i] = stack[j];
  40649. stack[j] = t;
  40650. }
  40651. for (i = c, j = r; i < j; i++, j--) {
  40652. t = stack[i];
  40653. stack[i] = stack[j];
  40654. stack[j] = t;
  40655. }
  40656. }
  40657. };
  40658. return PostScriptStack;
  40659. }();
  40660. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  40661. function PostScriptEvaluator(operators) {
  40662. this.operators = operators;
  40663. }
  40664. PostScriptEvaluator.prototype = {
  40665. execute: function PostScriptEvaluator_execute(initialStack) {
  40666. var stack = new PostScriptStack(initialStack);
  40667. var counter = 0;
  40668. var operators = this.operators;
  40669. var length = operators.length;
  40670. var operator, a, b;
  40671. while (counter < length) {
  40672. operator = operators[counter++];
  40673. if (typeof operator === 'number') {
  40674. stack.push(operator);
  40675. continue;
  40676. }
  40677. switch (operator) {
  40678. case 'jz':
  40679. b = stack.pop();
  40680. a = stack.pop();
  40681. if (!a) {
  40682. counter = b;
  40683. }
  40684. break;
  40685. case 'j':
  40686. a = stack.pop();
  40687. counter = a;
  40688. break;
  40689. case 'abs':
  40690. a = stack.pop();
  40691. stack.push(Math.abs(a));
  40692. break;
  40693. case 'add':
  40694. b = stack.pop();
  40695. a = stack.pop();
  40696. stack.push(a + b);
  40697. break;
  40698. case 'and':
  40699. b = stack.pop();
  40700. a = stack.pop();
  40701. if (isBool(a) && isBool(b)) {
  40702. stack.push(a && b);
  40703. } else {
  40704. stack.push(a & b);
  40705. }
  40706. break;
  40707. case 'atan':
  40708. a = stack.pop();
  40709. stack.push(Math.atan(a));
  40710. break;
  40711. case 'bitshift':
  40712. b = stack.pop();
  40713. a = stack.pop();
  40714. if (a > 0) {
  40715. stack.push(a << b);
  40716. } else {
  40717. stack.push(a >> b);
  40718. }
  40719. break;
  40720. case 'ceiling':
  40721. a = stack.pop();
  40722. stack.push(Math.ceil(a));
  40723. break;
  40724. case 'copy':
  40725. a = stack.pop();
  40726. stack.copy(a);
  40727. break;
  40728. case 'cos':
  40729. a = stack.pop();
  40730. stack.push(Math.cos(a));
  40731. break;
  40732. case 'cvi':
  40733. a = stack.pop() | 0;
  40734. stack.push(a);
  40735. break;
  40736. case 'cvr':
  40737. break;
  40738. case 'div':
  40739. b = stack.pop();
  40740. a = stack.pop();
  40741. stack.push(a / b);
  40742. break;
  40743. case 'dup':
  40744. stack.copy(1);
  40745. break;
  40746. case 'eq':
  40747. b = stack.pop();
  40748. a = stack.pop();
  40749. stack.push(a === b);
  40750. break;
  40751. case 'exch':
  40752. stack.roll(2, 1);
  40753. break;
  40754. case 'exp':
  40755. b = stack.pop();
  40756. a = stack.pop();
  40757. stack.push(Math.pow(a, b));
  40758. break;
  40759. case 'false':
  40760. stack.push(false);
  40761. break;
  40762. case 'floor':
  40763. a = stack.pop();
  40764. stack.push(Math.floor(a));
  40765. break;
  40766. case 'ge':
  40767. b = stack.pop();
  40768. a = stack.pop();
  40769. stack.push(a >= b);
  40770. break;
  40771. case 'gt':
  40772. b = stack.pop();
  40773. a = stack.pop();
  40774. stack.push(a > b);
  40775. break;
  40776. case 'idiv':
  40777. b = stack.pop();
  40778. a = stack.pop();
  40779. stack.push(a / b | 0);
  40780. break;
  40781. case 'index':
  40782. a = stack.pop();
  40783. stack.index(a);
  40784. break;
  40785. case 'le':
  40786. b = stack.pop();
  40787. a = stack.pop();
  40788. stack.push(a <= b);
  40789. break;
  40790. case 'ln':
  40791. a = stack.pop();
  40792. stack.push(Math.log(a));
  40793. break;
  40794. case 'log':
  40795. a = stack.pop();
  40796. stack.push(Math.log(a) / Math.LN10);
  40797. break;
  40798. case 'lt':
  40799. b = stack.pop();
  40800. a = stack.pop();
  40801. stack.push(a < b);
  40802. break;
  40803. case 'mod':
  40804. b = stack.pop();
  40805. a = stack.pop();
  40806. stack.push(a % b);
  40807. break;
  40808. case 'mul':
  40809. b = stack.pop();
  40810. a = stack.pop();
  40811. stack.push(a * b);
  40812. break;
  40813. case 'ne':
  40814. b = stack.pop();
  40815. a = stack.pop();
  40816. stack.push(a !== b);
  40817. break;
  40818. case 'neg':
  40819. a = stack.pop();
  40820. stack.push(-a);
  40821. break;
  40822. case 'not':
  40823. a = stack.pop();
  40824. if (isBool(a)) {
  40825. stack.push(!a);
  40826. } else {
  40827. stack.push(~a);
  40828. }
  40829. break;
  40830. case 'or':
  40831. b = stack.pop();
  40832. a = stack.pop();
  40833. if (isBool(a) && isBool(b)) {
  40834. stack.push(a || b);
  40835. } else {
  40836. stack.push(a | b);
  40837. }
  40838. break;
  40839. case 'pop':
  40840. stack.pop();
  40841. break;
  40842. case 'roll':
  40843. b = stack.pop();
  40844. a = stack.pop();
  40845. stack.roll(a, b);
  40846. break;
  40847. case 'round':
  40848. a = stack.pop();
  40849. stack.push(Math.round(a));
  40850. break;
  40851. case 'sin':
  40852. a = stack.pop();
  40853. stack.push(Math.sin(a));
  40854. break;
  40855. case 'sqrt':
  40856. a = stack.pop();
  40857. stack.push(Math.sqrt(a));
  40858. break;
  40859. case 'sub':
  40860. b = stack.pop();
  40861. a = stack.pop();
  40862. stack.push(a - b);
  40863. break;
  40864. case 'true':
  40865. stack.push(true);
  40866. break;
  40867. case 'truncate':
  40868. a = stack.pop();
  40869. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  40870. stack.push(a);
  40871. break;
  40872. case 'xor':
  40873. b = stack.pop();
  40874. a = stack.pop();
  40875. if (isBool(a) && isBool(b)) {
  40876. stack.push(a !== b);
  40877. } else {
  40878. stack.push(a ^ b);
  40879. }
  40880. break;
  40881. default:
  40882. error('Unknown operator ' + operator);
  40883. break;
  40884. }
  40885. }
  40886. return stack.stack;
  40887. }
  40888. };
  40889. return PostScriptEvaluator;
  40890. }();
  40891. var PostScriptCompiler = function PostScriptCompilerClosure() {
  40892. function AstNode(type) {
  40893. this.type = type;
  40894. }
  40895. AstNode.prototype.visit = function (visitor) {
  40896. throw new Error('abstract method');
  40897. };
  40898. function AstArgument(index, min, max) {
  40899. AstNode.call(this, 'args');
  40900. this.index = index;
  40901. this.min = min;
  40902. this.max = max;
  40903. }
  40904. AstArgument.prototype = Object.create(AstNode.prototype);
  40905. AstArgument.prototype.visit = function (visitor) {
  40906. visitor.visitArgument(this);
  40907. };
  40908. function AstLiteral(number) {
  40909. AstNode.call(this, 'literal');
  40910. this.number = number;
  40911. this.min = number;
  40912. this.max = number;
  40913. }
  40914. AstLiteral.prototype = Object.create(AstNode.prototype);
  40915. AstLiteral.prototype.visit = function (visitor) {
  40916. visitor.visitLiteral(this);
  40917. };
  40918. function AstBinaryOperation(op, arg1, arg2, min, max) {
  40919. AstNode.call(this, 'binary');
  40920. this.op = op;
  40921. this.arg1 = arg1;
  40922. this.arg2 = arg2;
  40923. this.min = min;
  40924. this.max = max;
  40925. }
  40926. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  40927. AstBinaryOperation.prototype.visit = function (visitor) {
  40928. visitor.visitBinaryOperation(this);
  40929. };
  40930. function AstMin(arg, max) {
  40931. AstNode.call(this, 'max');
  40932. this.arg = arg;
  40933. this.min = arg.min;
  40934. this.max = max;
  40935. }
  40936. AstMin.prototype = Object.create(AstNode.prototype);
  40937. AstMin.prototype.visit = function (visitor) {
  40938. visitor.visitMin(this);
  40939. };
  40940. function AstVariable(index, min, max) {
  40941. AstNode.call(this, 'var');
  40942. this.index = index;
  40943. this.min = min;
  40944. this.max = max;
  40945. }
  40946. AstVariable.prototype = Object.create(AstNode.prototype);
  40947. AstVariable.prototype.visit = function (visitor) {
  40948. visitor.visitVariable(this);
  40949. };
  40950. function AstVariableDefinition(variable, arg) {
  40951. AstNode.call(this, 'definition');
  40952. this.variable = variable;
  40953. this.arg = arg;
  40954. }
  40955. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  40956. AstVariableDefinition.prototype.visit = function (visitor) {
  40957. visitor.visitVariableDefinition(this);
  40958. };
  40959. function ExpressionBuilderVisitor() {
  40960. this.parts = [];
  40961. }
  40962. ExpressionBuilderVisitor.prototype = {
  40963. visitArgument: function (arg) {
  40964. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  40965. },
  40966. visitVariable: function (variable) {
  40967. this.parts.push('v', variable.index);
  40968. },
  40969. visitLiteral: function (literal) {
  40970. this.parts.push(literal.number);
  40971. },
  40972. visitBinaryOperation: function (operation) {
  40973. this.parts.push('(');
  40974. operation.arg1.visit(this);
  40975. this.parts.push(' ', operation.op, ' ');
  40976. operation.arg2.visit(this);
  40977. this.parts.push(')');
  40978. },
  40979. visitVariableDefinition: function (definition) {
  40980. this.parts.push('var ');
  40981. definition.variable.visit(this);
  40982. this.parts.push(' = ');
  40983. definition.arg.visit(this);
  40984. this.parts.push(';');
  40985. },
  40986. visitMin: function (max) {
  40987. this.parts.push('Math.min(');
  40988. max.arg.visit(this);
  40989. this.parts.push(', ', max.max, ')');
  40990. },
  40991. toString: function () {
  40992. return this.parts.join('');
  40993. }
  40994. };
  40995. function buildAddOperation(num1, num2) {
  40996. if (num2.type === 'literal' && num2.number === 0) {
  40997. return num1;
  40998. }
  40999. if (num1.type === 'literal' && num1.number === 0) {
  41000. return num2;
  41001. }
  41002. if (num2.type === 'literal' && num1.type === 'literal') {
  41003. return new AstLiteral(num1.number + num2.number);
  41004. }
  41005. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  41006. }
  41007. function buildMulOperation(num1, num2) {
  41008. if (num2.type === 'literal') {
  41009. if (num2.number === 0) {
  41010. return new AstLiteral(0);
  41011. } else if (num2.number === 1) {
  41012. return num1;
  41013. } else if (num1.type === 'literal') {
  41014. return new AstLiteral(num1.number * num2.number);
  41015. }
  41016. }
  41017. if (num1.type === 'literal') {
  41018. if (num1.number === 0) {
  41019. return new AstLiteral(0);
  41020. } else if (num1.number === 1) {
  41021. return num2;
  41022. }
  41023. }
  41024. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  41025. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  41026. return new AstBinaryOperation('*', num1, num2, min, max);
  41027. }
  41028. function buildSubOperation(num1, num2) {
  41029. if (num2.type === 'literal') {
  41030. if (num2.number === 0) {
  41031. return num1;
  41032. } else if (num1.type === 'literal') {
  41033. return new AstLiteral(num1.number - num2.number);
  41034. }
  41035. }
  41036. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  41037. return num2.arg2;
  41038. }
  41039. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  41040. }
  41041. function buildMinOperation(num1, max) {
  41042. if (num1.min >= max) {
  41043. return new AstLiteral(max);
  41044. } else if (num1.max <= max) {
  41045. return num1;
  41046. }
  41047. return new AstMin(num1, max);
  41048. }
  41049. function PostScriptCompiler() {
  41050. }
  41051. PostScriptCompiler.prototype = {
  41052. compile: function PostScriptCompiler_compile(code, domain, range) {
  41053. var stack = [];
  41054. var i, ii;
  41055. var instructions = [];
  41056. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  41057. var lastRegister = 0;
  41058. var n, j;
  41059. var num1, num2, ast1, ast2, tmpVar, item;
  41060. for (i = 0; i < inputSize; i++) {
  41061. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  41062. }
  41063. for (i = 0, ii = code.length; i < ii; i++) {
  41064. item = code[i];
  41065. if (typeof item === 'number') {
  41066. stack.push(new AstLiteral(item));
  41067. continue;
  41068. }
  41069. switch (item) {
  41070. case 'add':
  41071. if (stack.length < 2) {
  41072. return null;
  41073. }
  41074. num2 = stack.pop();
  41075. num1 = stack.pop();
  41076. stack.push(buildAddOperation(num1, num2));
  41077. break;
  41078. case 'cvr':
  41079. if (stack.length < 1) {
  41080. return null;
  41081. }
  41082. break;
  41083. case 'mul':
  41084. if (stack.length < 2) {
  41085. return null;
  41086. }
  41087. num2 = stack.pop();
  41088. num1 = stack.pop();
  41089. stack.push(buildMulOperation(num1, num2));
  41090. break;
  41091. case 'sub':
  41092. if (stack.length < 2) {
  41093. return null;
  41094. }
  41095. num2 = stack.pop();
  41096. num1 = stack.pop();
  41097. stack.push(buildSubOperation(num1, num2));
  41098. break;
  41099. case 'exch':
  41100. if (stack.length < 2) {
  41101. return null;
  41102. }
  41103. ast1 = stack.pop();
  41104. ast2 = stack.pop();
  41105. stack.push(ast1, ast2);
  41106. break;
  41107. case 'pop':
  41108. if (stack.length < 1) {
  41109. return null;
  41110. }
  41111. stack.pop();
  41112. break;
  41113. case 'index':
  41114. if (stack.length < 1) {
  41115. return null;
  41116. }
  41117. num1 = stack.pop();
  41118. if (num1.type !== 'literal') {
  41119. return null;
  41120. }
  41121. n = num1.number;
  41122. if (n < 0 || (n | 0) !== n || stack.length < n) {
  41123. return null;
  41124. }
  41125. ast1 = stack[stack.length - n - 1];
  41126. if (ast1.type === 'literal' || ast1.type === 'var') {
  41127. stack.push(ast1);
  41128. break;
  41129. }
  41130. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  41131. stack[stack.length - n - 1] = tmpVar;
  41132. stack.push(tmpVar);
  41133. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  41134. break;
  41135. case 'dup':
  41136. if (stack.length < 1) {
  41137. return null;
  41138. }
  41139. 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]) {
  41140. num1 = stack.pop();
  41141. stack.push(buildMinOperation(num1, code[i + 1]));
  41142. i += 6;
  41143. break;
  41144. }
  41145. ast1 = stack[stack.length - 1];
  41146. if (ast1.type === 'literal' || ast1.type === 'var') {
  41147. stack.push(ast1);
  41148. break;
  41149. }
  41150. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  41151. stack[stack.length - 1] = tmpVar;
  41152. stack.push(tmpVar);
  41153. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  41154. break;
  41155. case 'roll':
  41156. if (stack.length < 2) {
  41157. return null;
  41158. }
  41159. num2 = stack.pop();
  41160. num1 = stack.pop();
  41161. if (num2.type !== 'literal' || num1.type !== 'literal') {
  41162. return null;
  41163. }
  41164. j = num2.number;
  41165. n = num1.number;
  41166. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  41167. return null;
  41168. }
  41169. j = (j % n + n) % n;
  41170. if (j === 0) {
  41171. break;
  41172. }
  41173. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  41174. break;
  41175. default:
  41176. return null;
  41177. }
  41178. }
  41179. if (stack.length !== outputSize) {
  41180. return null;
  41181. }
  41182. var result = [];
  41183. instructions.forEach(function (instruction) {
  41184. var statementBuilder = new ExpressionBuilderVisitor();
  41185. instruction.visit(statementBuilder);
  41186. result.push(statementBuilder.toString());
  41187. });
  41188. stack.forEach(function (expr, i) {
  41189. var statementBuilder = new ExpressionBuilderVisitor();
  41190. expr.visit(statementBuilder);
  41191. var min = range[i * 2], max = range[i * 2 + 1];
  41192. var out = [statementBuilder.toString()];
  41193. if (min > expr.min) {
  41194. out.unshift('Math.max(', min, ', ');
  41195. out.push(')');
  41196. }
  41197. if (max < expr.max) {
  41198. out.unshift('Math.min(', max, ', ');
  41199. out.push(')');
  41200. }
  41201. out.unshift('dest[destOffset + ', i, '] = ');
  41202. out.push(';');
  41203. result.push(out.join(''));
  41204. });
  41205. return result.join('\n');
  41206. }
  41207. };
  41208. return PostScriptCompiler;
  41209. }();
  41210. exports.isPDFFunction = isPDFFunction;
  41211. exports.PDFFunction = PDFFunction;
  41212. exports.PostScriptEvaluator = PostScriptEvaluator;
  41213. exports.PostScriptCompiler = PostScriptCompiler;
  41214. }));
  41215. (function (root, factory) {
  41216. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  41217. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  41218. var error = sharedUtil.error;
  41219. var info = sharedUtil.info;
  41220. var isArray = sharedUtil.isArray;
  41221. var isString = sharedUtil.isString;
  41222. var shadow = sharedUtil.shadow;
  41223. var warn = sharedUtil.warn;
  41224. var isDict = corePrimitives.isDict;
  41225. var isName = corePrimitives.isName;
  41226. var isStream = corePrimitives.isStream;
  41227. var PDFFunction = coreFunction.PDFFunction;
  41228. var ColorSpace = function ColorSpaceClosure() {
  41229. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  41230. var COMPONENTS = 3;
  41231. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  41232. var xRatio = w1 / w2;
  41233. var yRatio = h1 / h2;
  41234. var i, j, py, newIndex = 0, oldIndex;
  41235. var xScaled = new Uint16Array(w2);
  41236. var w1Scanline = w1 * COMPONENTS;
  41237. for (i = 0; i < w2; i++) {
  41238. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  41239. }
  41240. for (i = 0; i < h2; i++) {
  41241. py = Math.floor(i * yRatio) * w1Scanline;
  41242. for (j = 0; j < w2; j++) {
  41243. oldIndex = py + xScaled[j];
  41244. dest[newIndex++] = src[oldIndex++];
  41245. dest[newIndex++] = src[oldIndex++];
  41246. dest[newIndex++] = src[oldIndex++];
  41247. newIndex += alpha01;
  41248. }
  41249. }
  41250. }
  41251. function ColorSpace() {
  41252. error('should not call ColorSpace constructor');
  41253. }
  41254. ColorSpace.prototype = {
  41255. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  41256. var rgb = new Uint8Array(3);
  41257. this.getRgbItem(src, srcOffset, rgb, 0);
  41258. return rgb;
  41259. },
  41260. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  41261. error('Should not call ColorSpace.getRgbItem');
  41262. },
  41263. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41264. error('Should not call ColorSpace.getRgbBuffer');
  41265. },
  41266. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  41267. error('Should not call ColorSpace.getOutputLength');
  41268. },
  41269. isPassthrough: function ColorSpace_isPassthrough(bits) {
  41270. return false;
  41271. },
  41272. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  41273. var count = originalWidth * originalHeight;
  41274. var rgbBuf = null;
  41275. var numComponentColors = 1 << bpc;
  41276. var needsResizing = originalHeight !== height || originalWidth !== width;
  41277. var i, ii;
  41278. if (this.isPassthrough(bpc)) {
  41279. rgbBuf = comps;
  41280. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  41281. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  41282. var key;
  41283. for (i = 0; i < numComponentColors; i++) {
  41284. allColors[i] = i;
  41285. }
  41286. var colorMap = new Uint8Array(numComponentColors * 3);
  41287. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  41288. var destPos, rgbPos;
  41289. if (!needsResizing) {
  41290. destPos = 0;
  41291. for (i = 0; i < count; ++i) {
  41292. key = comps[i] * 3;
  41293. dest[destPos++] = colorMap[key];
  41294. dest[destPos++] = colorMap[key + 1];
  41295. dest[destPos++] = colorMap[key + 2];
  41296. destPos += alpha01;
  41297. }
  41298. } else {
  41299. rgbBuf = new Uint8Array(count * 3);
  41300. rgbPos = 0;
  41301. for (i = 0; i < count; ++i) {
  41302. key = comps[i] * 3;
  41303. rgbBuf[rgbPos++] = colorMap[key];
  41304. rgbBuf[rgbPos++] = colorMap[key + 1];
  41305. rgbBuf[rgbPos++] = colorMap[key + 2];
  41306. }
  41307. }
  41308. } else {
  41309. if (!needsResizing) {
  41310. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  41311. } else {
  41312. rgbBuf = new Uint8Array(count * 3);
  41313. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  41314. }
  41315. }
  41316. if (rgbBuf) {
  41317. if (needsResizing) {
  41318. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  41319. } else {
  41320. rgbPos = 0;
  41321. destPos = 0;
  41322. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  41323. dest[destPos++] = rgbBuf[rgbPos++];
  41324. dest[destPos++] = rgbBuf[rgbPos++];
  41325. dest[destPos++] = rgbBuf[rgbPos++];
  41326. destPos += alpha01;
  41327. }
  41328. }
  41329. }
  41330. },
  41331. usesZeroToOneRange: true
  41332. };
  41333. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  41334. var IR = ColorSpace.parseToIR(cs, xref, res);
  41335. if (IR instanceof AlternateCS) {
  41336. return IR;
  41337. }
  41338. return ColorSpace.fromIR(IR);
  41339. };
  41340. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  41341. var name = isArray(IR) ? IR[0] : IR;
  41342. var whitePoint, blackPoint, gamma;
  41343. switch (name) {
  41344. case 'DeviceGrayCS':
  41345. return this.singletons.gray;
  41346. case 'DeviceRgbCS':
  41347. return this.singletons.rgb;
  41348. case 'DeviceCmykCS':
  41349. return this.singletons.cmyk;
  41350. case 'CalGrayCS':
  41351. whitePoint = IR[1];
  41352. blackPoint = IR[2];
  41353. gamma = IR[3];
  41354. return new CalGrayCS(whitePoint, blackPoint, gamma);
  41355. case 'CalRGBCS':
  41356. whitePoint = IR[1];
  41357. blackPoint = IR[2];
  41358. gamma = IR[3];
  41359. var matrix = IR[4];
  41360. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  41361. case 'PatternCS':
  41362. var basePatternCS = IR[1];
  41363. if (basePatternCS) {
  41364. basePatternCS = ColorSpace.fromIR(basePatternCS);
  41365. }
  41366. return new PatternCS(basePatternCS);
  41367. case 'IndexedCS':
  41368. var baseIndexedCS = IR[1];
  41369. var hiVal = IR[2];
  41370. var lookup = IR[3];
  41371. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  41372. case 'AlternateCS':
  41373. var numComps = IR[1];
  41374. var alt = IR[2];
  41375. var tintFnIR = IR[3];
  41376. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  41377. case 'LabCS':
  41378. whitePoint = IR[1];
  41379. blackPoint = IR[2];
  41380. var range = IR[3];
  41381. return new LabCS(whitePoint, blackPoint, range);
  41382. default:
  41383. error('Unknown name ' + name);
  41384. }
  41385. return null;
  41386. };
  41387. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  41388. if (isName(cs)) {
  41389. var colorSpaces = res.get('ColorSpace');
  41390. if (isDict(colorSpaces)) {
  41391. var refcs = colorSpaces.get(cs.name);
  41392. if (refcs) {
  41393. cs = refcs;
  41394. }
  41395. }
  41396. }
  41397. cs = xref.fetchIfRef(cs);
  41398. if (isName(cs)) {
  41399. switch (cs.name) {
  41400. case 'DeviceGray':
  41401. case 'G':
  41402. return 'DeviceGrayCS';
  41403. case 'DeviceRGB':
  41404. case 'RGB':
  41405. return 'DeviceRgbCS';
  41406. case 'DeviceCMYK':
  41407. case 'CMYK':
  41408. return 'DeviceCmykCS';
  41409. case 'Pattern':
  41410. return [
  41411. 'PatternCS',
  41412. null
  41413. ];
  41414. default:
  41415. error('unrecognized colorspace ' + cs.name);
  41416. }
  41417. } else if (isArray(cs)) {
  41418. var mode = xref.fetchIfRef(cs[0]).name;
  41419. var numComps, params, alt, whitePoint, blackPoint, gamma;
  41420. switch (mode) {
  41421. case 'DeviceGray':
  41422. case 'G':
  41423. return 'DeviceGrayCS';
  41424. case 'DeviceRGB':
  41425. case 'RGB':
  41426. return 'DeviceRgbCS';
  41427. case 'DeviceCMYK':
  41428. case 'CMYK':
  41429. return 'DeviceCmykCS';
  41430. case 'CalGray':
  41431. params = xref.fetchIfRef(cs[1]);
  41432. whitePoint = params.getArray('WhitePoint');
  41433. blackPoint = params.getArray('BlackPoint');
  41434. gamma = params.get('Gamma');
  41435. return [
  41436. 'CalGrayCS',
  41437. whitePoint,
  41438. blackPoint,
  41439. gamma
  41440. ];
  41441. case 'CalRGB':
  41442. params = xref.fetchIfRef(cs[1]);
  41443. whitePoint = params.getArray('WhitePoint');
  41444. blackPoint = params.getArray('BlackPoint');
  41445. gamma = params.getArray('Gamma');
  41446. var matrix = params.getArray('Matrix');
  41447. return [
  41448. 'CalRGBCS',
  41449. whitePoint,
  41450. blackPoint,
  41451. gamma,
  41452. matrix
  41453. ];
  41454. case 'ICCBased':
  41455. var stream = xref.fetchIfRef(cs[1]);
  41456. var dict = stream.dict;
  41457. numComps = dict.get('N');
  41458. alt = dict.get('Alternate');
  41459. if (alt) {
  41460. var altIR = ColorSpace.parseToIR(alt, xref, res);
  41461. var altCS = ColorSpace.fromIR(altIR);
  41462. if (altCS.numComps === numComps) {
  41463. return altIR;
  41464. }
  41465. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  41466. }
  41467. if (numComps === 1) {
  41468. return 'DeviceGrayCS';
  41469. } else if (numComps === 3) {
  41470. return 'DeviceRgbCS';
  41471. } else if (numComps === 4) {
  41472. return 'DeviceCmykCS';
  41473. }
  41474. break;
  41475. case 'Pattern':
  41476. var basePatternCS = cs[1] || null;
  41477. if (basePatternCS) {
  41478. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  41479. }
  41480. return [
  41481. 'PatternCS',
  41482. basePatternCS
  41483. ];
  41484. case 'Indexed':
  41485. case 'I':
  41486. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  41487. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  41488. var lookup = xref.fetchIfRef(cs[3]);
  41489. if (isStream(lookup)) {
  41490. lookup = lookup.getBytes();
  41491. }
  41492. return [
  41493. 'IndexedCS',
  41494. baseIndexedCS,
  41495. hiVal,
  41496. lookup
  41497. ];
  41498. case 'Separation':
  41499. case 'DeviceN':
  41500. var name = xref.fetchIfRef(cs[1]);
  41501. numComps = isArray(name) ? name.length : 1;
  41502. alt = ColorSpace.parseToIR(cs[2], xref, res);
  41503. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  41504. return [
  41505. 'AlternateCS',
  41506. numComps,
  41507. alt,
  41508. tintFnIR
  41509. ];
  41510. case 'Lab':
  41511. params = xref.fetchIfRef(cs[1]);
  41512. whitePoint = params.getArray('WhitePoint');
  41513. blackPoint = params.getArray('BlackPoint');
  41514. var range = params.getArray('Range');
  41515. return [
  41516. 'LabCS',
  41517. whitePoint,
  41518. blackPoint,
  41519. range
  41520. ];
  41521. default:
  41522. error('unimplemented color space object "' + mode + '"');
  41523. }
  41524. } else {
  41525. error('unrecognized color space object: "' + cs + '"');
  41526. }
  41527. return null;
  41528. };
  41529. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  41530. if (!isArray(decode)) {
  41531. return true;
  41532. }
  41533. if (n * 2 !== decode.length) {
  41534. warn('The decode map is not the correct length');
  41535. return true;
  41536. }
  41537. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  41538. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  41539. return false;
  41540. }
  41541. }
  41542. return true;
  41543. };
  41544. ColorSpace.singletons = {
  41545. get gray() {
  41546. return shadow(this, 'gray', new DeviceGrayCS());
  41547. },
  41548. get rgb() {
  41549. return shadow(this, 'rgb', new DeviceRgbCS());
  41550. },
  41551. get cmyk() {
  41552. return shadow(this, 'cmyk', new DeviceCmykCS());
  41553. }
  41554. };
  41555. return ColorSpace;
  41556. }();
  41557. var AlternateCS = function AlternateCSClosure() {
  41558. function AlternateCS(numComps, base, tintFn) {
  41559. this.name = 'Alternate';
  41560. this.numComps = numComps;
  41561. this.defaultColor = new Float32Array(numComps);
  41562. for (var i = 0; i < numComps; ++i) {
  41563. this.defaultColor[i] = 1;
  41564. }
  41565. this.base = base;
  41566. this.tintFn = tintFn;
  41567. this.tmpBuf = new Float32Array(base.numComps);
  41568. }
  41569. AlternateCS.prototype = {
  41570. getRgb: ColorSpace.prototype.getRgb,
  41571. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41572. var tmpBuf = this.tmpBuf;
  41573. this.tintFn(src, srcOffset, tmpBuf, 0);
  41574. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  41575. },
  41576. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41577. var tintFn = this.tintFn;
  41578. var base = this.base;
  41579. var scale = 1 / ((1 << bits) - 1);
  41580. var baseNumComps = base.numComps;
  41581. var usesZeroToOneRange = base.usesZeroToOneRange;
  41582. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  41583. var pos = isPassthrough ? destOffset : 0;
  41584. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  41585. var numComps = this.numComps;
  41586. var scaled = new Float32Array(numComps);
  41587. var tinted = new Float32Array(baseNumComps);
  41588. var i, j;
  41589. for (i = 0; i < count; i++) {
  41590. for (j = 0; j < numComps; j++) {
  41591. scaled[j] = src[srcOffset++] * scale;
  41592. }
  41593. tintFn(scaled, 0, tinted, 0);
  41594. if (usesZeroToOneRange) {
  41595. for (j = 0; j < baseNumComps; j++) {
  41596. baseBuf[pos++] = tinted[j] * 255;
  41597. }
  41598. } else {
  41599. base.getRgbItem(tinted, 0, baseBuf, pos);
  41600. pos += baseNumComps;
  41601. }
  41602. }
  41603. if (!isPassthrough) {
  41604. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  41605. }
  41606. },
  41607. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  41608. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  41609. },
  41610. isPassthrough: ColorSpace.prototype.isPassthrough,
  41611. fillRgb: ColorSpace.prototype.fillRgb,
  41612. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  41613. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41614. },
  41615. usesZeroToOneRange: true
  41616. };
  41617. return AlternateCS;
  41618. }();
  41619. var PatternCS = function PatternCSClosure() {
  41620. function PatternCS(baseCS) {
  41621. this.name = 'Pattern';
  41622. this.base = baseCS;
  41623. }
  41624. PatternCS.prototype = {};
  41625. return PatternCS;
  41626. }();
  41627. var IndexedCS = function IndexedCSClosure() {
  41628. function IndexedCS(base, highVal, lookup) {
  41629. this.name = 'Indexed';
  41630. this.numComps = 1;
  41631. this.defaultColor = new Uint8Array(this.numComps);
  41632. this.base = base;
  41633. this.highVal = highVal;
  41634. var baseNumComps = base.numComps;
  41635. var length = baseNumComps * highVal;
  41636. if (isStream(lookup)) {
  41637. this.lookup = new Uint8Array(length);
  41638. var bytes = lookup.getBytes(length);
  41639. this.lookup.set(bytes);
  41640. } else if (isString(lookup)) {
  41641. this.lookup = new Uint8Array(length);
  41642. for (var i = 0; i < length; ++i) {
  41643. this.lookup[i] = lookup.charCodeAt(i);
  41644. }
  41645. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  41646. this.lookup = lookup;
  41647. } else {
  41648. error('Unrecognized lookup table: ' + lookup);
  41649. }
  41650. }
  41651. IndexedCS.prototype = {
  41652. getRgb: ColorSpace.prototype.getRgb,
  41653. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41654. var numComps = this.base.numComps;
  41655. var start = src[srcOffset] * numComps;
  41656. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  41657. },
  41658. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41659. var base = this.base;
  41660. var numComps = base.numComps;
  41661. var outputDelta = base.getOutputLength(numComps, alpha01);
  41662. var lookup = this.lookup;
  41663. for (var i = 0; i < count; ++i) {
  41664. var lookupPos = src[srcOffset++] * numComps;
  41665. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  41666. destOffset += outputDelta;
  41667. }
  41668. },
  41669. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  41670. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  41671. },
  41672. isPassthrough: ColorSpace.prototype.isPassthrough,
  41673. fillRgb: ColorSpace.prototype.fillRgb,
  41674. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  41675. return true;
  41676. },
  41677. usesZeroToOneRange: true
  41678. };
  41679. return IndexedCS;
  41680. }();
  41681. var DeviceGrayCS = function DeviceGrayCSClosure() {
  41682. function DeviceGrayCS() {
  41683. this.name = 'DeviceGray';
  41684. this.numComps = 1;
  41685. this.defaultColor = new Float32Array(this.numComps);
  41686. }
  41687. DeviceGrayCS.prototype = {
  41688. getRgb: ColorSpace.prototype.getRgb,
  41689. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41690. var c = src[srcOffset] * 255 | 0;
  41691. c = c < 0 ? 0 : c > 255 ? 255 : c;
  41692. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  41693. },
  41694. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41695. var scale = 255 / ((1 << bits) - 1);
  41696. var j = srcOffset, q = destOffset;
  41697. for (var i = 0; i < count; ++i) {
  41698. var c = scale * src[j++] | 0;
  41699. dest[q++] = c;
  41700. dest[q++] = c;
  41701. dest[q++] = c;
  41702. q += alpha01;
  41703. }
  41704. },
  41705. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  41706. return inputLength * (3 + alpha01);
  41707. },
  41708. isPassthrough: ColorSpace.prototype.isPassthrough,
  41709. fillRgb: ColorSpace.prototype.fillRgb,
  41710. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  41711. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41712. },
  41713. usesZeroToOneRange: true
  41714. };
  41715. return DeviceGrayCS;
  41716. }();
  41717. var DeviceRgbCS = function DeviceRgbCSClosure() {
  41718. function DeviceRgbCS() {
  41719. this.name = 'DeviceRGB';
  41720. this.numComps = 3;
  41721. this.defaultColor = new Float32Array(this.numComps);
  41722. }
  41723. DeviceRgbCS.prototype = {
  41724. getRgb: ColorSpace.prototype.getRgb,
  41725. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41726. var r = src[srcOffset] * 255 | 0;
  41727. var g = src[srcOffset + 1] * 255 | 0;
  41728. var b = src[srcOffset + 2] * 255 | 0;
  41729. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  41730. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  41731. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  41732. },
  41733. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41734. if (bits === 8 && alpha01 === 0) {
  41735. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  41736. return;
  41737. }
  41738. var scale = 255 / ((1 << bits) - 1);
  41739. var j = srcOffset, q = destOffset;
  41740. for (var i = 0; i < count; ++i) {
  41741. dest[q++] = scale * src[j++] | 0;
  41742. dest[q++] = scale * src[j++] | 0;
  41743. dest[q++] = scale * src[j++] | 0;
  41744. q += alpha01;
  41745. }
  41746. },
  41747. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  41748. return inputLength * (3 + alpha01) / 3 | 0;
  41749. },
  41750. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  41751. return bits === 8;
  41752. },
  41753. fillRgb: ColorSpace.prototype.fillRgb,
  41754. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  41755. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41756. },
  41757. usesZeroToOneRange: true
  41758. };
  41759. return DeviceRgbCS;
  41760. }();
  41761. var DeviceCmykCS = function DeviceCmykCSClosure() {
  41762. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  41763. var c = src[srcOffset + 0] * srcScale;
  41764. var m = src[srcOffset + 1] * srcScale;
  41765. var y = src[srcOffset + 2] * srcScale;
  41766. var k = src[srcOffset + 3] * srcScale;
  41767. 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;
  41768. 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;
  41769. 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;
  41770. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  41771. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  41772. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  41773. }
  41774. function DeviceCmykCS() {
  41775. this.name = 'DeviceCMYK';
  41776. this.numComps = 4;
  41777. this.defaultColor = new Float32Array(this.numComps);
  41778. this.defaultColor[3] = 1;
  41779. }
  41780. DeviceCmykCS.prototype = {
  41781. getRgb: ColorSpace.prototype.getRgb,
  41782. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41783. convertToRgb(src, srcOffset, 1, dest, destOffset);
  41784. },
  41785. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41786. var scale = 1 / ((1 << bits) - 1);
  41787. for (var i = 0; i < count; i++) {
  41788. convertToRgb(src, srcOffset, scale, dest, destOffset);
  41789. srcOffset += 4;
  41790. destOffset += 3 + alpha01;
  41791. }
  41792. },
  41793. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  41794. return inputLength / 4 * (3 + alpha01) | 0;
  41795. },
  41796. isPassthrough: ColorSpace.prototype.isPassthrough,
  41797. fillRgb: ColorSpace.prototype.fillRgb,
  41798. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  41799. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41800. },
  41801. usesZeroToOneRange: true
  41802. };
  41803. return DeviceCmykCS;
  41804. }();
  41805. var CalGrayCS = function CalGrayCSClosure() {
  41806. function CalGrayCS(whitePoint, blackPoint, gamma) {
  41807. this.name = 'CalGray';
  41808. this.numComps = 1;
  41809. this.defaultColor = new Float32Array(this.numComps);
  41810. if (!whitePoint) {
  41811. error('WhitePoint missing - required for color space CalGray');
  41812. }
  41813. blackPoint = blackPoint || [
  41814. 0,
  41815. 0,
  41816. 0
  41817. ];
  41818. gamma = gamma || 1;
  41819. this.XW = whitePoint[0];
  41820. this.YW = whitePoint[1];
  41821. this.ZW = whitePoint[2];
  41822. this.XB = blackPoint[0];
  41823. this.YB = blackPoint[1];
  41824. this.ZB = blackPoint[2];
  41825. this.G = gamma;
  41826. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  41827. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  41828. }
  41829. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  41830. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  41831. this.XB = this.YB = this.ZB = 0;
  41832. }
  41833. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  41834. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  41835. }
  41836. if (this.G < 1) {
  41837. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  41838. this.G = 1;
  41839. }
  41840. }
  41841. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  41842. var A = src[srcOffset] * scale;
  41843. var AG = Math.pow(A, cs.G);
  41844. var L = cs.YW * AG;
  41845. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  41846. dest[destOffset] = val;
  41847. dest[destOffset + 1] = val;
  41848. dest[destOffset + 2] = val;
  41849. }
  41850. CalGrayCS.prototype = {
  41851. getRgb: ColorSpace.prototype.getRgb,
  41852. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  41853. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  41854. },
  41855. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  41856. var scale = 1 / ((1 << bits) - 1);
  41857. for (var i = 0; i < count; ++i) {
  41858. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  41859. srcOffset += 1;
  41860. destOffset += 3 + alpha01;
  41861. }
  41862. },
  41863. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  41864. return inputLength * (3 + alpha01);
  41865. },
  41866. isPassthrough: ColorSpace.prototype.isPassthrough,
  41867. fillRgb: ColorSpace.prototype.fillRgb,
  41868. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  41869. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  41870. },
  41871. usesZeroToOneRange: true
  41872. };
  41873. return CalGrayCS;
  41874. }();
  41875. var CalRGBCS = function CalRGBCSClosure() {
  41876. var BRADFORD_SCALE_MATRIX = new Float32Array([
  41877. 0.8951,
  41878. 0.2664,
  41879. -0.1614,
  41880. -0.7502,
  41881. 1.7135,
  41882. 0.0367,
  41883. 0.0389,
  41884. -0.0685,
  41885. 1.0296
  41886. ]);
  41887. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  41888. 0.9869929,
  41889. -0.1470543,
  41890. 0.1599627,
  41891. 0.4323053,
  41892. 0.5183603,
  41893. 0.0492912,
  41894. -0.0085287,
  41895. 0.0400428,
  41896. 0.9684867
  41897. ]);
  41898. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  41899. 3.2404542,
  41900. -1.5371385,
  41901. -0.4985314,
  41902. -0.9692660,
  41903. 1.8760108,
  41904. 0.0415560,
  41905. 0.0556434,
  41906. -0.2040259,
  41907. 1.0572252
  41908. ]);
  41909. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  41910. 1,
  41911. 1,
  41912. 1
  41913. ]);
  41914. var tempNormalizeMatrix = new Float32Array(3);
  41915. var tempConvertMatrix1 = new Float32Array(3);
  41916. var tempConvertMatrix2 = new Float32Array(3);
  41917. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  41918. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  41919. this.name = 'CalRGB';
  41920. this.numComps = 3;
  41921. this.defaultColor = new Float32Array(this.numComps);
  41922. if (!whitePoint) {
  41923. error('WhitePoint missing - required for color space CalRGB');
  41924. }
  41925. blackPoint = blackPoint || new Float32Array(3);
  41926. gamma = gamma || new Float32Array([
  41927. 1,
  41928. 1,
  41929. 1
  41930. ]);
  41931. matrix = matrix || new Float32Array([
  41932. 1,
  41933. 0,
  41934. 0,
  41935. 0,
  41936. 1,
  41937. 0,
  41938. 0,
  41939. 0,
  41940. 1
  41941. ]);
  41942. var XW = whitePoint[0];
  41943. var YW = whitePoint[1];
  41944. var ZW = whitePoint[2];
  41945. this.whitePoint = whitePoint;
  41946. var XB = blackPoint[0];
  41947. var YB = blackPoint[1];
  41948. var ZB = blackPoint[2];
  41949. this.blackPoint = blackPoint;
  41950. this.GR = gamma[0];
  41951. this.GG = gamma[1];
  41952. this.GB = gamma[2];
  41953. this.MXA = matrix[0];
  41954. this.MYA = matrix[1];
  41955. this.MZA = matrix[2];
  41956. this.MXB = matrix[3];
  41957. this.MYB = matrix[4];
  41958. this.MZB = matrix[5];
  41959. this.MXC = matrix[6];
  41960. this.MYC = matrix[7];
  41961. this.MZC = matrix[8];
  41962. if (XW < 0 || ZW < 0 || YW !== 1) {
  41963. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  41964. }
  41965. if (XB < 0 || YB < 0 || ZB < 0) {
  41966. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  41967. this.blackPoint = new Float32Array(3);
  41968. }
  41969. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  41970. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  41971. this.GR = this.GG = this.GB = 1;
  41972. }
  41973. 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) {
  41974. 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');
  41975. this.MXA = this.MYB = this.MZC = 1;
  41976. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  41977. }
  41978. }
  41979. function matrixProduct(a, b, result) {
  41980. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  41981. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  41982. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  41983. }
  41984. function convertToFlat(sourceWhitePoint, LMS, result) {
  41985. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  41986. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  41987. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  41988. }
  41989. function convertToD65(sourceWhitePoint, LMS, result) {
  41990. var D65X = 0.95047;
  41991. var D65Y = 1;
  41992. var D65Z = 1.08883;
  41993. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  41994. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  41995. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  41996. }
  41997. function sRGBTransferFunction(color) {
  41998. if (color <= 0.0031308) {
  41999. return adjustToRange(0, 1, 12.92 * color);
  42000. }
  42001. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  42002. }
  42003. function adjustToRange(min, max, value) {
  42004. return Math.max(min, Math.min(max, value));
  42005. }
  42006. function decodeL(L) {
  42007. if (L < 0) {
  42008. return -decodeL(-L);
  42009. }
  42010. if (L > 8.0) {
  42011. return Math.pow((L + 16) / 116, 3);
  42012. }
  42013. return L * DECODE_L_CONSTANT;
  42014. }
  42015. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  42016. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  42017. result[0] = XYZ_Flat[0];
  42018. result[1] = XYZ_Flat[1];
  42019. result[2] = XYZ_Flat[2];
  42020. return;
  42021. }
  42022. var zeroDecodeL = decodeL(0);
  42023. var X_DST = zeroDecodeL;
  42024. var X_SRC = decodeL(sourceBlackPoint[0]);
  42025. var Y_DST = zeroDecodeL;
  42026. var Y_SRC = decodeL(sourceBlackPoint[1]);
  42027. var Z_DST = zeroDecodeL;
  42028. var Z_SRC = decodeL(sourceBlackPoint[2]);
  42029. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  42030. var X_Offset = 1 - X_Scale;
  42031. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  42032. var Y_Offset = 1 - Y_Scale;
  42033. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  42034. var Z_Offset = 1 - Z_Scale;
  42035. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  42036. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  42037. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  42038. }
  42039. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  42040. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  42041. result[0] = XYZ_In[0];
  42042. result[1] = XYZ_In[1];
  42043. result[2] = XYZ_In[2];
  42044. return;
  42045. }
  42046. var LMS = result;
  42047. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  42048. var LMS_Flat = tempNormalizeMatrix;
  42049. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  42050. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  42051. }
  42052. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  42053. var LMS = result;
  42054. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  42055. var LMS_D65 = tempNormalizeMatrix;
  42056. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  42057. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  42058. }
  42059. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  42060. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  42061. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  42062. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  42063. var AGR = Math.pow(A, cs.GR);
  42064. var BGG = Math.pow(B, cs.GG);
  42065. var CGB = Math.pow(C, cs.GB);
  42066. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  42067. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  42068. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  42069. var XYZ = tempConvertMatrix1;
  42070. XYZ[0] = X;
  42071. XYZ[1] = Y;
  42072. XYZ[2] = Z;
  42073. var XYZ_Flat = tempConvertMatrix2;
  42074. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  42075. var XYZ_Black = tempConvertMatrix1;
  42076. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  42077. var XYZ_D65 = tempConvertMatrix2;
  42078. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  42079. var SRGB = tempConvertMatrix1;
  42080. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  42081. var sR = sRGBTransferFunction(SRGB[0]);
  42082. var sG = sRGBTransferFunction(SRGB[1]);
  42083. var sB = sRGBTransferFunction(SRGB[2]);
  42084. dest[destOffset] = Math.round(sR * 255);
  42085. dest[destOffset + 1] = Math.round(sG * 255);
  42086. dest[destOffset + 2] = Math.round(sB * 255);
  42087. }
  42088. CalRGBCS.prototype = {
  42089. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  42090. var rgb = new Uint8Array(3);
  42091. this.getRgbItem(src, srcOffset, rgb, 0);
  42092. return rgb;
  42093. },
  42094. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42095. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  42096. },
  42097. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42098. var scale = 1 / ((1 << bits) - 1);
  42099. for (var i = 0; i < count; ++i) {
  42100. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  42101. srcOffset += 3;
  42102. destOffset += 3 + alpha01;
  42103. }
  42104. },
  42105. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  42106. return inputLength * (3 + alpha01) / 3 | 0;
  42107. },
  42108. isPassthrough: ColorSpace.prototype.isPassthrough,
  42109. fillRgb: ColorSpace.prototype.fillRgb,
  42110. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  42111. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  42112. },
  42113. usesZeroToOneRange: true
  42114. };
  42115. return CalRGBCS;
  42116. }();
  42117. var LabCS = function LabCSClosure() {
  42118. function LabCS(whitePoint, blackPoint, range) {
  42119. this.name = 'Lab';
  42120. this.numComps = 3;
  42121. this.defaultColor = new Float32Array(this.numComps);
  42122. if (!whitePoint) {
  42123. error('WhitePoint missing - required for color space Lab');
  42124. }
  42125. blackPoint = blackPoint || [
  42126. 0,
  42127. 0,
  42128. 0
  42129. ];
  42130. range = range || [
  42131. -100,
  42132. 100,
  42133. -100,
  42134. 100
  42135. ];
  42136. this.XW = whitePoint[0];
  42137. this.YW = whitePoint[1];
  42138. this.ZW = whitePoint[2];
  42139. this.amin = range[0];
  42140. this.amax = range[1];
  42141. this.bmin = range[2];
  42142. this.bmax = range[3];
  42143. this.XB = blackPoint[0];
  42144. this.YB = blackPoint[1];
  42145. this.ZB = blackPoint[2];
  42146. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  42147. error('Invalid WhitePoint components, no fallback available');
  42148. }
  42149. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  42150. info('Invalid BlackPoint, falling back to default');
  42151. this.XB = this.YB = this.ZB = 0;
  42152. }
  42153. if (this.amin > this.amax || this.bmin > this.bmax) {
  42154. info('Invalid Range, falling back to defaults');
  42155. this.amin = -100;
  42156. this.amax = 100;
  42157. this.bmin = -100;
  42158. this.bmax = 100;
  42159. }
  42160. }
  42161. function fn_g(x) {
  42162. var result;
  42163. if (x >= 6 / 29) {
  42164. result = x * x * x;
  42165. } else {
  42166. result = 108 / 841 * (x - 4 / 29);
  42167. }
  42168. return result;
  42169. }
  42170. function decode(value, high1, low2, high2) {
  42171. return low2 + value * (high2 - low2) / high1;
  42172. }
  42173. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  42174. var Ls = src[srcOffset];
  42175. var as = src[srcOffset + 1];
  42176. var bs = src[srcOffset + 2];
  42177. if (maxVal !== false) {
  42178. Ls = decode(Ls, maxVal, 0, 100);
  42179. as = decode(as, maxVal, cs.amin, cs.amax);
  42180. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  42181. }
  42182. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  42183. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  42184. var M = (Ls + 16) / 116;
  42185. var L = M + as / 500;
  42186. var N = M - bs / 200;
  42187. var X = cs.XW * fn_g(L);
  42188. var Y = cs.YW * fn_g(M);
  42189. var Z = cs.ZW * fn_g(N);
  42190. var r, g, b;
  42191. if (cs.ZW < 1) {
  42192. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  42193. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  42194. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  42195. } else {
  42196. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  42197. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  42198. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  42199. }
  42200. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  42201. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  42202. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  42203. }
  42204. LabCS.prototype = {
  42205. getRgb: ColorSpace.prototype.getRgb,
  42206. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  42207. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  42208. },
  42209. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  42210. var maxVal = (1 << bits) - 1;
  42211. for (var i = 0; i < count; i++) {
  42212. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  42213. srcOffset += 3;
  42214. destOffset += 3 + alpha01;
  42215. }
  42216. },
  42217. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  42218. return inputLength * (3 + alpha01) / 3 | 0;
  42219. },
  42220. isPassthrough: ColorSpace.prototype.isPassthrough,
  42221. fillRgb: ColorSpace.prototype.fillRgb,
  42222. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  42223. return true;
  42224. },
  42225. usesZeroToOneRange: false
  42226. };
  42227. return LabCS;
  42228. }();
  42229. exports.ColorSpace = ColorSpace;
  42230. }));
  42231. (function (root, factory) {
  42232. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  42233. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  42234. var ImageKind = sharedUtil.ImageKind;
  42235. var assert = sharedUtil.assert;
  42236. var error = sharedUtil.error;
  42237. var info = sharedUtil.info;
  42238. var isArray = sharedUtil.isArray;
  42239. var warn = sharedUtil.warn;
  42240. var Name = corePrimitives.Name;
  42241. var isStream = corePrimitives.isStream;
  42242. var ColorSpace = coreColorSpace.ColorSpace;
  42243. var DecodeStream = coreStream.DecodeStream;
  42244. var JpegStream = coreStream.JpegStream;
  42245. var JpxImage = coreJpx.JpxImage;
  42246. var PDFImage = function PDFImageClosure() {
  42247. function handleImageData(image, nativeDecoder) {
  42248. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  42249. return nativeDecoder.decode(image);
  42250. }
  42251. return Promise.resolve(image);
  42252. }
  42253. function decodeAndClamp(value, addend, coefficient, max) {
  42254. value = addend + value * coefficient;
  42255. return value < 0 ? 0 : value > max ? max : value;
  42256. }
  42257. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  42258. var length = w2 * h2;
  42259. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  42260. var xRatio = w1 / w2;
  42261. var yRatio = h1 / h2;
  42262. var i, j, py, newIndex = 0, oldIndex;
  42263. var xScaled = new Uint16Array(w2);
  42264. var w1Scanline = w1;
  42265. for (i = 0; i < w2; i++) {
  42266. xScaled[i] = Math.floor(i * xRatio);
  42267. }
  42268. for (i = 0; i < h2; i++) {
  42269. py = Math.floor(i * yRatio) * w1Scanline;
  42270. for (j = 0; j < w2; j++) {
  42271. oldIndex = py + xScaled[j];
  42272. dest[newIndex++] = src[oldIndex];
  42273. }
  42274. }
  42275. return dest;
  42276. }
  42277. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  42278. this.image = image;
  42279. var dict = image.dict;
  42280. if (dict.has('Filter')) {
  42281. var filter = dict.get('Filter').name;
  42282. if (filter === 'JPXDecode') {
  42283. var jpxImage = new JpxImage();
  42284. jpxImage.parseImageProperties(image.stream);
  42285. image.stream.reset();
  42286. image.bitsPerComponent = jpxImage.bitsPerComponent;
  42287. image.numComps = jpxImage.componentsCount;
  42288. } else if (filter === 'JBIG2Decode') {
  42289. image.bitsPerComponent = 1;
  42290. image.numComps = 1;
  42291. }
  42292. }
  42293. this.width = dict.get('Width', 'W');
  42294. this.height = dict.get('Height', 'H');
  42295. if (this.width < 1 || this.height < 1) {
  42296. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  42297. }
  42298. this.interpolate = dict.get('Interpolate', 'I') || false;
  42299. this.imageMask = dict.get('ImageMask', 'IM') || false;
  42300. this.matte = dict.get('Matte') || false;
  42301. var bitsPerComponent = image.bitsPerComponent;
  42302. if (!bitsPerComponent) {
  42303. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  42304. if (!bitsPerComponent) {
  42305. if (this.imageMask) {
  42306. bitsPerComponent = 1;
  42307. } else {
  42308. error('Bits per component missing in image: ' + this.imageMask);
  42309. }
  42310. }
  42311. }
  42312. this.bpc = bitsPerComponent;
  42313. if (!this.imageMask) {
  42314. var colorSpace = dict.get('ColorSpace', 'CS');
  42315. if (!colorSpace) {
  42316. info('JPX images (which do not require color spaces)');
  42317. switch (image.numComps) {
  42318. case 1:
  42319. colorSpace = Name.get('DeviceGray');
  42320. break;
  42321. case 3:
  42322. colorSpace = Name.get('DeviceRGB');
  42323. break;
  42324. case 4:
  42325. colorSpace = Name.get('DeviceCMYK');
  42326. break;
  42327. default:
  42328. error('JPX images with ' + this.numComps + ' color components not supported.');
  42329. }
  42330. }
  42331. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  42332. this.numComps = this.colorSpace.numComps;
  42333. }
  42334. this.decode = dict.getArray('Decode', 'D');
  42335. this.needsDecode = false;
  42336. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  42337. this.needsDecode = true;
  42338. var max = (1 << bitsPerComponent) - 1;
  42339. this.decodeCoefficients = [];
  42340. this.decodeAddends = [];
  42341. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  42342. var dmin = this.decode[i];
  42343. var dmax = this.decode[i + 1];
  42344. this.decodeCoefficients[j] = dmax - dmin;
  42345. this.decodeAddends[j] = max * dmin;
  42346. }
  42347. }
  42348. if (smask) {
  42349. this.smask = new PDFImage(xref, res, smask, false);
  42350. } else if (mask) {
  42351. if (isStream(mask)) {
  42352. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  42353. if (!imageMask) {
  42354. warn('Ignoring /Mask in image without /ImageMask.');
  42355. } else {
  42356. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  42357. }
  42358. } else {
  42359. this.mask = mask;
  42360. }
  42361. }
  42362. }
  42363. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  42364. var imagePromise = handleImageData(image, nativeDecoder);
  42365. var smaskPromise;
  42366. var maskPromise;
  42367. var smask = image.dict.get('SMask');
  42368. var mask = image.dict.get('Mask');
  42369. if (smask) {
  42370. smaskPromise = handleImageData(smask, nativeDecoder);
  42371. maskPromise = Promise.resolve(null);
  42372. } else {
  42373. smaskPromise = Promise.resolve(null);
  42374. if (mask) {
  42375. if (isStream(mask)) {
  42376. maskPromise = handleImageData(mask, nativeDecoder);
  42377. } else if (isArray(mask)) {
  42378. maskPromise = Promise.resolve(mask);
  42379. } else {
  42380. warn('Unsupported mask format.');
  42381. maskPromise = Promise.resolve(null);
  42382. }
  42383. } else {
  42384. maskPromise = Promise.resolve(null);
  42385. }
  42386. }
  42387. return Promise.all([
  42388. imagePromise,
  42389. smaskPromise,
  42390. maskPromise
  42391. ]).then(function (results) {
  42392. var imageData = results[0];
  42393. var smaskData = results[1];
  42394. var maskData = results[2];
  42395. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  42396. });
  42397. };
  42398. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  42399. var computedLength = (width + 7 >> 3) * height;
  42400. var actualLength = imgArray.byteLength;
  42401. var haveFullData = computedLength === actualLength;
  42402. var data, i;
  42403. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  42404. data = imgArray;
  42405. } else if (!inverseDecode) {
  42406. data = new Uint8Array(actualLength);
  42407. data.set(imgArray);
  42408. } else {
  42409. data = new Uint8Array(computedLength);
  42410. data.set(imgArray);
  42411. for (i = actualLength; i < computedLength; i++) {
  42412. data[i] = 0xff;
  42413. }
  42414. }
  42415. if (inverseDecode) {
  42416. for (i = 0; i < actualLength; i++) {
  42417. data[i] = ~data[i];
  42418. }
  42419. }
  42420. return {
  42421. data: data,
  42422. width: width,
  42423. height: height
  42424. };
  42425. };
  42426. PDFImage.prototype = {
  42427. get drawWidth() {
  42428. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  42429. },
  42430. get drawHeight() {
  42431. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  42432. },
  42433. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  42434. var bpc = this.bpc;
  42435. var numComps = this.numComps;
  42436. var decodeAddends = this.decodeAddends;
  42437. var decodeCoefficients = this.decodeCoefficients;
  42438. var max = (1 << bpc) - 1;
  42439. var i, ii;
  42440. if (bpc === 1) {
  42441. for (i = 0, ii = buffer.length; i < ii; i++) {
  42442. buffer[i] = +!buffer[i];
  42443. }
  42444. return;
  42445. }
  42446. var index = 0;
  42447. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  42448. for (var j = 0; j < numComps; j++) {
  42449. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  42450. index++;
  42451. }
  42452. }
  42453. },
  42454. getComponents: function PDFImage_getComponents(buffer) {
  42455. var bpc = this.bpc;
  42456. if (bpc === 8) {
  42457. return buffer;
  42458. }
  42459. var width = this.width;
  42460. var height = this.height;
  42461. var numComps = this.numComps;
  42462. var length = width * height * numComps;
  42463. var bufferPos = 0;
  42464. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  42465. var rowComps = width * numComps;
  42466. var max = (1 << bpc) - 1;
  42467. var i = 0, ii, buf;
  42468. if (bpc === 1) {
  42469. var mask, loop1End, loop2End;
  42470. for (var j = 0; j < height; j++) {
  42471. loop1End = i + (rowComps & ~7);
  42472. loop2End = i + rowComps;
  42473. while (i < loop1End) {
  42474. buf = buffer[bufferPos++];
  42475. output[i] = buf >> 7 & 1;
  42476. output[i + 1] = buf >> 6 & 1;
  42477. output[i + 2] = buf >> 5 & 1;
  42478. output[i + 3] = buf >> 4 & 1;
  42479. output[i + 4] = buf >> 3 & 1;
  42480. output[i + 5] = buf >> 2 & 1;
  42481. output[i + 6] = buf >> 1 & 1;
  42482. output[i + 7] = buf & 1;
  42483. i += 8;
  42484. }
  42485. if (i < loop2End) {
  42486. buf = buffer[bufferPos++];
  42487. mask = 128;
  42488. while (i < loop2End) {
  42489. output[i++] = +!!(buf & mask);
  42490. mask >>= 1;
  42491. }
  42492. }
  42493. }
  42494. } else {
  42495. var bits = 0;
  42496. buf = 0;
  42497. for (i = 0, ii = length; i < ii; ++i) {
  42498. if (i % rowComps === 0) {
  42499. buf = 0;
  42500. bits = 0;
  42501. }
  42502. while (bits < bpc) {
  42503. buf = buf << 8 | buffer[bufferPos++];
  42504. bits += 8;
  42505. }
  42506. var remainingBits = bits - bpc;
  42507. var value = buf >> remainingBits;
  42508. output[i] = value < 0 ? 0 : value > max ? max : value;
  42509. buf = buf & (1 << remainingBits) - 1;
  42510. bits = remainingBits;
  42511. }
  42512. }
  42513. return output;
  42514. },
  42515. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  42516. var smask = this.smask;
  42517. var mask = this.mask;
  42518. var alphaBuf, sw, sh, i, ii, j;
  42519. if (smask) {
  42520. sw = smask.width;
  42521. sh = smask.height;
  42522. alphaBuf = new Uint8Array(sw * sh);
  42523. smask.fillGrayBuffer(alphaBuf);
  42524. if (sw !== width || sh !== height) {
  42525. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  42526. }
  42527. } else if (mask) {
  42528. if (mask instanceof PDFImage) {
  42529. sw = mask.width;
  42530. sh = mask.height;
  42531. alphaBuf = new Uint8Array(sw * sh);
  42532. mask.numComps = 1;
  42533. mask.fillGrayBuffer(alphaBuf);
  42534. for (i = 0, ii = sw * sh; i < ii; ++i) {
  42535. alphaBuf[i] = 255 - alphaBuf[i];
  42536. }
  42537. if (sw !== width || sh !== height) {
  42538. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  42539. }
  42540. } else if (isArray(mask)) {
  42541. alphaBuf = new Uint8Array(width * height);
  42542. var numComps = this.numComps;
  42543. for (i = 0, ii = width * height; i < ii; ++i) {
  42544. var opacity = 0;
  42545. var imageOffset = i * numComps;
  42546. for (j = 0; j < numComps; ++j) {
  42547. var color = image[imageOffset + j];
  42548. var maskOffset = j * 2;
  42549. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  42550. opacity = 255;
  42551. break;
  42552. }
  42553. }
  42554. alphaBuf[i] = opacity;
  42555. }
  42556. } else {
  42557. error('Unknown mask format.');
  42558. }
  42559. }
  42560. if (alphaBuf) {
  42561. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  42562. rgbaBuf[j] = alphaBuf[i];
  42563. }
  42564. } else {
  42565. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  42566. rgbaBuf[j] = 255;
  42567. }
  42568. }
  42569. },
  42570. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  42571. var matte = this.smask && this.smask.matte;
  42572. if (!matte) {
  42573. return;
  42574. }
  42575. var matteRgb = this.colorSpace.getRgb(matte, 0);
  42576. var matteR = matteRgb[0];
  42577. var matteG = matteRgb[1];
  42578. var matteB = matteRgb[2];
  42579. var length = width * height * 4;
  42580. var r, g, b;
  42581. for (var i = 0; i < length; i += 4) {
  42582. var alpha = buffer[i + 3];
  42583. if (alpha === 0) {
  42584. buffer[i] = 255;
  42585. buffer[i + 1] = 255;
  42586. buffer[i + 2] = 255;
  42587. continue;
  42588. }
  42589. var k = 255 / alpha;
  42590. r = (buffer[i] - matteR) * k + matteR;
  42591. g = (buffer[i + 1] - matteG) * k + matteG;
  42592. b = (buffer[i + 2] - matteB) * k + matteB;
  42593. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  42594. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  42595. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  42596. }
  42597. },
  42598. createImageData: function PDFImage_createImageData(forceRGBA) {
  42599. var drawWidth = this.drawWidth;
  42600. var drawHeight = this.drawHeight;
  42601. var imgData = {
  42602. width: drawWidth,
  42603. height: drawHeight
  42604. };
  42605. var numComps = this.numComps;
  42606. var originalWidth = this.width;
  42607. var originalHeight = this.height;
  42608. var bpc = this.bpc;
  42609. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  42610. var imgArray;
  42611. if (!forceRGBA) {
  42612. var kind;
  42613. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  42614. kind = ImageKind.GRAYSCALE_1BPP;
  42615. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  42616. kind = ImageKind.RGB_24BPP;
  42617. }
  42618. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  42619. imgData.kind = kind;
  42620. imgArray = this.getImageBytes(originalHeight * rowBytes);
  42621. if (this.image instanceof DecodeStream) {
  42622. imgData.data = imgArray;
  42623. } else {
  42624. var newArray = new Uint8Array(imgArray.length);
  42625. newArray.set(imgArray);
  42626. imgData.data = newArray;
  42627. }
  42628. if (this.needsDecode) {
  42629. assert(kind === ImageKind.GRAYSCALE_1BPP);
  42630. var buffer = imgData.data;
  42631. for (var i = 0, ii = buffer.length; i < ii; i++) {
  42632. buffer[i] ^= 0xff;
  42633. }
  42634. }
  42635. return imgData;
  42636. }
  42637. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  42638. imgData.kind = ImageKind.RGB_24BPP;
  42639. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  42640. return imgData;
  42641. }
  42642. }
  42643. imgArray = this.getImageBytes(originalHeight * rowBytes);
  42644. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  42645. var comps = this.getComponents(imgArray);
  42646. var alpha01, maybeUndoPreblend;
  42647. if (!forceRGBA && !this.smask && !this.mask) {
  42648. imgData.kind = ImageKind.RGB_24BPP;
  42649. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  42650. alpha01 = 0;
  42651. maybeUndoPreblend = false;
  42652. } else {
  42653. imgData.kind = ImageKind.RGBA_32BPP;
  42654. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  42655. alpha01 = 1;
  42656. maybeUndoPreblend = true;
  42657. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  42658. }
  42659. if (this.needsDecode) {
  42660. this.decodeBuffer(comps);
  42661. }
  42662. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  42663. if (maybeUndoPreblend) {
  42664. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  42665. }
  42666. return imgData;
  42667. },
  42668. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  42669. var numComps = this.numComps;
  42670. if (numComps !== 1) {
  42671. error('Reading gray scale from a color image: ' + numComps);
  42672. }
  42673. var width = this.width;
  42674. var height = this.height;
  42675. var bpc = this.bpc;
  42676. var rowBytes = width * numComps * bpc + 7 >> 3;
  42677. var imgArray = this.getImageBytes(height * rowBytes);
  42678. var comps = this.getComponents(imgArray);
  42679. var i, length;
  42680. if (bpc === 1) {
  42681. length = width * height;
  42682. if (this.needsDecode) {
  42683. for (i = 0; i < length; ++i) {
  42684. buffer[i] = comps[i] - 1 & 255;
  42685. }
  42686. } else {
  42687. for (i = 0; i < length; ++i) {
  42688. buffer[i] = -comps[i] & 255;
  42689. }
  42690. }
  42691. return;
  42692. }
  42693. if (this.needsDecode) {
  42694. this.decodeBuffer(comps);
  42695. }
  42696. length = width * height;
  42697. var scale = 255 / ((1 << bpc) - 1);
  42698. for (i = 0; i < length; ++i) {
  42699. buffer[i] = scale * comps[i] | 0;
  42700. }
  42701. },
  42702. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  42703. this.image.reset();
  42704. this.image.drawWidth = drawWidth || this.width;
  42705. this.image.drawHeight = drawHeight || this.height;
  42706. this.image.forceRGB = !!forceRGB;
  42707. return this.image.getBytes(length);
  42708. }
  42709. };
  42710. return PDFImage;
  42711. }();
  42712. exports.PDFImage = PDFImage;
  42713. }));
  42714. (function (root, factory) {
  42715. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  42716. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  42717. var InvalidPDFException = sharedUtil.InvalidPDFException;
  42718. var MissingDataException = sharedUtil.MissingDataException;
  42719. var XRefParseException = sharedUtil.XRefParseException;
  42720. var assert = sharedUtil.assert;
  42721. var bytesToString = sharedUtil.bytesToString;
  42722. var createPromiseCapability = sharedUtil.createPromiseCapability;
  42723. var error = sharedUtil.error;
  42724. var info = sharedUtil.info;
  42725. var isArray = sharedUtil.isArray;
  42726. var isBool = sharedUtil.isBool;
  42727. var isInt = sharedUtil.isInt;
  42728. var isString = sharedUtil.isString;
  42729. var shadow = sharedUtil.shadow;
  42730. var stringToPDFString = sharedUtil.stringToPDFString;
  42731. var stringToUTF8String = sharedUtil.stringToUTF8String;
  42732. var warn = sharedUtil.warn;
  42733. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  42734. var Util = sharedUtil.Util;
  42735. var Ref = corePrimitives.Ref;
  42736. var RefSet = corePrimitives.RefSet;
  42737. var RefSetCache = corePrimitives.RefSetCache;
  42738. var isName = corePrimitives.isName;
  42739. var isCmd = corePrimitives.isCmd;
  42740. var isDict = corePrimitives.isDict;
  42741. var isRef = corePrimitives.isRef;
  42742. var isRefsEqual = corePrimitives.isRefsEqual;
  42743. var isStream = corePrimitives.isStream;
  42744. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  42745. var Lexer = coreParser.Lexer;
  42746. var Parser = coreParser.Parser;
  42747. var ChunkedStream = coreChunkedStream.ChunkedStream;
  42748. var ColorSpace = coreColorSpace.ColorSpace;
  42749. var Catalog = function CatalogClosure() {
  42750. function Catalog(pdfManager, xref, pageFactory) {
  42751. this.pdfManager = pdfManager;
  42752. this.xref = xref;
  42753. this.catDict = xref.getCatalogObj();
  42754. this.fontCache = new RefSetCache();
  42755. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  42756. this.pageFactory = pageFactory;
  42757. this.pagePromises = [];
  42758. }
  42759. Catalog.prototype = {
  42760. get metadata() {
  42761. var streamRef = this.catDict.getRaw('Metadata');
  42762. if (!isRef(streamRef)) {
  42763. return shadow(this, 'metadata', null);
  42764. }
  42765. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  42766. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  42767. var metadata;
  42768. if (stream && isDict(stream.dict)) {
  42769. var type = stream.dict.get('Type');
  42770. var subtype = stream.dict.get('Subtype');
  42771. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  42772. try {
  42773. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  42774. } catch (e) {
  42775. info('Skipping invalid metadata.');
  42776. }
  42777. }
  42778. }
  42779. return shadow(this, 'metadata', metadata);
  42780. },
  42781. get toplevelPagesDict() {
  42782. var pagesObj = this.catDict.get('Pages');
  42783. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  42784. return shadow(this, 'toplevelPagesDict', pagesObj);
  42785. },
  42786. get documentOutline() {
  42787. var obj = null;
  42788. try {
  42789. obj = this.readDocumentOutline();
  42790. } catch (ex) {
  42791. if (ex instanceof MissingDataException) {
  42792. throw ex;
  42793. }
  42794. warn('Unable to read document outline');
  42795. }
  42796. return shadow(this, 'documentOutline', obj);
  42797. },
  42798. readDocumentOutline: function Catalog_readDocumentOutline() {
  42799. var obj = this.catDict.get('Outlines');
  42800. if (!isDict(obj)) {
  42801. return null;
  42802. }
  42803. obj = obj.getRaw('First');
  42804. if (!isRef(obj)) {
  42805. return null;
  42806. }
  42807. var root = { items: [] };
  42808. var queue = [{
  42809. obj: obj,
  42810. parent: root
  42811. }];
  42812. var processed = new RefSet();
  42813. processed.put(obj);
  42814. var xref = this.xref, blackColor = new Uint8Array(3);
  42815. while (queue.length > 0) {
  42816. var i = queue.shift();
  42817. var outlineDict = xref.fetchIfRef(i.obj);
  42818. if (outlineDict === null) {
  42819. continue;
  42820. }
  42821. assert(outlineDict.has('Title'), 'Invalid outline item');
  42822. var data = {
  42823. url: null,
  42824. dest: null
  42825. };
  42826. Catalog.parseDestDictionary({
  42827. destDict: outlineDict,
  42828. resultObj: data,
  42829. docBaseUrl: this.pdfManager.docBaseUrl
  42830. });
  42831. var title = outlineDict.get('Title');
  42832. var flags = outlineDict.get('F') || 0;
  42833. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  42834. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  42835. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  42836. }
  42837. var outlineItem = {
  42838. dest: data.dest,
  42839. url: data.url,
  42840. unsafeUrl: data.unsafeUrl,
  42841. newWindow: data.newWindow,
  42842. title: stringToPDFString(title),
  42843. color: rgbColor,
  42844. count: outlineDict.get('Count'),
  42845. bold: !!(flags & 2),
  42846. italic: !!(flags & 1),
  42847. items: []
  42848. };
  42849. i.parent.items.push(outlineItem);
  42850. obj = outlineDict.getRaw('First');
  42851. if (isRef(obj) && !processed.has(obj)) {
  42852. queue.push({
  42853. obj: obj,
  42854. parent: outlineItem
  42855. });
  42856. processed.put(obj);
  42857. }
  42858. obj = outlineDict.getRaw('Next');
  42859. if (isRef(obj) && !processed.has(obj)) {
  42860. queue.push({
  42861. obj: obj,
  42862. parent: i.parent
  42863. });
  42864. processed.put(obj);
  42865. }
  42866. }
  42867. return root.items.length > 0 ? root.items : null;
  42868. },
  42869. get numPages() {
  42870. var obj = this.toplevelPagesDict.get('Count');
  42871. assert(isInt(obj), 'page count in top level pages object is not an integer');
  42872. return shadow(this, 'num', obj);
  42873. },
  42874. get destinations() {
  42875. function fetchDestination(dest) {
  42876. return isDict(dest) ? dest.get('D') : dest;
  42877. }
  42878. var xref = this.xref;
  42879. var dests = {}, nameTreeRef, nameDictionaryRef;
  42880. var obj = this.catDict.get('Names');
  42881. if (obj && obj.has('Dests')) {
  42882. nameTreeRef = obj.getRaw('Dests');
  42883. } else if (this.catDict.has('Dests')) {
  42884. nameDictionaryRef = this.catDict.get('Dests');
  42885. }
  42886. if (nameDictionaryRef) {
  42887. obj = nameDictionaryRef;
  42888. obj.forEach(function catalogForEach(key, value) {
  42889. if (!value) {
  42890. return;
  42891. }
  42892. dests[key] = fetchDestination(value);
  42893. });
  42894. }
  42895. if (nameTreeRef) {
  42896. var nameTree = new NameTree(nameTreeRef, xref);
  42897. var names = nameTree.getAll();
  42898. for (var name in names) {
  42899. dests[name] = fetchDestination(names[name]);
  42900. }
  42901. }
  42902. return shadow(this, 'destinations', dests);
  42903. },
  42904. getDestination: function Catalog_getDestination(destinationId) {
  42905. function fetchDestination(dest) {
  42906. return isDict(dest) ? dest.get('D') : dest;
  42907. }
  42908. var xref = this.xref;
  42909. var dest = null, nameTreeRef, nameDictionaryRef;
  42910. var obj = this.catDict.get('Names');
  42911. if (obj && obj.has('Dests')) {
  42912. nameTreeRef = obj.getRaw('Dests');
  42913. } else if (this.catDict.has('Dests')) {
  42914. nameDictionaryRef = this.catDict.get('Dests');
  42915. }
  42916. if (nameDictionaryRef) {
  42917. var value = nameDictionaryRef.get(destinationId);
  42918. if (value) {
  42919. dest = fetchDestination(value);
  42920. }
  42921. }
  42922. if (nameTreeRef) {
  42923. var nameTree = new NameTree(nameTreeRef, xref);
  42924. dest = fetchDestination(nameTree.get(destinationId));
  42925. }
  42926. return dest;
  42927. },
  42928. get pageLabels() {
  42929. var obj = null;
  42930. try {
  42931. obj = this.readPageLabels();
  42932. } catch (ex) {
  42933. if (ex instanceof MissingDataException) {
  42934. throw ex;
  42935. }
  42936. warn('Unable to read page labels.');
  42937. }
  42938. return shadow(this, 'pageLabels', obj);
  42939. },
  42940. readPageLabels: function Catalog_readPageLabels() {
  42941. var obj = this.catDict.getRaw('PageLabels');
  42942. if (!obj) {
  42943. return null;
  42944. }
  42945. var pageLabels = new Array(this.numPages);
  42946. var style = null;
  42947. var prefix = '';
  42948. var numberTree = new NumberTree(obj, this.xref);
  42949. var nums = numberTree.getAll();
  42950. var currentLabel = '', currentIndex = 1;
  42951. for (var i = 0, ii = this.numPages; i < ii; i++) {
  42952. if (i in nums) {
  42953. var labelDict = nums[i];
  42954. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  42955. var type = labelDict.get('Type');
  42956. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  42957. var s = labelDict.get('S');
  42958. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  42959. style = s ? s.name : null;
  42960. var p = labelDict.get('P');
  42961. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  42962. prefix = p ? stringToPDFString(p) : '';
  42963. var st = labelDict.get('St');
  42964. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  42965. currentIndex = st || 1;
  42966. }
  42967. switch (style) {
  42968. case 'D':
  42969. currentLabel = currentIndex;
  42970. break;
  42971. case 'R':
  42972. case 'r':
  42973. currentLabel = Util.toRoman(currentIndex, style === 'r');
  42974. break;
  42975. case 'A':
  42976. case 'a':
  42977. var LIMIT = 26;
  42978. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  42979. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  42980. var letterIndex = currentIndex - 1;
  42981. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  42982. var charBuf = [];
  42983. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  42984. charBuf.push(character);
  42985. }
  42986. currentLabel = charBuf.join('');
  42987. break;
  42988. default:
  42989. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  42990. }
  42991. pageLabels[i] = prefix + currentLabel;
  42992. currentLabel = '';
  42993. currentIndex++;
  42994. }
  42995. return pageLabels;
  42996. },
  42997. get attachments() {
  42998. var xref = this.xref;
  42999. var attachments = null, nameTreeRef;
  43000. var obj = this.catDict.get('Names');
  43001. if (obj) {
  43002. nameTreeRef = obj.getRaw('EmbeddedFiles');
  43003. }
  43004. if (nameTreeRef) {
  43005. var nameTree = new NameTree(nameTreeRef, xref);
  43006. var names = nameTree.getAll();
  43007. for (var name in names) {
  43008. var fs = new FileSpec(names[name], xref);
  43009. if (!attachments) {
  43010. attachments = Object.create(null);
  43011. }
  43012. attachments[stringToPDFString(name)] = fs.serializable;
  43013. }
  43014. }
  43015. return shadow(this, 'attachments', attachments);
  43016. },
  43017. get javaScript() {
  43018. var xref = this.xref;
  43019. var obj = this.catDict.get('Names');
  43020. var javaScript = [];
  43021. function appendIfJavaScriptDict(jsDict) {
  43022. var type = jsDict.get('S');
  43023. if (!isName(type, 'JavaScript')) {
  43024. return;
  43025. }
  43026. var js = jsDict.get('JS');
  43027. if (isStream(js)) {
  43028. js = bytesToString(js.getBytes());
  43029. } else if (!isString(js)) {
  43030. return;
  43031. }
  43032. javaScript.push(stringToPDFString(js));
  43033. }
  43034. if (obj && obj.has('JavaScript')) {
  43035. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  43036. var names = nameTree.getAll();
  43037. for (var name in names) {
  43038. var jsDict = names[name];
  43039. if (isDict(jsDict)) {
  43040. appendIfJavaScriptDict(jsDict);
  43041. }
  43042. }
  43043. }
  43044. var openactionDict = this.catDict.get('OpenAction');
  43045. if (isDict(openactionDict, 'Action')) {
  43046. var actionType = openactionDict.get('S');
  43047. if (isName(actionType, 'Named')) {
  43048. var action = openactionDict.get('N');
  43049. if (isName(action, 'Print')) {
  43050. javaScript.push('print({});');
  43051. }
  43052. } else {
  43053. appendIfJavaScriptDict(openactionDict);
  43054. }
  43055. }
  43056. return shadow(this, 'javaScript', javaScript);
  43057. },
  43058. cleanup: function Catalog_cleanup() {
  43059. var promises = [];
  43060. this.fontCache.forEach(function (promise) {
  43061. promises.push(promise);
  43062. });
  43063. return Promise.all(promises).then(function (translatedFonts) {
  43064. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  43065. var font = translatedFonts[i].dict;
  43066. delete font.translated;
  43067. }
  43068. this.fontCache.clear();
  43069. }.bind(this));
  43070. },
  43071. getPage: function Catalog_getPage(pageIndex) {
  43072. if (!(pageIndex in this.pagePromises)) {
  43073. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  43074. var dict = a[0];
  43075. var ref = a[1];
  43076. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  43077. }.bind(this));
  43078. }
  43079. return this.pagePromises[pageIndex];
  43080. },
  43081. getPageDict: function Catalog_getPageDict(pageIndex) {
  43082. var capability = createPromiseCapability();
  43083. var nodesToVisit = [this.catDict.getRaw('Pages')];
  43084. var currentPageIndex = 0;
  43085. var xref = this.xref;
  43086. var checkAllKids = false;
  43087. function next() {
  43088. while (nodesToVisit.length) {
  43089. var currentNode = nodesToVisit.pop();
  43090. if (isRef(currentNode)) {
  43091. xref.fetchAsync(currentNode).then(function (obj) {
  43092. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  43093. if (pageIndex === currentPageIndex) {
  43094. capability.resolve([
  43095. obj,
  43096. currentNode
  43097. ]);
  43098. } else {
  43099. currentPageIndex++;
  43100. next();
  43101. }
  43102. return;
  43103. }
  43104. nodesToVisit.push(obj);
  43105. next();
  43106. }, capability.reject);
  43107. return;
  43108. }
  43109. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  43110. var count = currentNode.get('Count');
  43111. if (count === 0) {
  43112. checkAllKids = true;
  43113. }
  43114. if (currentPageIndex + count <= pageIndex) {
  43115. currentPageIndex += count;
  43116. continue;
  43117. }
  43118. var kids = currentNode.get('Kids');
  43119. assert(isArray(kids), 'page dictionary kids object is not an array');
  43120. if (!checkAllKids && count === kids.length) {
  43121. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  43122. currentPageIndex = pageIndex;
  43123. continue;
  43124. } else {
  43125. for (var last = kids.length - 1; last >= 0; last--) {
  43126. nodesToVisit.push(kids[last]);
  43127. }
  43128. }
  43129. }
  43130. capability.reject('Page index ' + pageIndex + ' not found.');
  43131. }
  43132. next();
  43133. return capability.promise;
  43134. },
  43135. getPageIndex: function Catalog_getPageIndex(pageRef) {
  43136. var xref = this.xref;
  43137. function pagesBeforeRef(kidRef) {
  43138. var total = 0;
  43139. var parentRef;
  43140. return xref.fetchAsync(kidRef).then(function (node) {
  43141. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  43142. throw new Error('The reference does not point to a /Page Dict.');
  43143. }
  43144. if (!node) {
  43145. return null;
  43146. }
  43147. assert(isDict(node), 'node must be a Dict.');
  43148. parentRef = node.getRaw('Parent');
  43149. return node.getAsync('Parent');
  43150. }).then(function (parent) {
  43151. if (!parent) {
  43152. return null;
  43153. }
  43154. assert(isDict(parent), 'parent must be a Dict.');
  43155. return parent.getAsync('Kids');
  43156. }).then(function (kids) {
  43157. if (!kids) {
  43158. return null;
  43159. }
  43160. var kidPromises = [];
  43161. var found = false;
  43162. for (var i = 0; i < kids.length; i++) {
  43163. var kid = kids[i];
  43164. assert(isRef(kid), 'kid must be a Ref.');
  43165. if (kid.num === kidRef.num) {
  43166. found = true;
  43167. break;
  43168. }
  43169. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  43170. if (kid.has('Count')) {
  43171. var count = kid.get('Count');
  43172. total += count;
  43173. } else {
  43174. total++;
  43175. }
  43176. }));
  43177. }
  43178. if (!found) {
  43179. error('kid ref not found in parents kids');
  43180. }
  43181. return Promise.all(kidPromises).then(function () {
  43182. return [
  43183. total,
  43184. parentRef
  43185. ];
  43186. });
  43187. });
  43188. }
  43189. var total = 0;
  43190. function next(ref) {
  43191. return pagesBeforeRef(ref).then(function (args) {
  43192. if (!args) {
  43193. return total;
  43194. }
  43195. var count = args[0];
  43196. var parentRef = args[1];
  43197. total += count;
  43198. return next(parentRef);
  43199. });
  43200. }
  43201. return next(pageRef);
  43202. }
  43203. };
  43204. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  43205. function addDefaultProtocolToUrl(url) {
  43206. if (url.indexOf('www.') === 0) {
  43207. return 'http://' + url;
  43208. }
  43209. return url;
  43210. }
  43211. function tryConvertUrlEncoding(url) {
  43212. try {
  43213. return stringToUTF8String(url);
  43214. } catch (e) {
  43215. return url;
  43216. }
  43217. }
  43218. var destDict = params.destDict;
  43219. if (!isDict(destDict)) {
  43220. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  43221. return;
  43222. }
  43223. var resultObj = params.resultObj;
  43224. if (typeof resultObj !== 'object') {
  43225. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  43226. return;
  43227. }
  43228. var docBaseUrl = params.docBaseUrl || null;
  43229. var action = destDict.get('A'), url, dest;
  43230. if (isDict(action)) {
  43231. var linkType = action.get('S').name;
  43232. switch (linkType) {
  43233. case 'URI':
  43234. url = action.get('URI');
  43235. if (isName(url)) {
  43236. url = '/' + url.name;
  43237. } else if (isString(url)) {
  43238. url = addDefaultProtocolToUrl(url);
  43239. }
  43240. break;
  43241. case 'GoTo':
  43242. dest = action.get('D');
  43243. break;
  43244. case 'Launch':
  43245. case 'GoToR':
  43246. var urlDict = action.get('F');
  43247. if (isDict(urlDict)) {
  43248. url = urlDict.get('F') || null;
  43249. } else if (isString(urlDict)) {
  43250. url = urlDict;
  43251. }
  43252. var remoteDest = action.get('D');
  43253. if (remoteDest) {
  43254. if (isName(remoteDest)) {
  43255. remoteDest = remoteDest.name;
  43256. }
  43257. if (isString(url)) {
  43258. var baseUrl = url.split('#')[0];
  43259. if (isString(remoteDest)) {
  43260. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  43261. } else if (isArray(remoteDest)) {
  43262. url = baseUrl + '#' + JSON.stringify(remoteDest);
  43263. }
  43264. }
  43265. }
  43266. var newWindow = action.get('NewWindow');
  43267. if (isBool(newWindow)) {
  43268. resultObj.newWindow = newWindow;
  43269. }
  43270. break;
  43271. case 'Named':
  43272. var namedAction = action.get('N');
  43273. if (isName(namedAction)) {
  43274. resultObj.action = namedAction.name;
  43275. }
  43276. break;
  43277. case 'JavaScript':
  43278. var jsAction = action.get('JS'), js;
  43279. if (isStream(jsAction)) {
  43280. js = bytesToString(jsAction.getBytes());
  43281. } else if (isString(jsAction)) {
  43282. js = jsAction;
  43283. }
  43284. if (js) {
  43285. var URL_OPEN_METHODS = [
  43286. 'app.launchURL',
  43287. 'window.open'
  43288. ];
  43289. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  43290. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  43291. if (jsUrl && jsUrl[1]) {
  43292. url = jsUrl[1];
  43293. break;
  43294. }
  43295. }
  43296. default:
  43297. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  43298. break;
  43299. }
  43300. } else if (destDict.has('Dest')) {
  43301. dest = destDict.get('Dest');
  43302. }
  43303. if (isString(url)) {
  43304. url = tryConvertUrlEncoding(url);
  43305. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  43306. if (absoluteUrl) {
  43307. resultObj.url = absoluteUrl.href;
  43308. }
  43309. resultObj.unsafeUrl = url;
  43310. }
  43311. if (dest) {
  43312. if (isName(dest)) {
  43313. dest = dest.name;
  43314. }
  43315. if (isString(dest) || isArray(dest)) {
  43316. resultObj.dest = dest;
  43317. }
  43318. }
  43319. };
  43320. return Catalog;
  43321. }();
  43322. var XRef = function XRefClosure() {
  43323. function XRef(stream, pdfManager) {
  43324. this.stream = stream;
  43325. this.pdfManager = pdfManager;
  43326. this.entries = [];
  43327. this.xrefstms = Object.create(null);
  43328. this.cache = [];
  43329. this.stats = {
  43330. streamTypes: [],
  43331. fontTypes: []
  43332. };
  43333. }
  43334. XRef.prototype = {
  43335. setStartXRef: function XRef_setStartXRef(startXRef) {
  43336. this.startXRefQueue = [startXRef];
  43337. },
  43338. parse: function XRef_parse(recoveryMode) {
  43339. var trailerDict;
  43340. if (!recoveryMode) {
  43341. trailerDict = this.readXRef();
  43342. } else {
  43343. warn('Indexing all PDF objects');
  43344. trailerDict = this.indexObjects();
  43345. }
  43346. trailerDict.assignXref(this);
  43347. this.trailer = trailerDict;
  43348. var encrypt = trailerDict.get('Encrypt');
  43349. if (isDict(encrypt)) {
  43350. var ids = trailerDict.get('ID');
  43351. var fileId = ids && ids.length ? ids[0] : '';
  43352. encrypt.suppressEncryption = true;
  43353. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.pdfManager.password);
  43354. }
  43355. if (!(this.root = trailerDict.get('Root'))) {
  43356. error('Invalid root reference');
  43357. }
  43358. },
  43359. processXRefTable: function XRef_processXRefTable(parser) {
  43360. if (!('tableState' in this)) {
  43361. this.tableState = {
  43362. entryNum: 0,
  43363. streamPos: parser.lexer.stream.pos,
  43364. parserBuf1: parser.buf1,
  43365. parserBuf2: parser.buf2
  43366. };
  43367. }
  43368. var obj = this.readXRefTable(parser);
  43369. if (!isCmd(obj, 'trailer')) {
  43370. error('Invalid XRef table: could not find trailer dictionary');
  43371. }
  43372. var dict = parser.getObj();
  43373. if (!isDict(dict) && dict.dict) {
  43374. dict = dict.dict;
  43375. }
  43376. if (!isDict(dict)) {
  43377. error('Invalid XRef table: could not parse trailer dictionary');
  43378. }
  43379. delete this.tableState;
  43380. return dict;
  43381. },
  43382. readXRefTable: function XRef_readXRefTable(parser) {
  43383. var stream = parser.lexer.stream;
  43384. var tableState = this.tableState;
  43385. stream.pos = tableState.streamPos;
  43386. parser.buf1 = tableState.parserBuf1;
  43387. parser.buf2 = tableState.parserBuf2;
  43388. var obj;
  43389. while (true) {
  43390. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  43391. if (isCmd(obj = parser.getObj(), 'trailer')) {
  43392. break;
  43393. }
  43394. tableState.firstEntryNum = obj;
  43395. tableState.entryCount = parser.getObj();
  43396. }
  43397. var first = tableState.firstEntryNum;
  43398. var count = tableState.entryCount;
  43399. if (!isInt(first) || !isInt(count)) {
  43400. error('Invalid XRef table: wrong types in subsection header');
  43401. }
  43402. for (var i = tableState.entryNum; i < count; i++) {
  43403. tableState.streamPos = stream.pos;
  43404. tableState.entryNum = i;
  43405. tableState.parserBuf1 = parser.buf1;
  43406. tableState.parserBuf2 = parser.buf2;
  43407. var entry = {};
  43408. entry.offset = parser.getObj();
  43409. entry.gen = parser.getObj();
  43410. var type = parser.getObj();
  43411. if (isCmd(type, 'f')) {
  43412. entry.free = true;
  43413. } else if (isCmd(type, 'n')) {
  43414. entry.uncompressed = true;
  43415. }
  43416. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  43417. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  43418. }
  43419. if (i === 0 && entry.free && first === 1) {
  43420. first = 0;
  43421. }
  43422. if (!this.entries[i + first]) {
  43423. this.entries[i + first] = entry;
  43424. }
  43425. }
  43426. tableState.entryNum = 0;
  43427. tableState.streamPos = stream.pos;
  43428. tableState.parserBuf1 = parser.buf1;
  43429. tableState.parserBuf2 = parser.buf2;
  43430. delete tableState.firstEntryNum;
  43431. delete tableState.entryCount;
  43432. }
  43433. if (this.entries[0] && !this.entries[0].free) {
  43434. error('Invalid XRef table: unexpected first object');
  43435. }
  43436. return obj;
  43437. },
  43438. processXRefStream: function XRef_processXRefStream(stream) {
  43439. if (!('streamState' in this)) {
  43440. var streamParameters = stream.dict;
  43441. var byteWidths = streamParameters.get('W');
  43442. var range = streamParameters.get('Index');
  43443. if (!range) {
  43444. range = [
  43445. 0,
  43446. streamParameters.get('Size')
  43447. ];
  43448. }
  43449. this.streamState = {
  43450. entryRanges: range,
  43451. byteWidths: byteWidths,
  43452. entryNum: 0,
  43453. streamPos: stream.pos
  43454. };
  43455. }
  43456. this.readXRefStream(stream);
  43457. delete this.streamState;
  43458. return stream.dict;
  43459. },
  43460. readXRefStream: function XRef_readXRefStream(stream) {
  43461. var i, j;
  43462. var streamState = this.streamState;
  43463. stream.pos = streamState.streamPos;
  43464. var byteWidths = streamState.byteWidths;
  43465. var typeFieldWidth = byteWidths[0];
  43466. var offsetFieldWidth = byteWidths[1];
  43467. var generationFieldWidth = byteWidths[2];
  43468. var entryRanges = streamState.entryRanges;
  43469. while (entryRanges.length > 0) {
  43470. var first = entryRanges[0];
  43471. var n = entryRanges[1];
  43472. if (!isInt(first) || !isInt(n)) {
  43473. error('Invalid XRef range fields: ' + first + ', ' + n);
  43474. }
  43475. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  43476. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  43477. }
  43478. for (i = streamState.entryNum; i < n; ++i) {
  43479. streamState.entryNum = i;
  43480. streamState.streamPos = stream.pos;
  43481. var type = 0, offset = 0, generation = 0;
  43482. for (j = 0; j < typeFieldWidth; ++j) {
  43483. type = type << 8 | stream.getByte();
  43484. }
  43485. if (typeFieldWidth === 0) {
  43486. type = 1;
  43487. }
  43488. for (j = 0; j < offsetFieldWidth; ++j) {
  43489. offset = offset << 8 | stream.getByte();
  43490. }
  43491. for (j = 0; j < generationFieldWidth; ++j) {
  43492. generation = generation << 8 | stream.getByte();
  43493. }
  43494. var entry = {};
  43495. entry.offset = offset;
  43496. entry.gen = generation;
  43497. switch (type) {
  43498. case 0:
  43499. entry.free = true;
  43500. break;
  43501. case 1:
  43502. entry.uncompressed = true;
  43503. break;
  43504. case 2:
  43505. break;
  43506. default:
  43507. error('Invalid XRef entry type: ' + type);
  43508. }
  43509. if (!this.entries[first + i]) {
  43510. this.entries[first + i] = entry;
  43511. }
  43512. }
  43513. streamState.entryNum = 0;
  43514. streamState.streamPos = stream.pos;
  43515. entryRanges.splice(0, 2);
  43516. }
  43517. },
  43518. indexObjects: function XRef_indexObjects() {
  43519. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  43520. var PERCENT = 0x25, LT = 0x3C;
  43521. function readToken(data, offset) {
  43522. var token = '', ch = data[offset];
  43523. while (ch !== LF && ch !== CR && ch !== LT) {
  43524. if (++offset >= data.length) {
  43525. break;
  43526. }
  43527. token += String.fromCharCode(ch);
  43528. ch = data[offset];
  43529. }
  43530. return token;
  43531. }
  43532. function skipUntil(data, offset, what) {
  43533. var length = what.length, dataLength = data.length;
  43534. var skipped = 0;
  43535. while (offset < dataLength) {
  43536. var i = 0;
  43537. while (i < length && data[offset + i] === what[i]) {
  43538. ++i;
  43539. }
  43540. if (i >= length) {
  43541. break;
  43542. }
  43543. offset++;
  43544. skipped++;
  43545. }
  43546. return skipped;
  43547. }
  43548. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  43549. var trailerBytes = new Uint8Array([
  43550. 116,
  43551. 114,
  43552. 97,
  43553. 105,
  43554. 108,
  43555. 101,
  43556. 114
  43557. ]);
  43558. var startxrefBytes = new Uint8Array([
  43559. 115,
  43560. 116,
  43561. 97,
  43562. 114,
  43563. 116,
  43564. 120,
  43565. 114,
  43566. 101,
  43567. 102
  43568. ]);
  43569. var endobjBytes = new Uint8Array([
  43570. 101,
  43571. 110,
  43572. 100,
  43573. 111,
  43574. 98,
  43575. 106
  43576. ]);
  43577. var xrefBytes = new Uint8Array([
  43578. 47,
  43579. 88,
  43580. 82,
  43581. 101,
  43582. 102
  43583. ]);
  43584. this.entries.length = 0;
  43585. var stream = this.stream;
  43586. stream.pos = 0;
  43587. var buffer = stream.getBytes();
  43588. var position = stream.start, length = buffer.length;
  43589. var trailers = [], xrefStms = [];
  43590. while (position < length) {
  43591. var ch = buffer[position];
  43592. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  43593. ++position;
  43594. continue;
  43595. }
  43596. if (ch === PERCENT) {
  43597. do {
  43598. ++position;
  43599. if (position >= length) {
  43600. break;
  43601. }
  43602. ch = buffer[position];
  43603. } while (ch !== LF && ch !== CR);
  43604. continue;
  43605. }
  43606. var token = readToken(buffer, position);
  43607. var m;
  43608. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  43609. position += skipUntil(buffer, position, trailerBytes);
  43610. trailers.push(position);
  43611. position += skipUntil(buffer, position, startxrefBytes);
  43612. } else if (m = objRegExp.exec(token)) {
  43613. if (typeof this.entries[m[1]] === 'undefined') {
  43614. this.entries[m[1]] = {
  43615. offset: position - stream.start,
  43616. gen: m[2] | 0,
  43617. uncompressed: true
  43618. };
  43619. }
  43620. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  43621. var content = buffer.subarray(position, position + contentLength);
  43622. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  43623. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  43624. xrefStms.push(position - stream.start);
  43625. this.xrefstms[position - stream.start] = 1;
  43626. }
  43627. position += contentLength;
  43628. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  43629. trailers.push(position);
  43630. position += skipUntil(buffer, position, startxrefBytes);
  43631. } else {
  43632. position += token.length + 1;
  43633. }
  43634. }
  43635. var i, ii;
  43636. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  43637. this.startXRefQueue.push(xrefStms[i]);
  43638. this.readXRef(true);
  43639. }
  43640. var dict;
  43641. for (i = 0, ii = trailers.length; i < ii; ++i) {
  43642. stream.pos = trailers[i];
  43643. var parser = new Parser(new Lexer(stream), true, this, true);
  43644. var obj = parser.getObj();
  43645. if (!isCmd(obj, 'trailer')) {
  43646. continue;
  43647. }
  43648. dict = parser.getObj();
  43649. if (!isDict(dict)) {
  43650. continue;
  43651. }
  43652. if (dict.has('ID')) {
  43653. return dict;
  43654. }
  43655. }
  43656. if (dict) {
  43657. return dict;
  43658. }
  43659. throw new InvalidPDFException('Invalid PDF structure');
  43660. },
  43661. readXRef: function XRef_readXRef(recoveryMode) {
  43662. var stream = this.stream;
  43663. try {
  43664. while (this.startXRefQueue.length) {
  43665. var startXRef = this.startXRefQueue[0];
  43666. stream.pos = startXRef + stream.start;
  43667. var parser = new Parser(new Lexer(stream), true, this);
  43668. var obj = parser.getObj();
  43669. var dict;
  43670. if (isCmd(obj, 'xref')) {
  43671. dict = this.processXRefTable(parser);
  43672. if (!this.topDict) {
  43673. this.topDict = dict;
  43674. }
  43675. obj = dict.get('XRefStm');
  43676. if (isInt(obj)) {
  43677. var pos = obj;
  43678. if (!(pos in this.xrefstms)) {
  43679. this.xrefstms[pos] = 1;
  43680. this.startXRefQueue.push(pos);
  43681. }
  43682. }
  43683. } else if (isInt(obj)) {
  43684. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  43685. error('Invalid XRef stream');
  43686. }
  43687. dict = this.processXRefStream(obj);
  43688. if (!this.topDict) {
  43689. this.topDict = dict;
  43690. }
  43691. if (!dict) {
  43692. error('Failed to read XRef stream');
  43693. }
  43694. } else {
  43695. error('Invalid XRef stream header');
  43696. }
  43697. obj = dict.get('Prev');
  43698. if (isInt(obj)) {
  43699. this.startXRefQueue.push(obj);
  43700. } else if (isRef(obj)) {
  43701. this.startXRefQueue.push(obj.num);
  43702. }
  43703. this.startXRefQueue.shift();
  43704. }
  43705. return this.topDict;
  43706. } catch (e) {
  43707. if (e instanceof MissingDataException) {
  43708. throw e;
  43709. }
  43710. info('(while reading XRef): ' + e);
  43711. }
  43712. if (recoveryMode) {
  43713. return;
  43714. }
  43715. throw new XRefParseException();
  43716. },
  43717. getEntry: function XRef_getEntry(i) {
  43718. var xrefEntry = this.entries[i];
  43719. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  43720. return xrefEntry;
  43721. }
  43722. return null;
  43723. },
  43724. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  43725. if (!isRef(obj)) {
  43726. return obj;
  43727. }
  43728. return this.fetch(obj, suppressEncryption);
  43729. },
  43730. fetch: function XRef_fetch(ref, suppressEncryption) {
  43731. assert(isRef(ref), 'ref object is not a reference');
  43732. var num = ref.num;
  43733. if (num in this.cache) {
  43734. var cacheEntry = this.cache[num];
  43735. return cacheEntry;
  43736. }
  43737. var xrefEntry = this.getEntry(num);
  43738. if (xrefEntry === null) {
  43739. return this.cache[num] = null;
  43740. }
  43741. if (xrefEntry.uncompressed) {
  43742. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  43743. } else {
  43744. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  43745. }
  43746. if (isDict(xrefEntry)) {
  43747. xrefEntry.objId = ref.toString();
  43748. } else if (isStream(xrefEntry)) {
  43749. xrefEntry.dict.objId = ref.toString();
  43750. }
  43751. return xrefEntry;
  43752. },
  43753. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  43754. var gen = ref.gen;
  43755. var num = ref.num;
  43756. if (xrefEntry.gen !== gen) {
  43757. error('inconsistent generation in XRef');
  43758. }
  43759. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  43760. var parser = new Parser(new Lexer(stream), true, this);
  43761. var obj1 = parser.getObj();
  43762. var obj2 = parser.getObj();
  43763. var obj3 = parser.getObj();
  43764. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  43765. error('bad XRef entry');
  43766. }
  43767. if (!isCmd(obj3, 'obj')) {
  43768. if (obj3.cmd.indexOf('obj') === 0) {
  43769. num = parseInt(obj3.cmd.substring(3), 10);
  43770. if (!isNaN(num)) {
  43771. return num;
  43772. }
  43773. }
  43774. error('bad XRef entry');
  43775. }
  43776. if (this.encrypt && !suppressEncryption) {
  43777. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  43778. } else {
  43779. xrefEntry = parser.getObj();
  43780. }
  43781. if (!isStream(xrefEntry)) {
  43782. this.cache[num] = xrefEntry;
  43783. }
  43784. return xrefEntry;
  43785. },
  43786. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  43787. var tableOffset = xrefEntry.offset;
  43788. var stream = this.fetch(new Ref(tableOffset, 0));
  43789. if (!isStream(stream)) {
  43790. error('bad ObjStm stream');
  43791. }
  43792. var first = stream.dict.get('First');
  43793. var n = stream.dict.get('N');
  43794. if (!isInt(first) || !isInt(n)) {
  43795. error('invalid first and n parameters for ObjStm stream');
  43796. }
  43797. var parser = new Parser(new Lexer(stream), false, this);
  43798. parser.allowStreams = true;
  43799. var i, entries = [], num, nums = [];
  43800. for (i = 0; i < n; ++i) {
  43801. num = parser.getObj();
  43802. if (!isInt(num)) {
  43803. error('invalid object number in the ObjStm stream: ' + num);
  43804. }
  43805. nums.push(num);
  43806. var offset = parser.getObj();
  43807. if (!isInt(offset)) {
  43808. error('invalid object offset in the ObjStm stream: ' + offset);
  43809. }
  43810. }
  43811. for (i = 0; i < n; ++i) {
  43812. entries.push(parser.getObj());
  43813. if (isCmd(parser.buf1, 'endobj')) {
  43814. parser.shift();
  43815. }
  43816. num = nums[i];
  43817. var entry = this.entries[num];
  43818. if (entry && entry.offset === tableOffset && entry.gen === i) {
  43819. this.cache[num] = entries[i];
  43820. }
  43821. }
  43822. xrefEntry = entries[xrefEntry.gen];
  43823. if (xrefEntry === undefined) {
  43824. error('bad XRef entry for compressed object');
  43825. }
  43826. return xrefEntry;
  43827. },
  43828. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  43829. if (!isRef(obj)) {
  43830. return Promise.resolve(obj);
  43831. }
  43832. return this.fetchAsync(obj, suppressEncryption);
  43833. },
  43834. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  43835. var streamManager = this.stream.manager;
  43836. var xref = this;
  43837. return new Promise(function tryFetch(resolve, reject) {
  43838. try {
  43839. resolve(xref.fetch(ref, suppressEncryption));
  43840. } catch (e) {
  43841. if (e instanceof MissingDataException) {
  43842. streamManager.requestRange(e.begin, e.end).then(function () {
  43843. tryFetch(resolve, reject);
  43844. }, reject);
  43845. return;
  43846. }
  43847. reject(e);
  43848. }
  43849. });
  43850. },
  43851. getCatalogObj: function XRef_getCatalogObj() {
  43852. return this.root;
  43853. }
  43854. };
  43855. return XRef;
  43856. }();
  43857. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  43858. function NameOrNumberTree(root, xref) {
  43859. throw new Error('Cannot initialize NameOrNumberTree.');
  43860. }
  43861. NameOrNumberTree.prototype = {
  43862. getAll: function NameOrNumberTree_getAll() {
  43863. var dict = Object.create(null);
  43864. if (!this.root) {
  43865. return dict;
  43866. }
  43867. var xref = this.xref;
  43868. var processed = new RefSet();
  43869. processed.put(this.root);
  43870. var queue = [this.root];
  43871. while (queue.length > 0) {
  43872. var i, n;
  43873. var obj = xref.fetchIfRef(queue.shift());
  43874. if (!isDict(obj)) {
  43875. continue;
  43876. }
  43877. if (obj.has('Kids')) {
  43878. var kids = obj.get('Kids');
  43879. for (i = 0, n = kids.length; i < n; i++) {
  43880. var kid = kids[i];
  43881. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  43882. queue.push(kid);
  43883. processed.put(kid);
  43884. }
  43885. continue;
  43886. }
  43887. var entries = obj.get(this._type);
  43888. if (isArray(entries)) {
  43889. for (i = 0, n = entries.length; i < n; i += 2) {
  43890. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  43891. }
  43892. }
  43893. }
  43894. return dict;
  43895. },
  43896. get: function NameOrNumberTree_get(key) {
  43897. if (!this.root) {
  43898. return null;
  43899. }
  43900. var xref = this.xref;
  43901. var kidsOrEntries = xref.fetchIfRef(this.root);
  43902. var loopCount = 0;
  43903. var MAX_LEVELS = 10;
  43904. var l, r, m;
  43905. while (kidsOrEntries.has('Kids')) {
  43906. if (++loopCount > MAX_LEVELS) {
  43907. warn('Search depth limit reached for "' + this._type + '" tree.');
  43908. return null;
  43909. }
  43910. var kids = kidsOrEntries.get('Kids');
  43911. if (!isArray(kids)) {
  43912. return null;
  43913. }
  43914. l = 0;
  43915. r = kids.length - 1;
  43916. while (l <= r) {
  43917. m = l + r >> 1;
  43918. var kid = xref.fetchIfRef(kids[m]);
  43919. var limits = kid.get('Limits');
  43920. if (key < xref.fetchIfRef(limits[0])) {
  43921. r = m - 1;
  43922. } else if (key > xref.fetchIfRef(limits[1])) {
  43923. l = m + 1;
  43924. } else {
  43925. kidsOrEntries = xref.fetchIfRef(kids[m]);
  43926. break;
  43927. }
  43928. }
  43929. if (l > r) {
  43930. return null;
  43931. }
  43932. }
  43933. var entries = kidsOrEntries.get(this._type);
  43934. if (isArray(entries)) {
  43935. l = 0;
  43936. r = entries.length - 2;
  43937. while (l <= r) {
  43938. m = l + r & ~1;
  43939. var currentKey = xref.fetchIfRef(entries[m]);
  43940. if (key < currentKey) {
  43941. r = m - 2;
  43942. } else if (key > currentKey) {
  43943. l = m + 2;
  43944. } else {
  43945. return xref.fetchIfRef(entries[m + 1]);
  43946. }
  43947. }
  43948. }
  43949. return null;
  43950. }
  43951. };
  43952. return NameOrNumberTree;
  43953. }();
  43954. var NameTree = function NameTreeClosure() {
  43955. function NameTree(root, xref) {
  43956. this.root = root;
  43957. this.xref = xref;
  43958. this._type = 'Names';
  43959. }
  43960. Util.inherit(NameTree, NameOrNumberTree, {});
  43961. return NameTree;
  43962. }();
  43963. var NumberTree = function NumberTreeClosure() {
  43964. function NumberTree(root, xref) {
  43965. this.root = root;
  43966. this.xref = xref;
  43967. this._type = 'Nums';
  43968. }
  43969. Util.inherit(NumberTree, NameOrNumberTree, {});
  43970. return NumberTree;
  43971. }();
  43972. var FileSpec = function FileSpecClosure() {
  43973. function FileSpec(root, xref) {
  43974. if (!root || !isDict(root)) {
  43975. return;
  43976. }
  43977. this.xref = xref;
  43978. this.root = root;
  43979. if (root.has('FS')) {
  43980. this.fs = root.get('FS');
  43981. }
  43982. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  43983. if (root.has('RF')) {
  43984. warn('Related file specifications are not supported');
  43985. }
  43986. this.contentAvailable = true;
  43987. if (!root.has('EF')) {
  43988. this.contentAvailable = false;
  43989. warn('Non-embedded file specifications are not supported');
  43990. }
  43991. }
  43992. function pickPlatformItem(dict) {
  43993. if (dict.has('UF')) {
  43994. return dict.get('UF');
  43995. } else if (dict.has('F')) {
  43996. return dict.get('F');
  43997. } else if (dict.has('Unix')) {
  43998. return dict.get('Unix');
  43999. } else if (dict.has('Mac')) {
  44000. return dict.get('Mac');
  44001. } else if (dict.has('DOS')) {
  44002. return dict.get('DOS');
  44003. }
  44004. return null;
  44005. }
  44006. FileSpec.prototype = {
  44007. get filename() {
  44008. if (!this._filename && this.root) {
  44009. var filename = pickPlatformItem(this.root) || 'unnamed';
  44010. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  44011. }
  44012. return this._filename;
  44013. },
  44014. get content() {
  44015. if (!this.contentAvailable) {
  44016. return null;
  44017. }
  44018. if (!this.contentRef && this.root) {
  44019. this.contentRef = pickPlatformItem(this.root.get('EF'));
  44020. }
  44021. var content = null;
  44022. if (this.contentRef) {
  44023. var xref = this.xref;
  44024. var fileObj = xref.fetchIfRef(this.contentRef);
  44025. if (fileObj && isStream(fileObj)) {
  44026. content = fileObj.getBytes();
  44027. } else {
  44028. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  44029. }
  44030. } else {
  44031. warn('Embedded file specification does not have a content');
  44032. }
  44033. return content;
  44034. },
  44035. get serializable() {
  44036. return {
  44037. filename: this.filename,
  44038. content: this.content
  44039. };
  44040. }
  44041. };
  44042. return FileSpec;
  44043. }();
  44044. var ObjectLoader = function () {
  44045. function mayHaveChildren(value) {
  44046. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  44047. }
  44048. function addChildren(node, nodesToVisit) {
  44049. var value;
  44050. if (isDict(node) || isStream(node)) {
  44051. var map;
  44052. if (isDict(node)) {
  44053. map = node.map;
  44054. } else {
  44055. map = node.dict.map;
  44056. }
  44057. for (var key in map) {
  44058. value = map[key];
  44059. if (mayHaveChildren(value)) {
  44060. nodesToVisit.push(value);
  44061. }
  44062. }
  44063. } else if (isArray(node)) {
  44064. for (var i = 0, ii = node.length; i < ii; i++) {
  44065. value = node[i];
  44066. if (mayHaveChildren(value)) {
  44067. nodesToVisit.push(value);
  44068. }
  44069. }
  44070. }
  44071. }
  44072. function ObjectLoader(obj, keys, xref) {
  44073. this.obj = obj;
  44074. this.keys = keys;
  44075. this.xref = xref;
  44076. this.refSet = null;
  44077. this.capability = null;
  44078. }
  44079. ObjectLoader.prototype = {
  44080. load: function ObjectLoader_load() {
  44081. var keys = this.keys;
  44082. this.capability = createPromiseCapability();
  44083. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  44084. this.capability.resolve();
  44085. return this.capability.promise;
  44086. }
  44087. this.refSet = new RefSet();
  44088. var nodesToVisit = [];
  44089. for (var i = 0; i < keys.length; i++) {
  44090. nodesToVisit.push(this.obj[keys[i]]);
  44091. }
  44092. this._walk(nodesToVisit);
  44093. return this.capability.promise;
  44094. },
  44095. _walk: function ObjectLoader_walk(nodesToVisit) {
  44096. var nodesToRevisit = [];
  44097. var pendingRequests = [];
  44098. while (nodesToVisit.length) {
  44099. var currentNode = nodesToVisit.pop();
  44100. if (isRef(currentNode)) {
  44101. if (this.refSet.has(currentNode)) {
  44102. continue;
  44103. }
  44104. try {
  44105. var ref = currentNode;
  44106. this.refSet.put(ref);
  44107. currentNode = this.xref.fetch(currentNode);
  44108. } catch (e) {
  44109. if (!(e instanceof MissingDataException)) {
  44110. throw e;
  44111. }
  44112. nodesToRevisit.push(currentNode);
  44113. pendingRequests.push({
  44114. begin: e.begin,
  44115. end: e.end
  44116. });
  44117. }
  44118. }
  44119. if (currentNode && currentNode.getBaseStreams) {
  44120. var baseStreams = currentNode.getBaseStreams();
  44121. var foundMissingData = false;
  44122. for (var i = 0; i < baseStreams.length; i++) {
  44123. var stream = baseStreams[i];
  44124. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  44125. foundMissingData = true;
  44126. pendingRequests.push({
  44127. begin: stream.start,
  44128. end: stream.end
  44129. });
  44130. }
  44131. }
  44132. if (foundMissingData) {
  44133. nodesToRevisit.push(currentNode);
  44134. }
  44135. }
  44136. addChildren(currentNode, nodesToVisit);
  44137. }
  44138. if (pendingRequests.length) {
  44139. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  44140. nodesToVisit = nodesToRevisit;
  44141. for (var i = 0; i < nodesToRevisit.length; i++) {
  44142. var node = nodesToRevisit[i];
  44143. if (isRef(node)) {
  44144. this.refSet.remove(node);
  44145. }
  44146. }
  44147. this._walk(nodesToVisit);
  44148. }.bind(this), this.capability.reject);
  44149. return;
  44150. }
  44151. this.refSet = null;
  44152. this.capability.resolve();
  44153. }
  44154. };
  44155. return ObjectLoader;
  44156. }();
  44157. exports.Catalog = Catalog;
  44158. exports.ObjectLoader = ObjectLoader;
  44159. exports.XRef = XRef;
  44160. exports.FileSpec = FileSpec;
  44161. }));
  44162. (function (root, factory) {
  44163. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  44164. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  44165. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  44166. var MissingDataException = sharedUtil.MissingDataException;
  44167. var Util = sharedUtil.Util;
  44168. var assert = sharedUtil.assert;
  44169. var error = sharedUtil.error;
  44170. var info = sharedUtil.info;
  44171. var warn = sharedUtil.warn;
  44172. var isStream = corePrimitives.isStream;
  44173. var PDFFunction = coreFunction.PDFFunction;
  44174. var ColorSpace = coreColorSpace.ColorSpace;
  44175. var ShadingType = {
  44176. FUNCTION_BASED: 1,
  44177. AXIAL: 2,
  44178. RADIAL: 3,
  44179. FREE_FORM_MESH: 4,
  44180. LATTICE_FORM_MESH: 5,
  44181. COONS_PATCH_MESH: 6,
  44182. TENSOR_PATCH_MESH: 7
  44183. };
  44184. var Pattern = function PatternClosure() {
  44185. function Pattern() {
  44186. error('should not call Pattern constructor');
  44187. }
  44188. Pattern.prototype = {
  44189. getPattern: function Pattern_getPattern(ctx) {
  44190. error('Should not call Pattern.getStyle: ' + ctx);
  44191. }
  44192. };
  44193. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  44194. var dict = isStream(shading) ? shading.dict : shading;
  44195. var type = dict.get('ShadingType');
  44196. try {
  44197. switch (type) {
  44198. case ShadingType.AXIAL:
  44199. case ShadingType.RADIAL:
  44200. return new Shadings.RadialAxial(dict, matrix, xref, res);
  44201. case ShadingType.FREE_FORM_MESH:
  44202. case ShadingType.LATTICE_FORM_MESH:
  44203. case ShadingType.COONS_PATCH_MESH:
  44204. case ShadingType.TENSOR_PATCH_MESH:
  44205. return new Shadings.Mesh(shading, matrix, xref, res);
  44206. default:
  44207. throw new Error('Unsupported ShadingType: ' + type);
  44208. }
  44209. } catch (ex) {
  44210. if (ex instanceof MissingDataException) {
  44211. throw ex;
  44212. }
  44213. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  44214. warn(ex);
  44215. return new Shadings.Dummy();
  44216. }
  44217. };
  44218. return Pattern;
  44219. }();
  44220. var Shadings = {};
  44221. Shadings.SMALL_NUMBER = 1e-6;
  44222. Shadings.RadialAxial = function RadialAxialClosure() {
  44223. function RadialAxial(dict, matrix, xref, res) {
  44224. this.matrix = matrix;
  44225. this.coordsArr = dict.getArray('Coords');
  44226. this.shadingType = dict.get('ShadingType');
  44227. this.type = 'Pattern';
  44228. var cs = dict.get('ColorSpace', 'CS');
  44229. cs = ColorSpace.parse(cs, xref, res);
  44230. this.cs = cs;
  44231. var t0 = 0.0, t1 = 1.0;
  44232. if (dict.has('Domain')) {
  44233. var domainArr = dict.getArray('Domain');
  44234. t0 = domainArr[0];
  44235. t1 = domainArr[1];
  44236. }
  44237. var extendStart = false, extendEnd = false;
  44238. if (dict.has('Extend')) {
  44239. var extendArr = dict.getArray('Extend');
  44240. extendStart = extendArr[0];
  44241. extendEnd = extendArr[1];
  44242. }
  44243. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  44244. var x1 = this.coordsArr[0];
  44245. var y1 = this.coordsArr[1];
  44246. var r1 = this.coordsArr[2];
  44247. var x2 = this.coordsArr[3];
  44248. var y2 = this.coordsArr[4];
  44249. var r2 = this.coordsArr[5];
  44250. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  44251. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  44252. warn('Unsupported radial gradient.');
  44253. }
  44254. }
  44255. this.extendStart = extendStart;
  44256. this.extendEnd = extendEnd;
  44257. var fnObj = dict.get('Function');
  44258. var fn = PDFFunction.parseArray(xref, fnObj);
  44259. var diff = t1 - t0;
  44260. var step = diff / 10;
  44261. var colorStops = this.colorStops = [];
  44262. if (t0 >= t1 || step <= 0) {
  44263. info('Bad shading domain.');
  44264. return;
  44265. }
  44266. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  44267. var rgbColor;
  44268. for (var i = t0; i <= t1; i += step) {
  44269. ratio[0] = i;
  44270. fn(ratio, 0, color, 0);
  44271. rgbColor = cs.getRgb(color, 0);
  44272. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  44273. colorStops.push([
  44274. (i - t0) / diff,
  44275. cssColor
  44276. ]);
  44277. }
  44278. var background = 'transparent';
  44279. if (dict.has('Background')) {
  44280. rgbColor = cs.getRgb(dict.get('Background'), 0);
  44281. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  44282. }
  44283. if (!extendStart) {
  44284. colorStops.unshift([
  44285. 0,
  44286. background
  44287. ]);
  44288. colorStops[1][0] += Shadings.SMALL_NUMBER;
  44289. }
  44290. if (!extendEnd) {
  44291. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  44292. colorStops.push([
  44293. 1,
  44294. background
  44295. ]);
  44296. }
  44297. this.colorStops = colorStops;
  44298. }
  44299. RadialAxial.prototype = {
  44300. getIR: function RadialAxial_getIR() {
  44301. var coordsArr = this.coordsArr;
  44302. var shadingType = this.shadingType;
  44303. var type, p0, p1, r0, r1;
  44304. if (shadingType === ShadingType.AXIAL) {
  44305. p0 = [
  44306. coordsArr[0],
  44307. coordsArr[1]
  44308. ];
  44309. p1 = [
  44310. coordsArr[2],
  44311. coordsArr[3]
  44312. ];
  44313. r0 = null;
  44314. r1 = null;
  44315. type = 'axial';
  44316. } else if (shadingType === ShadingType.RADIAL) {
  44317. p0 = [
  44318. coordsArr[0],
  44319. coordsArr[1]
  44320. ];
  44321. p1 = [
  44322. coordsArr[3],
  44323. coordsArr[4]
  44324. ];
  44325. r0 = coordsArr[2];
  44326. r1 = coordsArr[5];
  44327. type = 'radial';
  44328. } else {
  44329. error('getPattern type unknown: ' + shadingType);
  44330. }
  44331. var matrix = this.matrix;
  44332. if (matrix) {
  44333. p0 = Util.applyTransform(p0, matrix);
  44334. p1 = Util.applyTransform(p1, matrix);
  44335. if (shadingType === ShadingType.RADIAL) {
  44336. var scale = Util.singularValueDecompose2dScale(matrix);
  44337. r0 *= scale[0];
  44338. r1 *= scale[1];
  44339. }
  44340. }
  44341. return [
  44342. 'RadialAxial',
  44343. type,
  44344. this.colorStops,
  44345. p0,
  44346. p1,
  44347. r0,
  44348. r1
  44349. ];
  44350. }
  44351. };
  44352. return RadialAxial;
  44353. }();
  44354. Shadings.Mesh = function MeshClosure() {
  44355. function MeshStreamReader(stream, context) {
  44356. this.stream = stream;
  44357. this.context = context;
  44358. this.buffer = 0;
  44359. this.bufferLength = 0;
  44360. var numComps = context.numComps;
  44361. this.tmpCompsBuf = new Float32Array(numComps);
  44362. var csNumComps = context.colorSpace.numComps;
  44363. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  44364. }
  44365. MeshStreamReader.prototype = {
  44366. get hasData() {
  44367. if (this.stream.end) {
  44368. return this.stream.pos < this.stream.end;
  44369. }
  44370. if (this.bufferLength > 0) {
  44371. return true;
  44372. }
  44373. var nextByte = this.stream.getByte();
  44374. if (nextByte < 0) {
  44375. return false;
  44376. }
  44377. this.buffer = nextByte;
  44378. this.bufferLength = 8;
  44379. return true;
  44380. },
  44381. readBits: function MeshStreamReader_readBits(n) {
  44382. var buffer = this.buffer;
  44383. var bufferLength = this.bufferLength;
  44384. if (n === 32) {
  44385. if (bufferLength === 0) {
  44386. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  44387. }
  44388. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  44389. var nextByte = this.stream.getByte();
  44390. this.buffer = nextByte & (1 << bufferLength) - 1;
  44391. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  44392. }
  44393. if (n === 8 && bufferLength === 0) {
  44394. return this.stream.getByte();
  44395. }
  44396. while (bufferLength < n) {
  44397. buffer = buffer << 8 | this.stream.getByte();
  44398. bufferLength += 8;
  44399. }
  44400. bufferLength -= n;
  44401. this.bufferLength = bufferLength;
  44402. this.buffer = buffer & (1 << bufferLength) - 1;
  44403. return buffer >> bufferLength;
  44404. },
  44405. align: function MeshStreamReader_align() {
  44406. this.buffer = 0;
  44407. this.bufferLength = 0;
  44408. },
  44409. readFlag: function MeshStreamReader_readFlag() {
  44410. return this.readBits(this.context.bitsPerFlag);
  44411. },
  44412. readCoordinate: function MeshStreamReader_readCoordinate() {
  44413. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  44414. var xi = this.readBits(bitsPerCoordinate);
  44415. var yi = this.readBits(bitsPerCoordinate);
  44416. var decode = this.context.decode;
  44417. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  44418. return [
  44419. xi * scale * (decode[1] - decode[0]) + decode[0],
  44420. yi * scale * (decode[3] - decode[2]) + decode[2]
  44421. ];
  44422. },
  44423. readComponents: function MeshStreamReader_readComponents() {
  44424. var numComps = this.context.numComps;
  44425. var bitsPerComponent = this.context.bitsPerComponent;
  44426. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  44427. var decode = this.context.decode;
  44428. var components = this.tmpCompsBuf;
  44429. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  44430. var ci = this.readBits(bitsPerComponent);
  44431. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  44432. }
  44433. var color = this.tmpCsCompsBuf;
  44434. if (this.context.colorFn) {
  44435. this.context.colorFn(components, 0, color, 0);
  44436. }
  44437. return this.context.colorSpace.getRgb(color, 0);
  44438. }
  44439. };
  44440. function decodeType4Shading(mesh, reader) {
  44441. var coords = mesh.coords;
  44442. var colors = mesh.colors;
  44443. var operators = [];
  44444. var ps = [];
  44445. var verticesLeft = 0;
  44446. while (reader.hasData) {
  44447. var f = reader.readFlag();
  44448. var coord = reader.readCoordinate();
  44449. var color = reader.readComponents();
  44450. if (verticesLeft === 0) {
  44451. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  44452. switch (f) {
  44453. case 0:
  44454. verticesLeft = 3;
  44455. break;
  44456. case 1:
  44457. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  44458. verticesLeft = 1;
  44459. break;
  44460. case 2:
  44461. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  44462. verticesLeft = 1;
  44463. break;
  44464. }
  44465. operators.push(f);
  44466. }
  44467. ps.push(coords.length);
  44468. coords.push(coord);
  44469. colors.push(color);
  44470. verticesLeft--;
  44471. reader.align();
  44472. }
  44473. mesh.figures.push({
  44474. type: 'triangles',
  44475. coords: new Int32Array(ps),
  44476. colors: new Int32Array(ps)
  44477. });
  44478. }
  44479. function decodeType5Shading(mesh, reader, verticesPerRow) {
  44480. var coords = mesh.coords;
  44481. var colors = mesh.colors;
  44482. var ps = [];
  44483. while (reader.hasData) {
  44484. var coord = reader.readCoordinate();
  44485. var color = reader.readComponents();
  44486. ps.push(coords.length);
  44487. coords.push(coord);
  44488. colors.push(color);
  44489. }
  44490. mesh.figures.push({
  44491. type: 'lattice',
  44492. coords: new Int32Array(ps),
  44493. colors: new Int32Array(ps),
  44494. verticesPerRow: verticesPerRow
  44495. });
  44496. }
  44497. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  44498. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  44499. var TRIANGLE_DENSITY = 20;
  44500. var getB = function getBClosure() {
  44501. function buildB(count) {
  44502. var lut = [];
  44503. for (var i = 0; i <= count; i++) {
  44504. var t = i / count, t_ = 1 - t;
  44505. lut.push(new Float32Array([
  44506. t_ * t_ * t_,
  44507. 3 * t * t_ * t_,
  44508. 3 * t * t * t_,
  44509. t * t * t
  44510. ]));
  44511. }
  44512. return lut;
  44513. }
  44514. var cache = [];
  44515. return function getB(count) {
  44516. if (!cache[count]) {
  44517. cache[count] = buildB(count);
  44518. }
  44519. return cache[count];
  44520. };
  44521. }();
  44522. function buildFigureFromPatch(mesh, index) {
  44523. var figure = mesh.figures[index];
  44524. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  44525. var coords = mesh.coords, colors = mesh.colors;
  44526. var pi = figure.coords;
  44527. var ci = figure.colors;
  44528. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  44529. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  44530. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  44531. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  44532. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  44533. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  44534. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  44535. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  44536. var verticesPerRow = splitXBy + 1;
  44537. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  44538. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  44539. var k = 0;
  44540. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  44541. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  44542. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  44543. for (var row = 0; row <= splitYBy; row++) {
  44544. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  44545. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  44546. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  44547. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  44548. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  44549. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  44550. for (var col = 0; col <= splitXBy; col++, k++) {
  44551. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  44552. continue;
  44553. }
  44554. var x = 0, y = 0;
  44555. var q = 0;
  44556. for (var i = 0; i <= 3; i++) {
  44557. for (var j = 0; j <= 3; j++, q++) {
  44558. var m = bRow[row][i] * bCol[col][j];
  44559. x += coords[pi[q]][0] * m;
  44560. y += coords[pi[q]][1] * m;
  44561. }
  44562. }
  44563. figureCoords[k] = coords.length;
  44564. coords.push([
  44565. x,
  44566. y
  44567. ]);
  44568. figureColors[k] = colors.length;
  44569. var newColor = new Uint8Array(3);
  44570. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  44571. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  44572. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  44573. colors.push(newColor);
  44574. }
  44575. }
  44576. figureCoords[0] = pi[0];
  44577. figureColors[0] = ci[0];
  44578. figureCoords[splitXBy] = pi[3];
  44579. figureColors[splitXBy] = ci[1];
  44580. figureCoords[verticesPerRow * splitYBy] = pi[12];
  44581. figureColors[verticesPerRow * splitYBy] = ci[2];
  44582. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  44583. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  44584. mesh.figures[index] = {
  44585. type: 'lattice',
  44586. coords: figureCoords,
  44587. colors: figureColors,
  44588. verticesPerRow: verticesPerRow
  44589. };
  44590. }
  44591. function decodeType6Shading(mesh, reader) {
  44592. var coords = mesh.coords;
  44593. var colors = mesh.colors;
  44594. var ps = new Int32Array(16);
  44595. var cs = new Int32Array(4);
  44596. while (reader.hasData) {
  44597. var f = reader.readFlag();
  44598. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  44599. var i, ii;
  44600. var pi = coords.length;
  44601. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  44602. coords.push(reader.readCoordinate());
  44603. }
  44604. var ci = colors.length;
  44605. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  44606. colors.push(reader.readComponents());
  44607. }
  44608. var tmp1, tmp2, tmp3, tmp4;
  44609. switch (f) {
  44610. case 0:
  44611. ps[12] = pi + 3;
  44612. ps[13] = pi + 4;
  44613. ps[14] = pi + 5;
  44614. ps[15] = pi + 6;
  44615. ps[8] = pi + 2;
  44616. ps[11] = pi + 7;
  44617. ps[4] = pi + 1;
  44618. ps[7] = pi + 8;
  44619. ps[0] = pi;
  44620. ps[1] = pi + 11;
  44621. ps[2] = pi + 10;
  44622. ps[3] = pi + 9;
  44623. cs[2] = ci + 1;
  44624. cs[3] = ci + 2;
  44625. cs[0] = ci;
  44626. cs[1] = ci + 3;
  44627. break;
  44628. case 1:
  44629. tmp1 = ps[12];
  44630. tmp2 = ps[13];
  44631. tmp3 = ps[14];
  44632. tmp4 = ps[15];
  44633. ps[12] = tmp4;
  44634. ps[13] = pi + 0;
  44635. ps[14] = pi + 1;
  44636. ps[15] = pi + 2;
  44637. ps[8] = tmp3;
  44638. ps[11] = pi + 3;
  44639. ps[4] = tmp2;
  44640. ps[7] = pi + 4;
  44641. ps[0] = tmp1;
  44642. ps[1] = pi + 7;
  44643. ps[2] = pi + 6;
  44644. ps[3] = pi + 5;
  44645. tmp1 = cs[2];
  44646. tmp2 = cs[3];
  44647. cs[2] = tmp2;
  44648. cs[3] = ci;
  44649. cs[0] = tmp1;
  44650. cs[1] = ci + 1;
  44651. break;
  44652. case 2:
  44653. tmp1 = ps[15];
  44654. tmp2 = ps[11];
  44655. ps[12] = ps[3];
  44656. ps[13] = pi + 0;
  44657. ps[14] = pi + 1;
  44658. ps[15] = pi + 2;
  44659. ps[8] = ps[7];
  44660. ps[11] = pi + 3;
  44661. ps[4] = tmp2;
  44662. ps[7] = pi + 4;
  44663. ps[0] = tmp1;
  44664. ps[1] = pi + 7;
  44665. ps[2] = pi + 6;
  44666. ps[3] = pi + 5;
  44667. tmp1 = cs[3];
  44668. cs[2] = cs[1];
  44669. cs[3] = ci;
  44670. cs[0] = tmp1;
  44671. cs[1] = ci + 1;
  44672. break;
  44673. case 3:
  44674. ps[12] = ps[0];
  44675. ps[13] = pi + 0;
  44676. ps[14] = pi + 1;
  44677. ps[15] = pi + 2;
  44678. ps[8] = ps[1];
  44679. ps[11] = pi + 3;
  44680. ps[4] = ps[2];
  44681. ps[7] = pi + 4;
  44682. ps[0] = ps[3];
  44683. ps[1] = pi + 7;
  44684. ps[2] = pi + 6;
  44685. ps[3] = pi + 5;
  44686. cs[2] = cs[0];
  44687. cs[3] = ci;
  44688. cs[0] = cs[1];
  44689. cs[1] = ci + 1;
  44690. break;
  44691. }
  44692. ps[5] = coords.length;
  44693. coords.push([
  44694. (-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,
  44695. (-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
  44696. ]);
  44697. ps[6] = coords.length;
  44698. coords.push([
  44699. (-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,
  44700. (-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
  44701. ]);
  44702. ps[9] = coords.length;
  44703. coords.push([
  44704. (-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,
  44705. (-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
  44706. ]);
  44707. ps[10] = coords.length;
  44708. coords.push([
  44709. (-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,
  44710. (-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
  44711. ]);
  44712. mesh.figures.push({
  44713. type: 'patch',
  44714. coords: new Int32Array(ps),
  44715. colors: new Int32Array(cs)
  44716. });
  44717. }
  44718. }
  44719. function decodeType7Shading(mesh, reader) {
  44720. var coords = mesh.coords;
  44721. var colors = mesh.colors;
  44722. var ps = new Int32Array(16);
  44723. var cs = new Int32Array(4);
  44724. while (reader.hasData) {
  44725. var f = reader.readFlag();
  44726. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  44727. var i, ii;
  44728. var pi = coords.length;
  44729. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  44730. coords.push(reader.readCoordinate());
  44731. }
  44732. var ci = colors.length;
  44733. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  44734. colors.push(reader.readComponents());
  44735. }
  44736. var tmp1, tmp2, tmp3, tmp4;
  44737. switch (f) {
  44738. case 0:
  44739. ps[12] = pi + 3;
  44740. ps[13] = pi + 4;
  44741. ps[14] = pi + 5;
  44742. ps[15] = pi + 6;
  44743. ps[8] = pi + 2;
  44744. ps[9] = pi + 13;
  44745. ps[10] = pi + 14;
  44746. ps[11] = pi + 7;
  44747. ps[4] = pi + 1;
  44748. ps[5] = pi + 12;
  44749. ps[6] = pi + 15;
  44750. ps[7] = pi + 8;
  44751. ps[0] = pi;
  44752. ps[1] = pi + 11;
  44753. ps[2] = pi + 10;
  44754. ps[3] = pi + 9;
  44755. cs[2] = ci + 1;
  44756. cs[3] = ci + 2;
  44757. cs[0] = ci;
  44758. cs[1] = ci + 3;
  44759. break;
  44760. case 1:
  44761. tmp1 = ps[12];
  44762. tmp2 = ps[13];
  44763. tmp3 = ps[14];
  44764. tmp4 = ps[15];
  44765. ps[12] = tmp4;
  44766. ps[13] = pi + 0;
  44767. ps[14] = pi + 1;
  44768. ps[15] = pi + 2;
  44769. ps[8] = tmp3;
  44770. ps[9] = pi + 9;
  44771. ps[10] = pi + 10;
  44772. ps[11] = pi + 3;
  44773. ps[4] = tmp2;
  44774. ps[5] = pi + 8;
  44775. ps[6] = pi + 11;
  44776. ps[7] = pi + 4;
  44777. ps[0] = tmp1;
  44778. ps[1] = pi + 7;
  44779. ps[2] = pi + 6;
  44780. ps[3] = pi + 5;
  44781. tmp1 = cs[2];
  44782. tmp2 = cs[3];
  44783. cs[2] = tmp2;
  44784. cs[3] = ci;
  44785. cs[0] = tmp1;
  44786. cs[1] = ci + 1;
  44787. break;
  44788. case 2:
  44789. tmp1 = ps[15];
  44790. tmp2 = ps[11];
  44791. ps[12] = ps[3];
  44792. ps[13] = pi + 0;
  44793. ps[14] = pi + 1;
  44794. ps[15] = pi + 2;
  44795. ps[8] = ps[7];
  44796. ps[9] = pi + 9;
  44797. ps[10] = pi + 10;
  44798. ps[11] = pi + 3;
  44799. ps[4] = tmp2;
  44800. ps[5] = pi + 8;
  44801. ps[6] = pi + 11;
  44802. ps[7] = pi + 4;
  44803. ps[0] = tmp1;
  44804. ps[1] = pi + 7;
  44805. ps[2] = pi + 6;
  44806. ps[3] = pi + 5;
  44807. tmp1 = cs[3];
  44808. cs[2] = cs[1];
  44809. cs[3] = ci;
  44810. cs[0] = tmp1;
  44811. cs[1] = ci + 1;
  44812. break;
  44813. case 3:
  44814. ps[12] = ps[0];
  44815. ps[13] = pi + 0;
  44816. ps[14] = pi + 1;
  44817. ps[15] = pi + 2;
  44818. ps[8] = ps[1];
  44819. ps[9] = pi + 9;
  44820. ps[10] = pi + 10;
  44821. ps[11] = pi + 3;
  44822. ps[4] = ps[2];
  44823. ps[5] = pi + 8;
  44824. ps[6] = pi + 11;
  44825. ps[7] = pi + 4;
  44826. ps[0] = ps[3];
  44827. ps[1] = pi + 7;
  44828. ps[2] = pi + 6;
  44829. ps[3] = pi + 5;
  44830. cs[2] = cs[0];
  44831. cs[3] = ci;
  44832. cs[0] = cs[1];
  44833. cs[1] = ci + 1;
  44834. break;
  44835. }
  44836. mesh.figures.push({
  44837. type: 'patch',
  44838. coords: new Int32Array(ps),
  44839. colors: new Int32Array(cs)
  44840. });
  44841. }
  44842. }
  44843. function updateBounds(mesh) {
  44844. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  44845. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  44846. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  44847. minX = minX > x ? x : minX;
  44848. minY = minY > y ? y : minY;
  44849. maxX = maxX < x ? x : maxX;
  44850. maxY = maxY < y ? y : maxY;
  44851. }
  44852. mesh.bounds = [
  44853. minX,
  44854. minY,
  44855. maxX,
  44856. maxY
  44857. ];
  44858. }
  44859. function packData(mesh) {
  44860. var i, ii, j, jj;
  44861. var coords = mesh.coords;
  44862. var coordsPacked = new Float32Array(coords.length * 2);
  44863. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  44864. var xy = coords[i];
  44865. coordsPacked[j++] = xy[0];
  44866. coordsPacked[j++] = xy[1];
  44867. }
  44868. mesh.coords = coordsPacked;
  44869. var colors = mesh.colors;
  44870. var colorsPacked = new Uint8Array(colors.length * 3);
  44871. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  44872. var c = colors[i];
  44873. colorsPacked[j++] = c[0];
  44874. colorsPacked[j++] = c[1];
  44875. colorsPacked[j++] = c[2];
  44876. }
  44877. mesh.colors = colorsPacked;
  44878. var figures = mesh.figures;
  44879. for (i = 0, ii = figures.length; i < ii; i++) {
  44880. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  44881. for (j = 0, jj = ps.length; j < jj; j++) {
  44882. ps[j] *= 2;
  44883. cs[j] *= 3;
  44884. }
  44885. }
  44886. }
  44887. function Mesh(stream, matrix, xref, res) {
  44888. assert(isStream(stream), 'Mesh data is not a stream');
  44889. var dict = stream.dict;
  44890. this.matrix = matrix;
  44891. this.shadingType = dict.get('ShadingType');
  44892. this.type = 'Pattern';
  44893. this.bbox = dict.getArray('BBox');
  44894. var cs = dict.get('ColorSpace', 'CS');
  44895. cs = ColorSpace.parse(cs, xref, res);
  44896. this.cs = cs;
  44897. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  44898. var fnObj = dict.get('Function');
  44899. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  44900. this.coords = [];
  44901. this.colors = [];
  44902. this.figures = [];
  44903. var decodeContext = {
  44904. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  44905. bitsPerComponent: dict.get('BitsPerComponent'),
  44906. bitsPerFlag: dict.get('BitsPerFlag'),
  44907. decode: dict.getArray('Decode'),
  44908. colorFn: fn,
  44909. colorSpace: cs,
  44910. numComps: fn ? 1 : cs.numComps
  44911. };
  44912. var reader = new MeshStreamReader(stream, decodeContext);
  44913. var patchMesh = false;
  44914. switch (this.shadingType) {
  44915. case ShadingType.FREE_FORM_MESH:
  44916. decodeType4Shading(this, reader);
  44917. break;
  44918. case ShadingType.LATTICE_FORM_MESH:
  44919. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  44920. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  44921. decodeType5Shading(this, reader, verticesPerRow);
  44922. break;
  44923. case ShadingType.COONS_PATCH_MESH:
  44924. decodeType6Shading(this, reader);
  44925. patchMesh = true;
  44926. break;
  44927. case ShadingType.TENSOR_PATCH_MESH:
  44928. decodeType7Shading(this, reader);
  44929. patchMesh = true;
  44930. break;
  44931. default:
  44932. error('Unsupported mesh type.');
  44933. break;
  44934. }
  44935. if (patchMesh) {
  44936. updateBounds(this);
  44937. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  44938. buildFigureFromPatch(this, i);
  44939. }
  44940. }
  44941. updateBounds(this);
  44942. packData(this);
  44943. }
  44944. Mesh.prototype = {
  44945. getIR: function Mesh_getIR() {
  44946. return [
  44947. 'Mesh',
  44948. this.shadingType,
  44949. this.coords,
  44950. this.colors,
  44951. this.figures,
  44952. this.bounds,
  44953. this.matrix,
  44954. this.bbox,
  44955. this.background
  44956. ];
  44957. }
  44958. };
  44959. return Mesh;
  44960. }();
  44961. Shadings.Dummy = function DummyClosure() {
  44962. function Dummy() {
  44963. this.type = 'Pattern';
  44964. }
  44965. Dummy.prototype = {
  44966. getIR: function Dummy_getIR() {
  44967. return ['Dummy'];
  44968. }
  44969. };
  44970. return Dummy;
  44971. }();
  44972. function getTilingPatternIR(operatorList, dict, args) {
  44973. var matrix = dict.getArray('Matrix');
  44974. var bbox = dict.getArray('BBox');
  44975. var xstep = dict.get('XStep');
  44976. var ystep = dict.get('YStep');
  44977. var paintType = dict.get('PaintType');
  44978. var tilingType = dict.get('TilingType');
  44979. return [
  44980. 'TilingPattern',
  44981. args,
  44982. operatorList,
  44983. matrix,
  44984. bbox,
  44985. xstep,
  44986. ystep,
  44987. paintType,
  44988. tilingType
  44989. ];
  44990. }
  44991. exports.Pattern = Pattern;
  44992. exports.getTilingPatternIR = getTilingPatternIR;
  44993. }));
  44994. (function (root, factory) {
  44995. 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);
  44996. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  44997. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  44998. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  44999. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  45000. var ImageKind = sharedUtil.ImageKind;
  45001. var OPS = sharedUtil.OPS;
  45002. var TextRenderingMode = sharedUtil.TextRenderingMode;
  45003. var Util = sharedUtil.Util;
  45004. var assert = sharedUtil.assert;
  45005. var createPromiseCapability = sharedUtil.createPromiseCapability;
  45006. var error = sharedUtil.error;
  45007. var info = sharedUtil.info;
  45008. var isArray = sharedUtil.isArray;
  45009. var isNum = sharedUtil.isNum;
  45010. var isString = sharedUtil.isString;
  45011. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  45012. var warn = sharedUtil.warn;
  45013. var Dict = corePrimitives.Dict;
  45014. var Name = corePrimitives.Name;
  45015. var isCmd = corePrimitives.isCmd;
  45016. var isDict = corePrimitives.isDict;
  45017. var isName = corePrimitives.isName;
  45018. var isRef = corePrimitives.isRef;
  45019. var isStream = corePrimitives.isStream;
  45020. var DecodeStream = coreStream.DecodeStream;
  45021. var JpegStream = coreStream.JpegStream;
  45022. var Stream = coreStream.Stream;
  45023. var Lexer = coreParser.Lexer;
  45024. var Parser = coreParser.Parser;
  45025. var isEOF = coreParser.isEOF;
  45026. var PDFImage = coreImage.PDFImage;
  45027. var ColorSpace = coreColorSpace.ColorSpace;
  45028. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  45029. var ErrorFont = coreFonts.ErrorFont;
  45030. var FontFlags = coreFonts.FontFlags;
  45031. var Font = coreFonts.Font;
  45032. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  45033. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  45034. var getFontType = coreFonts.getFontType;
  45035. var isPDFFunction = coreFunction.isPDFFunction;
  45036. var PDFFunction = coreFunction.PDFFunction;
  45037. var Pattern = corePattern.Pattern;
  45038. var getTilingPatternIR = corePattern.getTilingPatternIR;
  45039. var CMapFactory = coreCMap.CMapFactory;
  45040. var IdentityCMap = coreCMap.IdentityCMap;
  45041. var getMetrics = coreMetrics.getMetrics;
  45042. var bidi = coreBidi.bidi;
  45043. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  45044. var StandardEncoding = coreEncodings.StandardEncoding;
  45045. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  45046. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  45047. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  45048. var getEncoding = coreEncodings.getEncoding;
  45049. var getStdFontMap = coreStandardFonts.getStdFontMap;
  45050. var getSerifFonts = coreStandardFonts.getSerifFonts;
  45051. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  45052. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  45053. var reverseIfRtl = coreUnicode.reverseIfRtl;
  45054. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  45055. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  45056. var PartialEvaluator = function PartialEvaluatorClosure() {
  45057. var DefaultPartialEvaluatorOptions = {
  45058. forceDataSchema: false,
  45059. maxImageSize: -1,
  45060. disableFontFace: false,
  45061. cMapOptions: {
  45062. url: null,
  45063. packed: false
  45064. }
  45065. };
  45066. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  45067. this.xref = xref;
  45068. this.resources = resources;
  45069. this.handler = handler;
  45070. this.forceDataSchema = forceDataSchema;
  45071. }
  45072. NativeImageDecoder.prototype = {
  45073. canDecode: function (image) {
  45074. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  45075. },
  45076. decode: function (image) {
  45077. var dict = image.dict;
  45078. var colorSpace = dict.get('ColorSpace', 'CS');
  45079. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  45080. var numComps = colorSpace.numComps;
  45081. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  45082. image.getIR(this.forceDataSchema),
  45083. numComps
  45084. ]);
  45085. return decodePromise.then(function (message) {
  45086. var data = message.data;
  45087. return new Stream(data, 0, data.length, image.dict);
  45088. });
  45089. }
  45090. };
  45091. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  45092. var dict = image.dict;
  45093. if (dict.has('DecodeParms') || dict.has('DP')) {
  45094. return false;
  45095. }
  45096. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  45097. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  45098. };
  45099. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  45100. var dict = image.dict;
  45101. if (dict.has('DecodeParms') || dict.has('DP')) {
  45102. return false;
  45103. }
  45104. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  45105. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  45106. };
  45107. function PartialEvaluator(pdfManager, xref, handler, pageIndex, idFactory, fontCache, options) {
  45108. this.pdfManager = pdfManager;
  45109. this.xref = xref;
  45110. this.handler = handler;
  45111. this.pageIndex = pageIndex;
  45112. this.idFactory = idFactory;
  45113. this.fontCache = fontCache;
  45114. this.options = options || DefaultPartialEvaluatorOptions;
  45115. }
  45116. var TIME_SLOT_DURATION_MS = 20;
  45117. var CHECK_TIME_EVERY = 100;
  45118. function TimeSlotManager() {
  45119. this.reset();
  45120. }
  45121. TimeSlotManager.prototype = {
  45122. check: function TimeSlotManager_check() {
  45123. if (++this.checked < CHECK_TIME_EVERY) {
  45124. return false;
  45125. }
  45126. this.checked = 0;
  45127. return this.endTime <= Date.now();
  45128. },
  45129. reset: function TimeSlotManager_reset() {
  45130. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  45131. this.checked = 0;
  45132. }
  45133. };
  45134. var deferred = Promise.resolve();
  45135. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  45136. PartialEvaluator.prototype = {
  45137. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  45138. if (!isDict(resources)) {
  45139. return false;
  45140. }
  45141. var processed = Object.create(null);
  45142. if (resources.objId) {
  45143. processed[resources.objId] = true;
  45144. }
  45145. var nodes = [resources], xref = this.xref;
  45146. while (nodes.length) {
  45147. var key, i, ii;
  45148. var node = nodes.shift();
  45149. var graphicStates = node.get('ExtGState');
  45150. if (isDict(graphicStates)) {
  45151. var graphicStatesKeys = graphicStates.getKeys();
  45152. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  45153. key = graphicStatesKeys[i];
  45154. var graphicState = graphicStates.get(key);
  45155. var bm = graphicState.get('BM');
  45156. if (isName(bm) && bm.name !== 'Normal') {
  45157. return true;
  45158. }
  45159. }
  45160. }
  45161. var xObjects = node.get('XObject');
  45162. if (!isDict(xObjects)) {
  45163. continue;
  45164. }
  45165. var xObjectsKeys = xObjects.getKeys();
  45166. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  45167. key = xObjectsKeys[i];
  45168. var xObject = xObjects.getRaw(key);
  45169. if (isRef(xObject)) {
  45170. if (processed[xObject.toString()]) {
  45171. continue;
  45172. }
  45173. xObject = xref.fetch(xObject);
  45174. }
  45175. if (!isStream(xObject)) {
  45176. continue;
  45177. }
  45178. if (xObject.dict.objId) {
  45179. if (processed[xObject.dict.objId]) {
  45180. continue;
  45181. }
  45182. processed[xObject.dict.objId] = true;
  45183. }
  45184. var xResources = xObject.dict.get('Resources');
  45185. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  45186. nodes.push(xResources);
  45187. if (xResources.objId) {
  45188. processed[xResources.objId] = true;
  45189. }
  45190. }
  45191. }
  45192. }
  45193. return false;
  45194. },
  45195. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  45196. var matrix = xobj.dict.getArray('Matrix');
  45197. var bbox = xobj.dict.getArray('BBox');
  45198. var group = xobj.dict.get('Group');
  45199. if (group) {
  45200. var groupOptions = {
  45201. matrix: matrix,
  45202. bbox: bbox,
  45203. smask: smask,
  45204. isolated: false,
  45205. knockout: false
  45206. };
  45207. var groupSubtype = group.get('S');
  45208. var colorSpace;
  45209. if (isName(groupSubtype, 'Transparency')) {
  45210. groupOptions.isolated = group.get('I') || false;
  45211. groupOptions.knockout = group.get('K') || false;
  45212. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  45213. }
  45214. if (smask && smask.backdrop) {
  45215. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  45216. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  45217. }
  45218. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  45219. }
  45220. operatorList.addOp(OPS.paintFormXObjectBegin, [
  45221. matrix,
  45222. bbox
  45223. ]);
  45224. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  45225. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  45226. if (group) {
  45227. operatorList.addOp(OPS.endGroup, [groupOptions]);
  45228. }
  45229. });
  45230. },
  45231. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  45232. var self = this;
  45233. var dict = image.dict;
  45234. var w = dict.get('Width', 'W');
  45235. var h = dict.get('Height', 'H');
  45236. if (!(w && isNum(w)) || !(h && isNum(h))) {
  45237. warn('Image dimensions are missing, or not numbers.');
  45238. return;
  45239. }
  45240. var maxImageSize = this.options.maxImageSize;
  45241. if (maxImageSize !== -1 && w * h > maxImageSize) {
  45242. warn('Image exceeded maximum allowed size and was removed.');
  45243. return;
  45244. }
  45245. var imageMask = dict.get('ImageMask', 'IM') || false;
  45246. var imgData, args;
  45247. if (imageMask) {
  45248. var width = dict.get('Width', 'W');
  45249. var height = dict.get('Height', 'H');
  45250. var bitStrideLength = width + 7 >> 3;
  45251. var imgArray = image.getBytes(bitStrideLength * height);
  45252. var decode = dict.getArray('Decode', 'D');
  45253. var inverseDecode = !!decode && decode[0] > 0;
  45254. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  45255. imgData.cached = true;
  45256. args = [imgData];
  45257. operatorList.addOp(OPS.paintImageMaskXObject, args);
  45258. if (cacheKey) {
  45259. imageCache[cacheKey] = {
  45260. fn: OPS.paintImageMaskXObject,
  45261. args: args
  45262. };
  45263. }
  45264. return;
  45265. }
  45266. var softMask = dict.get('SMask', 'SM') || false;
  45267. var mask = dict.get('Mask') || false;
  45268. var SMALL_IMAGE_DIMENSIONS = 200;
  45269. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  45270. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  45271. imgData = imageObj.createImageData(true);
  45272. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  45273. return;
  45274. }
  45275. var objId = 'img_' + this.idFactory.createObjId();
  45276. operatorList.addDependency(objId);
  45277. args = [
  45278. objId,
  45279. w,
  45280. h
  45281. ];
  45282. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  45283. operatorList.addOp(OPS.paintJpegXObject, args);
  45284. this.handler.send('obj', [
  45285. objId,
  45286. this.pageIndex,
  45287. 'JpegStream',
  45288. image.getIR(this.options.forceDataSchema)
  45289. ]);
  45290. return;
  45291. }
  45292. var nativeImageDecoder = null;
  45293. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  45294. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  45295. }
  45296. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  45297. var imgData = imageObj.createImageData(false);
  45298. self.handler.send('obj', [
  45299. objId,
  45300. self.pageIndex,
  45301. 'Image',
  45302. imgData
  45303. ], [imgData.data.buffer]);
  45304. }).then(undefined, function (reason) {
  45305. warn('Unable to decode image: ' + reason);
  45306. self.handler.send('obj', [
  45307. objId,
  45308. self.pageIndex,
  45309. 'Image',
  45310. null
  45311. ]);
  45312. });
  45313. operatorList.addOp(OPS.paintImageXObject, args);
  45314. if (cacheKey) {
  45315. imageCache[cacheKey] = {
  45316. fn: OPS.paintImageXObject,
  45317. args: args
  45318. };
  45319. }
  45320. },
  45321. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  45322. var smaskContent = smask.get('G');
  45323. var smaskOptions = {
  45324. subtype: smask.get('S').name,
  45325. backdrop: smask.get('BC')
  45326. };
  45327. var transferObj = smask.get('TR');
  45328. if (isPDFFunction(transferObj)) {
  45329. var transferFn = PDFFunction.parse(this.xref, transferObj);
  45330. var transferMap = new Uint8Array(256);
  45331. var tmp = new Float32Array(1);
  45332. for (var i = 0; i < 256; i++) {
  45333. tmp[0] = i / 255;
  45334. transferFn(tmp, 0, tmp, 0);
  45335. transferMap[i] = tmp[0] * 255 | 0;
  45336. }
  45337. smaskOptions.transferMap = transferMap;
  45338. }
  45339. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  45340. },
  45341. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  45342. var tilingOpList = new OperatorList();
  45343. var resourcesArray = [
  45344. patternDict.get('Resources'),
  45345. resources
  45346. ];
  45347. var patternResources = Dict.merge(this.xref, resourcesArray);
  45348. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  45349. operatorList.addDependencies(tilingOpList.dependencies);
  45350. operatorList.addOp(fn, getTilingPatternIR({
  45351. fnArray: tilingOpList.fnArray,
  45352. argsArray: tilingOpList.argsArray
  45353. }, patternDict, args));
  45354. });
  45355. },
  45356. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  45357. var fontName;
  45358. if (fontArgs) {
  45359. fontArgs = fontArgs.slice();
  45360. fontName = fontArgs[0].name;
  45361. }
  45362. var self = this;
  45363. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  45364. if (!translated.font.isType3Font) {
  45365. return translated;
  45366. }
  45367. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  45368. return translated;
  45369. }, function (reason) {
  45370. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  45371. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  45372. });
  45373. }).then(function (translated) {
  45374. state.font = translated.font;
  45375. translated.send(self.handler);
  45376. return translated.loadedName;
  45377. });
  45378. },
  45379. handleText: function PartialEvaluator_handleText(chars, state) {
  45380. var font = state.font;
  45381. var glyphs = font.charsToGlyphs(chars);
  45382. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  45383. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  45384. var buildPath = function (fontChar) {
  45385. if (!font.renderer.hasBuiltPath(fontChar)) {
  45386. var path = font.renderer.getPathJs(fontChar);
  45387. this.handler.send('commonobj', [
  45388. font.loadedName + '_path_' + fontChar,
  45389. 'FontPath',
  45390. path
  45391. ]);
  45392. }
  45393. }.bind(this);
  45394. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  45395. var glyph = glyphs[i];
  45396. buildPath(glyph.fontChar);
  45397. var accent = glyph.accent;
  45398. if (accent && accent.fontChar) {
  45399. buildPath(accent.fontChar);
  45400. }
  45401. }
  45402. }
  45403. return glyphs;
  45404. },
  45405. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  45406. var gStateObj = [];
  45407. var gStateKeys = gState.getKeys();
  45408. var self = this;
  45409. var promise = Promise.resolve();
  45410. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  45411. var key = gStateKeys[i];
  45412. var value = gState.get(key);
  45413. switch (key) {
  45414. case 'Type':
  45415. break;
  45416. case 'LW':
  45417. case 'LC':
  45418. case 'LJ':
  45419. case 'ML':
  45420. case 'D':
  45421. case 'RI':
  45422. case 'FL':
  45423. case 'CA':
  45424. case 'ca':
  45425. gStateObj.push([
  45426. key,
  45427. value
  45428. ]);
  45429. break;
  45430. case 'Font':
  45431. promise = promise.then(function () {
  45432. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  45433. operatorList.addDependency(loadedName);
  45434. gStateObj.push([
  45435. key,
  45436. [
  45437. loadedName,
  45438. value[1]
  45439. ]
  45440. ]);
  45441. });
  45442. });
  45443. break;
  45444. case 'BM':
  45445. gStateObj.push([
  45446. key,
  45447. value
  45448. ]);
  45449. break;
  45450. case 'SMask':
  45451. if (isName(value, 'None')) {
  45452. gStateObj.push([
  45453. key,
  45454. false
  45455. ]);
  45456. break;
  45457. }
  45458. if (isDict(value)) {
  45459. promise = promise.then(function (dict) {
  45460. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  45461. }.bind(this, value));
  45462. gStateObj.push([
  45463. key,
  45464. true
  45465. ]);
  45466. } else {
  45467. warn('Unsupported SMask type');
  45468. }
  45469. break;
  45470. case 'OP':
  45471. case 'op':
  45472. case 'OPM':
  45473. case 'BG':
  45474. case 'BG2':
  45475. case 'UCR':
  45476. case 'UCR2':
  45477. case 'TR':
  45478. case 'TR2':
  45479. case 'HT':
  45480. case 'SM':
  45481. case 'SA':
  45482. case 'AIS':
  45483. case 'TK':
  45484. info('graphic state operator ' + key);
  45485. break;
  45486. default:
  45487. info('Unknown graphic state operator ' + key);
  45488. break;
  45489. }
  45490. }
  45491. return promise.then(function () {
  45492. if (gStateObj.length > 0) {
  45493. operatorList.addOp(OPS.setGState, [gStateObj]);
  45494. }
  45495. });
  45496. },
  45497. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  45498. function errorFont() {
  45499. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  45500. }
  45501. var fontRef;
  45502. if (font) {
  45503. assert(isRef(font));
  45504. fontRef = font;
  45505. } else {
  45506. var fontRes = resources.get('Font');
  45507. if (fontRes) {
  45508. fontRef = fontRes.getRaw(fontName);
  45509. } else {
  45510. warn('fontRes not available');
  45511. return errorFont();
  45512. }
  45513. }
  45514. if (!fontRef) {
  45515. warn('fontRef not available');
  45516. return errorFont();
  45517. }
  45518. if (this.fontCache.has(fontRef)) {
  45519. return this.fontCache.get(fontRef);
  45520. }
  45521. font = xref.fetchIfRef(fontRef);
  45522. if (!isDict(font)) {
  45523. return errorFont();
  45524. }
  45525. if (font.translated) {
  45526. return font.translated;
  45527. }
  45528. var fontCapability = createPromiseCapability();
  45529. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  45530. var descriptor = preEvaluatedFont.descriptor;
  45531. var fontRefIsRef = isRef(fontRef), fontID;
  45532. if (fontRefIsRef) {
  45533. fontID = fontRef.toString();
  45534. }
  45535. if (isDict(descriptor)) {
  45536. if (!descriptor.fontAliases) {
  45537. descriptor.fontAliases = Object.create(null);
  45538. }
  45539. var fontAliases = descriptor.fontAliases;
  45540. var hash = preEvaluatedFont.hash;
  45541. if (fontAliases[hash]) {
  45542. var aliasFontRef = fontAliases[hash].aliasRef;
  45543. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  45544. this.fontCache.putAlias(fontRef, aliasFontRef);
  45545. return this.fontCache.get(fontRef);
  45546. }
  45547. } else {
  45548. fontAliases[hash] = { fontID: Font.getFontID() };
  45549. }
  45550. if (fontRefIsRef) {
  45551. fontAliases[hash].aliasRef = fontRef;
  45552. }
  45553. fontID = fontAliases[hash].fontID;
  45554. }
  45555. if (fontRefIsRef) {
  45556. this.fontCache.put(fontRef, fontCapability.promise);
  45557. } else {
  45558. if (!fontID) {
  45559. fontID = this.idFactory.createObjId();
  45560. }
  45561. this.fontCache.put('id_' + fontID, fontCapability.promise);
  45562. }
  45563. assert(fontID, 'The "fontID" must be defined.');
  45564. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  45565. font.translated = fontCapability.promise;
  45566. var translatedPromise;
  45567. try {
  45568. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  45569. } catch (e) {
  45570. translatedPromise = Promise.reject(e);
  45571. }
  45572. var self = this;
  45573. translatedPromise.then(function (translatedFont) {
  45574. if (translatedFont.fontType !== undefined) {
  45575. var xrefFontStats = xref.stats.fontTypes;
  45576. xrefFontStats[translatedFont.fontType] = true;
  45577. }
  45578. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  45579. }, function (reason) {
  45580. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  45581. try {
  45582. var descriptor = preEvaluatedFont.descriptor;
  45583. var fontFile3 = descriptor && descriptor.get('FontFile3');
  45584. var subtype = fontFile3 && fontFile3.get('Subtype');
  45585. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  45586. var xrefFontStats = xref.stats.fontTypes;
  45587. xrefFontStats[fontType] = true;
  45588. } catch (ex) {
  45589. }
  45590. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  45591. });
  45592. return fontCapability.promise;
  45593. },
  45594. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  45595. var lastIndex = operatorList.length - 1;
  45596. if (!args) {
  45597. args = [];
  45598. }
  45599. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  45600. operatorList.addOp(OPS.constructPath, [
  45601. [fn],
  45602. args
  45603. ]);
  45604. } else {
  45605. var opArgs = operatorList.argsArray[lastIndex];
  45606. opArgs[0].push(fn);
  45607. Array.prototype.push.apply(opArgs[1], args);
  45608. }
  45609. },
  45610. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  45611. var patternName = args[args.length - 1];
  45612. var pattern;
  45613. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  45614. var dict = isStream(pattern) ? pattern.dict : pattern;
  45615. var typeNum = dict.get('PatternType');
  45616. if (typeNum === TILING_PATTERN) {
  45617. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  45618. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  45619. } else if (typeNum === SHADING_PATTERN) {
  45620. var shading = dict.get('Shading');
  45621. var matrix = dict.getArray('Matrix');
  45622. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  45623. operatorList.addOp(fn, pattern.getIR());
  45624. return Promise.resolve();
  45625. }
  45626. return Promise.reject('Unknown PatternType: ' + typeNum);
  45627. }
  45628. operatorList.addOp(fn, args);
  45629. return Promise.resolve();
  45630. },
  45631. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  45632. var self = this;
  45633. var xref = this.xref;
  45634. var imageCache = Object.create(null);
  45635. assert(operatorList);
  45636. resources = resources || Dict.empty;
  45637. var xobjs = resources.get('XObject') || Dict.empty;
  45638. var patterns = resources.get('Pattern') || Dict.empty;
  45639. var stateManager = new StateManager(initialState || new EvalState());
  45640. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  45641. var timeSlotManager = new TimeSlotManager();
  45642. return new Promise(function promiseBody(resolve, reject) {
  45643. var next = function (promise) {
  45644. promise.then(function () {
  45645. try {
  45646. promiseBody(resolve, reject);
  45647. } catch (ex) {
  45648. reject(ex);
  45649. }
  45650. }, reject);
  45651. };
  45652. task.ensureNotTerminated();
  45653. timeSlotManager.reset();
  45654. var stop, operation = {}, i, ii, cs;
  45655. while (!(stop = timeSlotManager.check())) {
  45656. operation.args = null;
  45657. if (!preprocessor.read(operation)) {
  45658. break;
  45659. }
  45660. var args = operation.args;
  45661. var fn = operation.fn;
  45662. switch (fn | 0) {
  45663. case OPS.paintXObject:
  45664. if (args[0].code) {
  45665. break;
  45666. }
  45667. var name = args[0].name;
  45668. if (!name) {
  45669. warn('XObject must be referred to by name.');
  45670. continue;
  45671. }
  45672. if (imageCache[name] !== undefined) {
  45673. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  45674. args = null;
  45675. continue;
  45676. }
  45677. var xobj = xobjs.get(name);
  45678. if (xobj) {
  45679. assert(isStream(xobj), 'XObject should be a stream');
  45680. var type = xobj.dict.get('Subtype');
  45681. assert(isName(type), 'XObject should have a Name subtype');
  45682. if (type.name === 'Form') {
  45683. stateManager.save();
  45684. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  45685. stateManager.restore();
  45686. }));
  45687. return;
  45688. } else if (type.name === 'Image') {
  45689. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  45690. args = null;
  45691. continue;
  45692. } else if (type.name === 'PS') {
  45693. info('Ignored XObject subtype PS');
  45694. continue;
  45695. } else {
  45696. error('Unhandled XObject subtype ' + type.name);
  45697. }
  45698. }
  45699. break;
  45700. case OPS.setFont:
  45701. var fontSize = args[1];
  45702. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  45703. operatorList.addDependency(loadedName);
  45704. operatorList.addOp(OPS.setFont, [
  45705. loadedName,
  45706. fontSize
  45707. ]);
  45708. }));
  45709. return;
  45710. case OPS.endInlineImage:
  45711. var cacheKey = args[0].cacheKey;
  45712. if (cacheKey) {
  45713. var cacheEntry = imageCache[cacheKey];
  45714. if (cacheEntry !== undefined) {
  45715. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  45716. args = null;
  45717. continue;
  45718. }
  45719. }
  45720. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  45721. args = null;
  45722. continue;
  45723. case OPS.showText:
  45724. args[0] = self.handleText(args[0], stateManager.state);
  45725. break;
  45726. case OPS.showSpacedText:
  45727. var arr = args[0];
  45728. var combinedGlyphs = [];
  45729. var arrLength = arr.length;
  45730. var state = stateManager.state;
  45731. for (i = 0; i < arrLength; ++i) {
  45732. var arrItem = arr[i];
  45733. if (isString(arrItem)) {
  45734. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  45735. } else if (isNum(arrItem)) {
  45736. combinedGlyphs.push(arrItem);
  45737. }
  45738. }
  45739. args[0] = combinedGlyphs;
  45740. fn = OPS.showText;
  45741. break;
  45742. case OPS.nextLineShowText:
  45743. operatorList.addOp(OPS.nextLine);
  45744. args[0] = self.handleText(args[0], stateManager.state);
  45745. fn = OPS.showText;
  45746. break;
  45747. case OPS.nextLineSetSpacingShowText:
  45748. operatorList.addOp(OPS.nextLine);
  45749. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  45750. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  45751. args[0] = self.handleText(args[0], stateManager.state);
  45752. fn = OPS.showText;
  45753. break;
  45754. case OPS.setTextRenderingMode:
  45755. stateManager.state.textRenderingMode = args[0];
  45756. break;
  45757. case OPS.setFillColorSpace:
  45758. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  45759. continue;
  45760. case OPS.setStrokeColorSpace:
  45761. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  45762. continue;
  45763. case OPS.setFillColor:
  45764. cs = stateManager.state.fillColorSpace;
  45765. args = cs.getRgb(args, 0);
  45766. fn = OPS.setFillRGBColor;
  45767. break;
  45768. case OPS.setStrokeColor:
  45769. cs = stateManager.state.strokeColorSpace;
  45770. args = cs.getRgb(args, 0);
  45771. fn = OPS.setStrokeRGBColor;
  45772. break;
  45773. case OPS.setFillGray:
  45774. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  45775. args = ColorSpace.singletons.gray.getRgb(args, 0);
  45776. fn = OPS.setFillRGBColor;
  45777. break;
  45778. case OPS.setStrokeGray:
  45779. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  45780. args = ColorSpace.singletons.gray.getRgb(args, 0);
  45781. fn = OPS.setStrokeRGBColor;
  45782. break;
  45783. case OPS.setFillCMYKColor:
  45784. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  45785. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  45786. fn = OPS.setFillRGBColor;
  45787. break;
  45788. case OPS.setStrokeCMYKColor:
  45789. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  45790. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  45791. fn = OPS.setStrokeRGBColor;
  45792. break;
  45793. case OPS.setFillRGBColor:
  45794. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  45795. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  45796. break;
  45797. case OPS.setStrokeRGBColor:
  45798. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  45799. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  45800. break;
  45801. case OPS.setFillColorN:
  45802. cs = stateManager.state.fillColorSpace;
  45803. if (cs.name === 'Pattern') {
  45804. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  45805. return;
  45806. }
  45807. args = cs.getRgb(args, 0);
  45808. fn = OPS.setFillRGBColor;
  45809. break;
  45810. case OPS.setStrokeColorN:
  45811. cs = stateManager.state.strokeColorSpace;
  45812. if (cs.name === 'Pattern') {
  45813. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  45814. return;
  45815. }
  45816. args = cs.getRgb(args, 0);
  45817. fn = OPS.setStrokeRGBColor;
  45818. break;
  45819. case OPS.shadingFill:
  45820. var shadingRes = resources.get('Shading');
  45821. if (!shadingRes) {
  45822. error('No shading resource found');
  45823. }
  45824. var shading = shadingRes.get(args[0].name);
  45825. if (!shading) {
  45826. error('No shading object found');
  45827. }
  45828. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  45829. var patternIR = shadingFill.getIR();
  45830. args = [patternIR];
  45831. fn = OPS.shadingFill;
  45832. break;
  45833. case OPS.setGState:
  45834. var dictName = args[0];
  45835. var extGState = resources.get('ExtGState');
  45836. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  45837. break;
  45838. }
  45839. var gState = extGState.get(dictName.name);
  45840. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  45841. return;
  45842. case OPS.moveTo:
  45843. case OPS.lineTo:
  45844. case OPS.curveTo:
  45845. case OPS.curveTo2:
  45846. case OPS.curveTo3:
  45847. case OPS.closePath:
  45848. self.buildPath(operatorList, fn, args);
  45849. continue;
  45850. case OPS.rectangle:
  45851. self.buildPath(operatorList, fn, args);
  45852. continue;
  45853. case OPS.markPoint:
  45854. case OPS.markPointProps:
  45855. case OPS.beginMarkedContent:
  45856. case OPS.beginMarkedContentProps:
  45857. case OPS.endMarkedContent:
  45858. case OPS.beginCompat:
  45859. case OPS.endCompat:
  45860. continue;
  45861. default:
  45862. if (args !== null) {
  45863. for (i = 0, ii = args.length; i < ii; i++) {
  45864. if (args[i] instanceof Dict) {
  45865. break;
  45866. }
  45867. }
  45868. if (i < ii) {
  45869. warn('getOperatorList - ignoring operator: ' + fn);
  45870. continue;
  45871. }
  45872. }
  45873. }
  45874. operatorList.addOp(fn, args);
  45875. }
  45876. if (stop) {
  45877. next(deferred);
  45878. return;
  45879. }
  45880. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  45881. operatorList.addOp(OPS.restore, []);
  45882. }
  45883. resolve();
  45884. });
  45885. },
  45886. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  45887. stateManager = stateManager || new StateManager(new TextState());
  45888. var WhitespaceRegexp = /\s/g;
  45889. var textContent = {
  45890. items: [],
  45891. styles: Object.create(null)
  45892. };
  45893. var textContentItem = {
  45894. initialized: false,
  45895. str: [],
  45896. width: 0,
  45897. height: 0,
  45898. vertical: false,
  45899. lastAdvanceWidth: 0,
  45900. lastAdvanceHeight: 0,
  45901. textAdvanceScale: 0,
  45902. spaceWidth: 0,
  45903. fakeSpaceMin: Infinity,
  45904. fakeMultiSpaceMin: Infinity,
  45905. fakeMultiSpaceMax: -0,
  45906. textRunBreakAllowed: false,
  45907. transform: null,
  45908. fontName: null
  45909. };
  45910. var SPACE_FACTOR = 0.3;
  45911. var MULTI_SPACE_FACTOR = 1.5;
  45912. var MULTI_SPACE_FACTOR_MAX = 4;
  45913. var self = this;
  45914. var xref = this.xref;
  45915. resources = xref.fetchIfRef(resources) || Dict.empty;
  45916. var xobjs = null;
  45917. var xobjsCache = Object.create(null);
  45918. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  45919. var textState;
  45920. function ensureTextContentItem() {
  45921. if (textContentItem.initialized) {
  45922. return textContentItem;
  45923. }
  45924. var font = textState.font;
  45925. if (!(font.loadedName in textContent.styles)) {
  45926. textContent.styles[font.loadedName] = {
  45927. fontFamily: font.fallbackName,
  45928. ascent: font.ascent,
  45929. descent: font.descent,
  45930. vertical: font.vertical
  45931. };
  45932. }
  45933. textContentItem.fontName = font.loadedName;
  45934. var tsm = [
  45935. textState.fontSize * textState.textHScale,
  45936. 0,
  45937. 0,
  45938. textState.fontSize,
  45939. 0,
  45940. textState.textRise
  45941. ];
  45942. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  45943. var glyphHeight = font.bbox[3] - font.bbox[1];
  45944. if (glyphHeight > 0) {
  45945. glyphHeight = glyphHeight * textState.fontMatrix[3];
  45946. tsm[3] *= glyphHeight;
  45947. }
  45948. }
  45949. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  45950. textContentItem.transform = trm;
  45951. if (!font.vertical) {
  45952. textContentItem.width = 0;
  45953. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  45954. textContentItem.vertical = false;
  45955. } else {
  45956. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  45957. textContentItem.height = 0;
  45958. textContentItem.vertical = true;
  45959. }
  45960. var a = textState.textLineMatrix[0];
  45961. var b = textState.textLineMatrix[1];
  45962. var scaleLineX = Math.sqrt(a * a + b * b);
  45963. a = textState.ctm[0];
  45964. b = textState.ctm[1];
  45965. var scaleCtmX = Math.sqrt(a * a + b * b);
  45966. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  45967. textContentItem.lastAdvanceWidth = 0;
  45968. textContentItem.lastAdvanceHeight = 0;
  45969. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  45970. if (spaceWidth) {
  45971. textContentItem.spaceWidth = spaceWidth;
  45972. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  45973. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  45974. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  45975. textContentItem.textRunBreakAllowed = !font.isMonospace;
  45976. } else {
  45977. textContentItem.spaceWidth = 0;
  45978. textContentItem.fakeSpaceMin = Infinity;
  45979. textContentItem.fakeMultiSpaceMin = Infinity;
  45980. textContentItem.fakeMultiSpaceMax = 0;
  45981. textContentItem.textRunBreakAllowed = false;
  45982. }
  45983. textContentItem.initialized = true;
  45984. return textContentItem;
  45985. }
  45986. function replaceWhitespace(str) {
  45987. var i = 0, ii = str.length, code;
  45988. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  45989. i++;
  45990. }
  45991. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  45992. }
  45993. function runBidiTransform(textChunk) {
  45994. var str = textChunk.str.join('');
  45995. var bidiResult = bidi(str, -1, textChunk.vertical);
  45996. return {
  45997. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  45998. dir: bidiResult.dir,
  45999. width: textChunk.width,
  46000. height: textChunk.height,
  46001. transform: textChunk.transform,
  46002. fontName: textChunk.fontName
  46003. };
  46004. }
  46005. function handleSetFont(fontName, fontRef) {
  46006. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  46007. textState.font = translated.font;
  46008. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  46009. });
  46010. }
  46011. function buildTextContentItem(chars) {
  46012. var font = textState.font;
  46013. var textChunk = ensureTextContentItem();
  46014. var width = 0;
  46015. var height = 0;
  46016. var glyphs = font.charsToGlyphs(chars);
  46017. var defaultVMetrics = font.defaultVMetrics;
  46018. for (var i = 0; i < glyphs.length; i++) {
  46019. var glyph = glyphs[i];
  46020. var vMetricX = null;
  46021. var vMetricY = null;
  46022. var glyphWidth = null;
  46023. if (font.vertical) {
  46024. if (glyph.vmetric) {
  46025. glyphWidth = glyph.vmetric[0];
  46026. vMetricX = glyph.vmetric[1];
  46027. vMetricY = glyph.vmetric[2];
  46028. } else {
  46029. glyphWidth = glyph.width;
  46030. vMetricX = glyph.width * 0.5;
  46031. vMetricY = defaultVMetrics[2];
  46032. }
  46033. } else {
  46034. glyphWidth = glyph.width;
  46035. }
  46036. var glyphUnicode = glyph.unicode;
  46037. var NormalizedUnicodes = getNormalizedUnicodes();
  46038. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  46039. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  46040. }
  46041. glyphUnicode = reverseIfRtl(glyphUnicode);
  46042. var charSpacing = textState.charSpacing;
  46043. if (glyph.isSpace) {
  46044. var wordSpacing = textState.wordSpacing;
  46045. charSpacing += wordSpacing;
  46046. if (wordSpacing > 0) {
  46047. addFakeSpaces(wordSpacing, textChunk.str);
  46048. }
  46049. }
  46050. var tx = 0;
  46051. var ty = 0;
  46052. if (!font.vertical) {
  46053. var w0 = glyphWidth * textState.fontMatrix[0];
  46054. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  46055. width += tx;
  46056. } else {
  46057. var w1 = glyphWidth * textState.fontMatrix[0];
  46058. ty = w1 * textState.fontSize + charSpacing;
  46059. height += ty;
  46060. }
  46061. textState.translateTextMatrix(tx, ty);
  46062. textChunk.str.push(glyphUnicode);
  46063. }
  46064. if (!font.vertical) {
  46065. textChunk.lastAdvanceWidth = width;
  46066. textChunk.width += width;
  46067. } else {
  46068. textChunk.lastAdvanceHeight = height;
  46069. textChunk.height += Math.abs(height);
  46070. }
  46071. return textChunk;
  46072. }
  46073. function addFakeSpaces(width, strBuf) {
  46074. if (width < textContentItem.fakeSpaceMin) {
  46075. return;
  46076. }
  46077. if (width < textContentItem.fakeMultiSpaceMin) {
  46078. strBuf.push(' ');
  46079. return;
  46080. }
  46081. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  46082. while (fakeSpaces-- > 0) {
  46083. strBuf.push(' ');
  46084. }
  46085. }
  46086. function flushTextContentItem() {
  46087. if (!textContentItem.initialized) {
  46088. return;
  46089. }
  46090. textContentItem.width *= textContentItem.textAdvanceScale;
  46091. textContentItem.height *= textContentItem.textAdvanceScale;
  46092. textContent.items.push(runBidiTransform(textContentItem));
  46093. textContentItem.initialized = false;
  46094. textContentItem.str.length = 0;
  46095. }
  46096. var timeSlotManager = new TimeSlotManager();
  46097. return new Promise(function promiseBody(resolve, reject) {
  46098. var next = function (promise) {
  46099. promise.then(function () {
  46100. try {
  46101. promiseBody(resolve, reject);
  46102. } catch (ex) {
  46103. reject(ex);
  46104. }
  46105. }, reject);
  46106. };
  46107. task.ensureNotTerminated();
  46108. timeSlotManager.reset();
  46109. var stop, operation = {}, args = [];
  46110. while (!(stop = timeSlotManager.check())) {
  46111. args.length = 0;
  46112. operation.args = args;
  46113. if (!preprocessor.read(operation)) {
  46114. break;
  46115. }
  46116. textState = stateManager.state;
  46117. var fn = operation.fn;
  46118. args = operation.args;
  46119. var advance, diff;
  46120. switch (fn | 0) {
  46121. case OPS.setFont:
  46122. var fontNameArg = args[0].name, fontSizeArg = args[1];
  46123. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  46124. break;
  46125. }
  46126. flushTextContentItem();
  46127. textState.fontName = fontNameArg;
  46128. textState.fontSize = fontSizeArg;
  46129. next(handleSetFont(fontNameArg, null));
  46130. return;
  46131. case OPS.setTextRise:
  46132. flushTextContentItem();
  46133. textState.textRise = args[0];
  46134. break;
  46135. case OPS.setHScale:
  46136. flushTextContentItem();
  46137. textState.textHScale = args[0] / 100;
  46138. break;
  46139. case OPS.setLeading:
  46140. flushTextContentItem();
  46141. textState.leading = args[0];
  46142. break;
  46143. case OPS.moveText:
  46144. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  46145. advance = args[0] - args[1];
  46146. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  46147. textState.translateTextLineMatrix(args[0], args[1]);
  46148. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  46149. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  46150. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  46151. addFakeSpaces(diff, textContentItem.str);
  46152. break;
  46153. }
  46154. flushTextContentItem();
  46155. textState.translateTextLineMatrix(args[0], args[1]);
  46156. textState.textMatrix = textState.textLineMatrix.slice();
  46157. break;
  46158. case OPS.setLeadingMoveText:
  46159. flushTextContentItem();
  46160. textState.leading = -args[1];
  46161. textState.translateTextLineMatrix(args[0], args[1]);
  46162. textState.textMatrix = textState.textLineMatrix.slice();
  46163. break;
  46164. case OPS.nextLine:
  46165. flushTextContentItem();
  46166. textState.carriageReturn();
  46167. break;
  46168. case OPS.setTextMatrix:
  46169. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  46170. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  46171. textState.translateTextLineMatrix(advance.width, advance.height);
  46172. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  46173. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  46174. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  46175. addFakeSpaces(diff, textContentItem.str);
  46176. break;
  46177. }
  46178. flushTextContentItem();
  46179. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  46180. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  46181. break;
  46182. case OPS.setCharSpacing:
  46183. textState.charSpacing = args[0];
  46184. break;
  46185. case OPS.setWordSpacing:
  46186. textState.wordSpacing = args[0];
  46187. break;
  46188. case OPS.beginText:
  46189. flushTextContentItem();
  46190. textState.textMatrix = IDENTITY_MATRIX.slice();
  46191. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  46192. break;
  46193. case OPS.showSpacedText:
  46194. var items = args[0];
  46195. var offset;
  46196. for (var j = 0, jj = items.length; j < jj; j++) {
  46197. if (typeof items[j] === 'string') {
  46198. buildTextContentItem(items[j]);
  46199. } else if (isNum(items[j])) {
  46200. ensureTextContentItem();
  46201. advance = items[j] * textState.fontSize / 1000;
  46202. var breakTextRun = false;
  46203. if (textState.font.vertical) {
  46204. offset = advance;
  46205. textState.translateTextMatrix(0, offset);
  46206. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  46207. if (!breakTextRun) {
  46208. textContentItem.height += offset;
  46209. }
  46210. } else {
  46211. advance = -advance;
  46212. offset = advance * textState.textHScale;
  46213. textState.translateTextMatrix(offset, 0);
  46214. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  46215. if (!breakTextRun) {
  46216. textContentItem.width += offset;
  46217. }
  46218. }
  46219. if (breakTextRun) {
  46220. flushTextContentItem();
  46221. } else if (advance > 0) {
  46222. addFakeSpaces(advance, textContentItem.str);
  46223. }
  46224. }
  46225. }
  46226. break;
  46227. case OPS.showText:
  46228. buildTextContentItem(args[0]);
  46229. break;
  46230. case OPS.nextLineShowText:
  46231. flushTextContentItem();
  46232. textState.carriageReturn();
  46233. buildTextContentItem(args[0]);
  46234. break;
  46235. case OPS.nextLineSetSpacingShowText:
  46236. flushTextContentItem();
  46237. textState.wordSpacing = args[0];
  46238. textState.charSpacing = args[1];
  46239. textState.carriageReturn();
  46240. buildTextContentItem(args[2]);
  46241. break;
  46242. case OPS.paintXObject:
  46243. flushTextContentItem();
  46244. if (args[0].code) {
  46245. break;
  46246. }
  46247. if (!xobjs) {
  46248. xobjs = resources.get('XObject') || Dict.empty;
  46249. }
  46250. var name = args[0].name;
  46251. if (xobjsCache.key === name) {
  46252. if (xobjsCache.texts) {
  46253. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  46254. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  46255. }
  46256. break;
  46257. }
  46258. var xobj = xobjs.get(name);
  46259. if (!xobj) {
  46260. break;
  46261. }
  46262. assert(isStream(xobj), 'XObject should be a stream');
  46263. var type = xobj.dict.get('Subtype');
  46264. assert(isName(type), 'XObject should have a Name subtype');
  46265. if ('Form' !== type.name) {
  46266. xobjsCache.key = name;
  46267. xobjsCache.texts = null;
  46268. break;
  46269. }
  46270. stateManager.save();
  46271. var matrix = xobj.dict.getArray('Matrix');
  46272. if (isArray(matrix) && matrix.length === 6) {
  46273. stateManager.transform(matrix);
  46274. }
  46275. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  46276. Util.appendToArray(textContent.items, formTextContent.items);
  46277. Util.extendObj(textContent.styles, formTextContent.styles);
  46278. stateManager.restore();
  46279. xobjsCache.key = name;
  46280. xobjsCache.texts = formTextContent;
  46281. }));
  46282. return;
  46283. case OPS.setGState:
  46284. flushTextContentItem();
  46285. var dictName = args[0];
  46286. var extGState = resources.get('ExtGState');
  46287. if (!isDict(extGState) || !isName(dictName)) {
  46288. break;
  46289. }
  46290. var gState = extGState.get(dictName.name);
  46291. if (!isDict(gState)) {
  46292. break;
  46293. }
  46294. var gStateFont = gState.get('Font');
  46295. if (gStateFont) {
  46296. textState.fontName = null;
  46297. textState.fontSize = gStateFont[1];
  46298. next(handleSetFont(null, gStateFont[0]));
  46299. return;
  46300. }
  46301. break;
  46302. }
  46303. }
  46304. if (stop) {
  46305. next(deferred);
  46306. return;
  46307. }
  46308. flushTextContentItem();
  46309. resolve(textContent);
  46310. });
  46311. },
  46312. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  46313. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  46314. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  46315. if (properties.composite) {
  46316. var cidSystemInfo = dict.get('CIDSystemInfo');
  46317. if (isDict(cidSystemInfo)) {
  46318. properties.cidSystemInfo = {
  46319. registry: cidSystemInfo.get('Registry'),
  46320. ordering: cidSystemInfo.get('Ordering'),
  46321. supplement: cidSystemInfo.get('Supplement')
  46322. };
  46323. }
  46324. var cidToGidMap = dict.get('CIDToGIDMap');
  46325. if (isStream(cidToGidMap)) {
  46326. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  46327. }
  46328. }
  46329. var differences = [];
  46330. var baseEncodingName = null;
  46331. var encoding;
  46332. if (dict.has('Encoding')) {
  46333. encoding = dict.get('Encoding');
  46334. if (isDict(encoding)) {
  46335. baseEncodingName = encoding.get('BaseEncoding');
  46336. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  46337. if (encoding.has('Differences')) {
  46338. var diffEncoding = encoding.get('Differences');
  46339. var index = 0;
  46340. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  46341. var data = xref.fetchIfRef(diffEncoding[j]);
  46342. if (isNum(data)) {
  46343. index = data;
  46344. } else if (isName(data)) {
  46345. differences[index++] = data.name;
  46346. } else {
  46347. error('Invalid entry in \'Differences\' array: ' + data);
  46348. }
  46349. }
  46350. }
  46351. } else if (isName(encoding)) {
  46352. baseEncodingName = encoding.name;
  46353. } else {
  46354. error('Encoding is not a Name nor a Dict');
  46355. }
  46356. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  46357. baseEncodingName = null;
  46358. }
  46359. }
  46360. if (baseEncodingName) {
  46361. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  46362. } else {
  46363. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  46364. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  46365. encoding = StandardEncoding;
  46366. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  46367. encoding = WinAnsiEncoding;
  46368. }
  46369. if (isSymbolicFont) {
  46370. encoding = MacRomanEncoding;
  46371. if (!properties.file) {
  46372. if (/Symbol/i.test(properties.name)) {
  46373. encoding = SymbolSetEncoding;
  46374. } else if (/Dingbats/i.test(properties.name)) {
  46375. encoding = ZapfDingbatsEncoding;
  46376. }
  46377. }
  46378. }
  46379. properties.defaultEncoding = encoding;
  46380. }
  46381. properties.differences = differences;
  46382. properties.baseEncodingName = baseEncodingName;
  46383. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  46384. properties.dict = dict;
  46385. return toUnicodePromise.then(function (toUnicode) {
  46386. properties.toUnicode = toUnicode;
  46387. return this.buildToUnicode(properties);
  46388. }.bind(this)).then(function (toUnicode) {
  46389. properties.toUnicode = toUnicode;
  46390. return properties;
  46391. });
  46392. },
  46393. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  46394. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  46395. if (properties.hasIncludedToUnicodeMap) {
  46396. return Promise.resolve(properties.toUnicode);
  46397. }
  46398. var toUnicode, charcode, glyphName;
  46399. if (!properties.composite)
  46400. {
  46401. toUnicode = [];
  46402. var encoding = properties.defaultEncoding.slice();
  46403. var baseEncodingName = properties.baseEncodingName;
  46404. var differences = properties.differences;
  46405. for (charcode in differences) {
  46406. glyphName = differences[charcode];
  46407. if (glyphName === '.notdef') {
  46408. continue;
  46409. }
  46410. encoding[charcode] = glyphName;
  46411. }
  46412. var glyphsUnicodeMap = getGlyphsUnicode();
  46413. for (charcode in encoding) {
  46414. glyphName = encoding[charcode];
  46415. if (glyphName === '') {
  46416. continue;
  46417. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  46418. var code = 0;
  46419. switch (glyphName[0]) {
  46420. case 'G':
  46421. if (glyphName.length === 3) {
  46422. code = parseInt(glyphName.substr(1), 16);
  46423. }
  46424. break;
  46425. case 'g':
  46426. if (glyphName.length === 5) {
  46427. code = parseInt(glyphName.substr(1), 16);
  46428. }
  46429. break;
  46430. case 'C':
  46431. case 'c':
  46432. if (glyphName.length >= 3) {
  46433. code = +glyphName.substr(1);
  46434. }
  46435. break;
  46436. default:
  46437. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  46438. if (unicode !== -1) {
  46439. code = unicode;
  46440. }
  46441. }
  46442. if (code) {
  46443. if (baseEncodingName && code === +charcode) {
  46444. var baseEncoding = getEncoding(baseEncodingName);
  46445. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  46446. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  46447. continue;
  46448. }
  46449. }
  46450. toUnicode[charcode] = String.fromCharCode(code);
  46451. }
  46452. continue;
  46453. }
  46454. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  46455. }
  46456. return Promise.resolve(new ToUnicodeMap(toUnicode));
  46457. }
  46458. 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'))) {
  46459. var registry = properties.cidSystemInfo.registry;
  46460. var ordering = properties.cidSystemInfo.ordering;
  46461. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  46462. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  46463. var cMap = properties.cMap;
  46464. toUnicode = [];
  46465. cMap.forEach(function (charcode, cid) {
  46466. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  46467. var ucs2 = ucs2CMap.lookup(cid);
  46468. if (ucs2) {
  46469. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  46470. }
  46471. });
  46472. return new ToUnicodeMap(toUnicode);
  46473. });
  46474. }
  46475. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  46476. },
  46477. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  46478. var cmapObj = toUnicode;
  46479. if (isName(cmapObj)) {
  46480. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  46481. if (cmap instanceof IdentityCMap) {
  46482. return new IdentityToUnicodeMap(0, 0xFFFF);
  46483. }
  46484. return new ToUnicodeMap(cmap.getMap());
  46485. });
  46486. } else if (isStream(cmapObj)) {
  46487. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  46488. if (cmap instanceof IdentityCMap) {
  46489. return new IdentityToUnicodeMap(0, 0xFFFF);
  46490. }
  46491. var map = new Array(cmap.length);
  46492. cmap.forEach(function (charCode, token) {
  46493. var str = [];
  46494. for (var k = 0; k < token.length; k += 2) {
  46495. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  46496. if ((w1 & 0xF800) !== 0xD800) {
  46497. str.push(w1);
  46498. continue;
  46499. }
  46500. k += 2;
  46501. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  46502. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  46503. }
  46504. map[charCode] = String.fromCharCode.apply(String, str);
  46505. });
  46506. return new ToUnicodeMap(map);
  46507. });
  46508. }
  46509. return Promise.resolve(null);
  46510. },
  46511. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  46512. var glyphsData = cidToGidStream.getBytes();
  46513. var result = [];
  46514. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  46515. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  46516. if (glyphID === 0) {
  46517. continue;
  46518. }
  46519. var code = j >> 1;
  46520. result[code] = glyphID;
  46521. }
  46522. return result;
  46523. },
  46524. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  46525. var glyphsWidths = [];
  46526. var defaultWidth = 0;
  46527. var glyphsVMetrics = [];
  46528. var defaultVMetrics;
  46529. var i, ii, j, jj, start, code, widths;
  46530. if (properties.composite) {
  46531. defaultWidth = dict.get('DW') || 1000;
  46532. widths = dict.get('W');
  46533. if (widths) {
  46534. for (i = 0, ii = widths.length; i < ii; i++) {
  46535. start = xref.fetchIfRef(widths[i++]);
  46536. code = xref.fetchIfRef(widths[i]);
  46537. if (isArray(code)) {
  46538. for (j = 0, jj = code.length; j < jj; j++) {
  46539. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  46540. }
  46541. } else {
  46542. var width = xref.fetchIfRef(widths[++i]);
  46543. for (j = start; j <= code; j++) {
  46544. glyphsWidths[j] = width;
  46545. }
  46546. }
  46547. }
  46548. }
  46549. if (properties.vertical) {
  46550. var vmetrics = dict.getArray('DW2') || [
  46551. 880,
  46552. -1000
  46553. ];
  46554. defaultVMetrics = [
  46555. vmetrics[1],
  46556. defaultWidth * 0.5,
  46557. vmetrics[0]
  46558. ];
  46559. vmetrics = dict.get('W2');
  46560. if (vmetrics) {
  46561. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  46562. start = xref.fetchIfRef(vmetrics[i++]);
  46563. code = xref.fetchIfRef(vmetrics[i]);
  46564. if (isArray(code)) {
  46565. for (j = 0, jj = code.length; j < jj; j++) {
  46566. glyphsVMetrics[start++] = [
  46567. xref.fetchIfRef(code[j++]),
  46568. xref.fetchIfRef(code[j++]),
  46569. xref.fetchIfRef(code[j])
  46570. ];
  46571. }
  46572. } else {
  46573. var vmetric = [
  46574. xref.fetchIfRef(vmetrics[++i]),
  46575. xref.fetchIfRef(vmetrics[++i]),
  46576. xref.fetchIfRef(vmetrics[++i])
  46577. ];
  46578. for (j = start; j <= code; j++) {
  46579. glyphsVMetrics[j] = vmetric;
  46580. }
  46581. }
  46582. }
  46583. }
  46584. }
  46585. } else {
  46586. var firstChar = properties.firstChar;
  46587. widths = dict.get('Widths');
  46588. if (widths) {
  46589. j = firstChar;
  46590. for (i = 0, ii = widths.length; i < ii; i++) {
  46591. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  46592. }
  46593. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  46594. } else {
  46595. var baseFontName = dict.get('BaseFont');
  46596. if (isName(baseFontName)) {
  46597. var metrics = this.getBaseFontMetrics(baseFontName.name);
  46598. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  46599. defaultWidth = metrics.defaultWidth;
  46600. }
  46601. }
  46602. }
  46603. var isMonospace = true;
  46604. var firstWidth = defaultWidth;
  46605. for (var glyph in glyphsWidths) {
  46606. var glyphWidth = glyphsWidths[glyph];
  46607. if (!glyphWidth) {
  46608. continue;
  46609. }
  46610. if (!firstWidth) {
  46611. firstWidth = glyphWidth;
  46612. continue;
  46613. }
  46614. if (firstWidth !== glyphWidth) {
  46615. isMonospace = false;
  46616. break;
  46617. }
  46618. }
  46619. if (isMonospace) {
  46620. properties.flags |= FontFlags.FixedPitch;
  46621. }
  46622. properties.defaultWidth = defaultWidth;
  46623. properties.widths = glyphsWidths;
  46624. properties.defaultVMetrics = defaultVMetrics;
  46625. properties.vmetrics = glyphsVMetrics;
  46626. },
  46627. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  46628. var fontNameWoStyle = baseFontName.split('-')[0];
  46629. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  46630. },
  46631. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  46632. var defaultWidth = 0;
  46633. var widths = [];
  46634. var monospace = false;
  46635. var stdFontMap = getStdFontMap();
  46636. var lookupName = stdFontMap[name] || name;
  46637. var Metrics = getMetrics();
  46638. if (!(lookupName in Metrics)) {
  46639. if (this.isSerifFont(name)) {
  46640. lookupName = 'Times-Roman';
  46641. } else {
  46642. lookupName = 'Helvetica';
  46643. }
  46644. }
  46645. var glyphWidths = Metrics[lookupName];
  46646. if (isNum(glyphWidths)) {
  46647. defaultWidth = glyphWidths;
  46648. monospace = true;
  46649. } else {
  46650. widths = glyphWidths();
  46651. }
  46652. return {
  46653. defaultWidth: defaultWidth,
  46654. monospace: monospace,
  46655. widths: widths
  46656. };
  46657. },
  46658. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  46659. var widths = Object.create(null);
  46660. var differences = properties.differences;
  46661. var encoding = properties.defaultEncoding;
  46662. for (var charCode = 0; charCode < 256; charCode++) {
  46663. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  46664. widths[charCode] = widthsByGlyphName[differences[charCode]];
  46665. continue;
  46666. }
  46667. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  46668. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  46669. continue;
  46670. }
  46671. }
  46672. return widths;
  46673. },
  46674. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  46675. var baseDict = dict;
  46676. var type = dict.get('Subtype');
  46677. assert(isName(type), 'invalid font Subtype');
  46678. var composite = false;
  46679. var uint8array;
  46680. if (type.name === 'Type0') {
  46681. var df = dict.get('DescendantFonts');
  46682. if (!df) {
  46683. error('Descendant fonts are not specified');
  46684. }
  46685. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  46686. type = dict.get('Subtype');
  46687. assert(isName(type), 'invalid font Subtype');
  46688. composite = true;
  46689. }
  46690. var descriptor = dict.get('FontDescriptor');
  46691. if (descriptor) {
  46692. var hash = new MurmurHash3_64();
  46693. var encoding = baseDict.getRaw('Encoding');
  46694. if (isName(encoding)) {
  46695. hash.update(encoding.name);
  46696. } else if (isRef(encoding)) {
  46697. hash.update(encoding.toString());
  46698. } else if (isDict(encoding)) {
  46699. var keys = encoding.getKeys();
  46700. for (var i = 0, ii = keys.length; i < ii; i++) {
  46701. var entry = encoding.getRaw(keys[i]);
  46702. if (isName(entry)) {
  46703. hash.update(entry.name);
  46704. } else if (isRef(entry)) {
  46705. hash.update(entry.toString());
  46706. } else if (isArray(entry)) {
  46707. var diffLength = entry.length, diffBuf = new Array(diffLength);
  46708. for (var j = 0; j < diffLength; j++) {
  46709. var diffEntry = entry[j];
  46710. if (isName(diffEntry)) {
  46711. diffBuf[j] = diffEntry.name;
  46712. } else if (isNum(diffEntry) || isRef(diffEntry)) {
  46713. diffBuf[j] = diffEntry.toString();
  46714. }
  46715. }
  46716. hash.update(diffBuf.join());
  46717. }
  46718. }
  46719. }
  46720. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  46721. if (isStream(toUnicode)) {
  46722. var stream = toUnicode.str || toUnicode;
  46723. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  46724. hash.update(uint8array);
  46725. } else if (isName(toUnicode)) {
  46726. hash.update(toUnicode.name);
  46727. }
  46728. var widths = dict.get('Widths') || baseDict.get('Widths');
  46729. if (widths) {
  46730. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  46731. hash.update(uint8array);
  46732. }
  46733. }
  46734. return {
  46735. descriptor: descriptor,
  46736. dict: dict,
  46737. baseDict: baseDict,
  46738. composite: composite,
  46739. type: type.name,
  46740. hash: hash ? hash.hexdigest() : ''
  46741. };
  46742. },
  46743. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  46744. var baseDict = preEvaluatedFont.baseDict;
  46745. var dict = preEvaluatedFont.dict;
  46746. var composite = preEvaluatedFont.composite;
  46747. var descriptor = preEvaluatedFont.descriptor;
  46748. var type = preEvaluatedFont.type;
  46749. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  46750. var cMapOptions = this.options.cMapOptions;
  46751. var properties;
  46752. if (!descriptor) {
  46753. if (type === 'Type3') {
  46754. descriptor = new Dict(null);
  46755. descriptor.set('FontName', Name.get(type));
  46756. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  46757. } else {
  46758. var baseFontName = dict.get('BaseFont');
  46759. if (!isName(baseFontName)) {
  46760. error('Base font is not specified');
  46761. }
  46762. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  46763. var metrics = this.getBaseFontMetrics(baseFontName);
  46764. var fontNameWoStyle = baseFontName.split('-')[0];
  46765. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  46766. properties = {
  46767. type: type,
  46768. name: baseFontName,
  46769. widths: metrics.widths,
  46770. defaultWidth: metrics.defaultWidth,
  46771. flags: flags,
  46772. firstChar: 0,
  46773. lastChar: maxCharIndex
  46774. };
  46775. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  46776. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  46777. return new Font(baseFontName, null, properties);
  46778. }.bind(this));
  46779. }
  46780. }
  46781. var firstChar = dict.get('FirstChar') || 0;
  46782. var lastChar = dict.get('LastChar') || maxCharIndex;
  46783. var fontName = descriptor.get('FontName');
  46784. var baseFont = dict.get('BaseFont');
  46785. if (isString(fontName)) {
  46786. fontName = Name.get(fontName);
  46787. }
  46788. if (isString(baseFont)) {
  46789. baseFont = Name.get(baseFont);
  46790. }
  46791. if (type !== 'Type3') {
  46792. var fontNameStr = fontName && fontName.name;
  46793. var baseFontStr = baseFont && baseFont.name;
  46794. if (fontNameStr !== baseFontStr) {
  46795. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  46796. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  46797. fontName = baseFont;
  46798. }
  46799. }
  46800. }
  46801. fontName = fontName || baseFont;
  46802. assert(isName(fontName), 'invalid font name');
  46803. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  46804. if (fontFile) {
  46805. if (fontFile.dict) {
  46806. var subtype = fontFile.dict.get('Subtype');
  46807. if (subtype) {
  46808. subtype = subtype.name;
  46809. }
  46810. var length1 = fontFile.dict.get('Length1');
  46811. var length2 = fontFile.dict.get('Length2');
  46812. var length3 = fontFile.dict.get('Length3');
  46813. }
  46814. }
  46815. properties = {
  46816. type: type,
  46817. name: fontName.name,
  46818. subtype: subtype,
  46819. file: fontFile,
  46820. length1: length1,
  46821. length2: length2,
  46822. length3: length3,
  46823. loadedName: baseDict.loadedName,
  46824. composite: composite,
  46825. wideChars: composite,
  46826. fixedPitch: false,
  46827. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  46828. firstChar: firstChar || 0,
  46829. lastChar: lastChar || maxCharIndex,
  46830. bbox: descriptor.getArray('FontBBox'),
  46831. ascent: descriptor.get('Ascent'),
  46832. descent: descriptor.get('Descent'),
  46833. xHeight: descriptor.get('XHeight'),
  46834. capHeight: descriptor.get('CapHeight'),
  46835. flags: descriptor.get('Flags'),
  46836. italicAngle: descriptor.get('ItalicAngle'),
  46837. coded: false
  46838. };
  46839. var cMapPromise;
  46840. if (composite) {
  46841. var cidEncoding = baseDict.get('Encoding');
  46842. if (isName(cidEncoding)) {
  46843. properties.cidEncoding = cidEncoding.name;
  46844. }
  46845. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  46846. properties.cMap = cMap;
  46847. properties.vertical = properties.cMap.vertical;
  46848. });
  46849. } else {
  46850. cMapPromise = Promise.resolve(undefined);
  46851. }
  46852. return cMapPromise.then(function () {
  46853. return this.extractDataStructures(dict, baseDict, xref, properties);
  46854. }.bind(this)).then(function (properties) {
  46855. this.extractWidths(dict, xref, descriptor, properties);
  46856. if (type === 'Type3') {
  46857. properties.isType3Font = true;
  46858. }
  46859. return new Font(fontName.name, fontFile, properties);
  46860. }.bind(this));
  46861. }
  46862. };
  46863. return PartialEvaluator;
  46864. }();
  46865. var TranslatedFont = function TranslatedFontClosure() {
  46866. function TranslatedFont(loadedName, font, dict) {
  46867. this.loadedName = loadedName;
  46868. this.font = font;
  46869. this.dict = dict;
  46870. this.type3Loaded = null;
  46871. this.sent = false;
  46872. }
  46873. TranslatedFont.prototype = {
  46874. send: function (handler) {
  46875. if (this.sent) {
  46876. return;
  46877. }
  46878. var fontData = this.font.exportData();
  46879. handler.send('commonobj', [
  46880. this.loadedName,
  46881. 'Font',
  46882. fontData
  46883. ]);
  46884. this.sent = true;
  46885. },
  46886. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  46887. assert(this.font.isType3Font);
  46888. if (this.type3Loaded) {
  46889. return this.type3Loaded;
  46890. }
  46891. var translatedFont = this.font;
  46892. var loadCharProcsPromise = Promise.resolve();
  46893. var charProcs = this.dict.get('CharProcs');
  46894. var fontResources = this.dict.get('Resources') || resources;
  46895. var charProcKeys = charProcs.getKeys();
  46896. var charProcOperatorList = Object.create(null);
  46897. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  46898. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  46899. var glyphStream = charProcs.get(key);
  46900. var operatorList = new OperatorList();
  46901. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  46902. charProcOperatorList[key] = operatorList.getIR();
  46903. parentOperatorList.addDependencies(operatorList.dependencies);
  46904. }, function (reason) {
  46905. warn('Type3 font resource \"' + key + '\" is not available');
  46906. var operatorList = new OperatorList();
  46907. charProcOperatorList[key] = operatorList.getIR();
  46908. });
  46909. }.bind(this, charProcKeys[i]));
  46910. }
  46911. this.type3Loaded = loadCharProcsPromise.then(function () {
  46912. translatedFont.charProcOperatorList = charProcOperatorList;
  46913. });
  46914. return this.type3Loaded;
  46915. }
  46916. };
  46917. return TranslatedFont;
  46918. }();
  46919. var OperatorList = function OperatorListClosure() {
  46920. var CHUNK_SIZE = 1000;
  46921. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  46922. function getTransfers(queue) {
  46923. var transfers = [];
  46924. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  46925. for (var i = 0, ii = queue.length; i < ii; i++) {
  46926. switch (fnArray[i]) {
  46927. case OPS.paintInlineImageXObject:
  46928. case OPS.paintInlineImageXObjectGroup:
  46929. case OPS.paintImageMaskXObject:
  46930. var arg = argsArray[i][0];
  46931. if (!arg.cached) {
  46932. transfers.push(arg.data.buffer);
  46933. }
  46934. break;
  46935. }
  46936. }
  46937. return transfers;
  46938. }
  46939. function OperatorList(intent, messageHandler, pageIndex) {
  46940. this.messageHandler = messageHandler;
  46941. this.fnArray = [];
  46942. this.argsArray = [];
  46943. this.dependencies = Object.create(null);
  46944. this._totalLength = 0;
  46945. this.pageIndex = pageIndex;
  46946. this.intent = intent;
  46947. }
  46948. OperatorList.prototype = {
  46949. get length() {
  46950. return this.argsArray.length;
  46951. },
  46952. get totalLength() {
  46953. return this._totalLength + this.length;
  46954. },
  46955. addOp: function (fn, args) {
  46956. this.fnArray.push(fn);
  46957. this.argsArray.push(args);
  46958. if (this.messageHandler) {
  46959. if (this.fnArray.length >= CHUNK_SIZE) {
  46960. this.flush();
  46961. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  46962. this.flush();
  46963. }
  46964. }
  46965. },
  46966. addDependency: function (dependency) {
  46967. if (dependency in this.dependencies) {
  46968. return;
  46969. }
  46970. this.dependencies[dependency] = true;
  46971. this.addOp(OPS.dependency, [dependency]);
  46972. },
  46973. addDependencies: function (dependencies) {
  46974. for (var key in dependencies) {
  46975. this.addDependency(key);
  46976. }
  46977. },
  46978. addOpList: function (opList) {
  46979. Util.extendObj(this.dependencies, opList.dependencies);
  46980. for (var i = 0, ii = opList.length; i < ii; i++) {
  46981. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  46982. }
  46983. },
  46984. getIR: function () {
  46985. return {
  46986. fnArray: this.fnArray,
  46987. argsArray: this.argsArray,
  46988. length: this.length
  46989. };
  46990. },
  46991. flush: function (lastChunk) {
  46992. if (this.intent !== 'oplist') {
  46993. new QueueOptimizer().optimize(this);
  46994. }
  46995. var transfers = getTransfers(this);
  46996. var length = this.length;
  46997. this._totalLength += length;
  46998. this.messageHandler.send('RenderPageChunk', {
  46999. operatorList: {
  47000. fnArray: this.fnArray,
  47001. argsArray: this.argsArray,
  47002. lastChunk: lastChunk,
  47003. length: length
  47004. },
  47005. pageIndex: this.pageIndex,
  47006. intent: this.intent
  47007. }, transfers);
  47008. this.dependencies = Object.create(null);
  47009. this.fnArray.length = 0;
  47010. this.argsArray.length = 0;
  47011. }
  47012. };
  47013. return OperatorList;
  47014. }();
  47015. var StateManager = function StateManagerClosure() {
  47016. function StateManager(initialState) {
  47017. this.state = initialState;
  47018. this.stateStack = [];
  47019. }
  47020. StateManager.prototype = {
  47021. save: function () {
  47022. var old = this.state;
  47023. this.stateStack.push(this.state);
  47024. this.state = old.clone();
  47025. },
  47026. restore: function () {
  47027. var prev = this.stateStack.pop();
  47028. if (prev) {
  47029. this.state = prev;
  47030. }
  47031. },
  47032. transform: function (args) {
  47033. this.state.ctm = Util.transform(this.state.ctm, args);
  47034. }
  47035. };
  47036. return StateManager;
  47037. }();
  47038. var TextState = function TextStateClosure() {
  47039. function TextState() {
  47040. this.ctm = new Float32Array(IDENTITY_MATRIX);
  47041. this.fontName = null;
  47042. this.fontSize = 0;
  47043. this.font = null;
  47044. this.fontMatrix = FONT_IDENTITY_MATRIX;
  47045. this.textMatrix = IDENTITY_MATRIX.slice();
  47046. this.textLineMatrix = IDENTITY_MATRIX.slice();
  47047. this.charSpacing = 0;
  47048. this.wordSpacing = 0;
  47049. this.leading = 0;
  47050. this.textHScale = 1;
  47051. this.textRise = 0;
  47052. }
  47053. TextState.prototype = {
  47054. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  47055. var m = this.textMatrix;
  47056. m[0] = a;
  47057. m[1] = b;
  47058. m[2] = c;
  47059. m[3] = d;
  47060. m[4] = e;
  47061. m[5] = f;
  47062. },
  47063. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  47064. var m = this.textLineMatrix;
  47065. m[0] = a;
  47066. m[1] = b;
  47067. m[2] = c;
  47068. m[3] = d;
  47069. m[4] = e;
  47070. m[5] = f;
  47071. },
  47072. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  47073. var m = this.textMatrix;
  47074. m[4] = m[0] * x + m[2] * y + m[4];
  47075. m[5] = m[1] * x + m[3] * y + m[5];
  47076. },
  47077. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  47078. var m = this.textLineMatrix;
  47079. m[4] = m[0] * x + m[2] * y + m[4];
  47080. m[5] = m[1] * x + m[3] * y + m[5];
  47081. },
  47082. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  47083. var font = this.font;
  47084. if (!font) {
  47085. return null;
  47086. }
  47087. var m = this.textLineMatrix;
  47088. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  47089. return null;
  47090. }
  47091. var txDiff = e - m[4], tyDiff = f - m[5];
  47092. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  47093. return null;
  47094. }
  47095. var tx, ty, denominator = a * d - b * c;
  47096. if (font.vertical) {
  47097. tx = -tyDiff * c / denominator;
  47098. ty = tyDiff * a / denominator;
  47099. } else {
  47100. tx = txDiff * d / denominator;
  47101. ty = -txDiff * b / denominator;
  47102. }
  47103. return {
  47104. width: tx,
  47105. height: ty,
  47106. value: font.vertical ? ty : tx
  47107. };
  47108. },
  47109. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  47110. var tsm = [
  47111. this.fontSize * this.textHScale,
  47112. 0,
  47113. 0,
  47114. this.fontSize,
  47115. 0,
  47116. this.textRise
  47117. ];
  47118. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  47119. },
  47120. carriageReturn: function TextState_carriageReturn() {
  47121. this.translateTextLineMatrix(0, -this.leading);
  47122. this.textMatrix = this.textLineMatrix.slice();
  47123. },
  47124. clone: function TextState_clone() {
  47125. var clone = Object.create(this);
  47126. clone.textMatrix = this.textMatrix.slice();
  47127. clone.textLineMatrix = this.textLineMatrix.slice();
  47128. clone.fontMatrix = this.fontMatrix.slice();
  47129. return clone;
  47130. }
  47131. };
  47132. return TextState;
  47133. }();
  47134. var EvalState = function EvalStateClosure() {
  47135. function EvalState() {
  47136. this.ctm = new Float32Array(IDENTITY_MATRIX);
  47137. this.font = null;
  47138. this.textRenderingMode = TextRenderingMode.FILL;
  47139. this.fillColorSpace = ColorSpace.singletons.gray;
  47140. this.strokeColorSpace = ColorSpace.singletons.gray;
  47141. }
  47142. EvalState.prototype = {
  47143. clone: function CanvasExtraState_clone() {
  47144. return Object.create(this);
  47145. }
  47146. };
  47147. return EvalState;
  47148. }();
  47149. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  47150. var getOPMap = getLookupTableFactory(function (t) {
  47151. t['w'] = {
  47152. id: OPS.setLineWidth,
  47153. numArgs: 1,
  47154. variableArgs: false
  47155. };
  47156. t['J'] = {
  47157. id: OPS.setLineCap,
  47158. numArgs: 1,
  47159. variableArgs: false
  47160. };
  47161. t['j'] = {
  47162. id: OPS.setLineJoin,
  47163. numArgs: 1,
  47164. variableArgs: false
  47165. };
  47166. t['M'] = {
  47167. id: OPS.setMiterLimit,
  47168. numArgs: 1,
  47169. variableArgs: false
  47170. };
  47171. t['d'] = {
  47172. id: OPS.setDash,
  47173. numArgs: 2,
  47174. variableArgs: false
  47175. };
  47176. t['ri'] = {
  47177. id: OPS.setRenderingIntent,
  47178. numArgs: 1,
  47179. variableArgs: false
  47180. };
  47181. t['i'] = {
  47182. id: OPS.setFlatness,
  47183. numArgs: 1,
  47184. variableArgs: false
  47185. };
  47186. t['gs'] = {
  47187. id: OPS.setGState,
  47188. numArgs: 1,
  47189. variableArgs: false
  47190. };
  47191. t['q'] = {
  47192. id: OPS.save,
  47193. numArgs: 0,
  47194. variableArgs: false
  47195. };
  47196. t['Q'] = {
  47197. id: OPS.restore,
  47198. numArgs: 0,
  47199. variableArgs: false
  47200. };
  47201. t['cm'] = {
  47202. id: OPS.transform,
  47203. numArgs: 6,
  47204. variableArgs: false
  47205. };
  47206. t['m'] = {
  47207. id: OPS.moveTo,
  47208. numArgs: 2,
  47209. variableArgs: false
  47210. };
  47211. t['l'] = {
  47212. id: OPS.lineTo,
  47213. numArgs: 2,
  47214. variableArgs: false
  47215. };
  47216. t['c'] = {
  47217. id: OPS.curveTo,
  47218. numArgs: 6,
  47219. variableArgs: false
  47220. };
  47221. t['v'] = {
  47222. id: OPS.curveTo2,
  47223. numArgs: 4,
  47224. variableArgs: false
  47225. };
  47226. t['y'] = {
  47227. id: OPS.curveTo3,
  47228. numArgs: 4,
  47229. variableArgs: false
  47230. };
  47231. t['h'] = {
  47232. id: OPS.closePath,
  47233. numArgs: 0,
  47234. variableArgs: false
  47235. };
  47236. t['re'] = {
  47237. id: OPS.rectangle,
  47238. numArgs: 4,
  47239. variableArgs: false
  47240. };
  47241. t['S'] = {
  47242. id: OPS.stroke,
  47243. numArgs: 0,
  47244. variableArgs: false
  47245. };
  47246. t['s'] = {
  47247. id: OPS.closeStroke,
  47248. numArgs: 0,
  47249. variableArgs: false
  47250. };
  47251. t['f'] = {
  47252. id: OPS.fill,
  47253. numArgs: 0,
  47254. variableArgs: false
  47255. };
  47256. t['F'] = {
  47257. id: OPS.fill,
  47258. numArgs: 0,
  47259. variableArgs: false
  47260. };
  47261. t['f*'] = {
  47262. id: OPS.eoFill,
  47263. numArgs: 0,
  47264. variableArgs: false
  47265. };
  47266. t['B'] = {
  47267. id: OPS.fillStroke,
  47268. numArgs: 0,
  47269. variableArgs: false
  47270. };
  47271. t['B*'] = {
  47272. id: OPS.eoFillStroke,
  47273. numArgs: 0,
  47274. variableArgs: false
  47275. };
  47276. t['b'] = {
  47277. id: OPS.closeFillStroke,
  47278. numArgs: 0,
  47279. variableArgs: false
  47280. };
  47281. t['b*'] = {
  47282. id: OPS.closeEOFillStroke,
  47283. numArgs: 0,
  47284. variableArgs: false
  47285. };
  47286. t['n'] = {
  47287. id: OPS.endPath,
  47288. numArgs: 0,
  47289. variableArgs: false
  47290. };
  47291. t['W'] = {
  47292. id: OPS.clip,
  47293. numArgs: 0,
  47294. variableArgs: false
  47295. };
  47296. t['W*'] = {
  47297. id: OPS.eoClip,
  47298. numArgs: 0,
  47299. variableArgs: false
  47300. };
  47301. t['BT'] = {
  47302. id: OPS.beginText,
  47303. numArgs: 0,
  47304. variableArgs: false
  47305. };
  47306. t['ET'] = {
  47307. id: OPS.endText,
  47308. numArgs: 0,
  47309. variableArgs: false
  47310. };
  47311. t['Tc'] = {
  47312. id: OPS.setCharSpacing,
  47313. numArgs: 1,
  47314. variableArgs: false
  47315. };
  47316. t['Tw'] = {
  47317. id: OPS.setWordSpacing,
  47318. numArgs: 1,
  47319. variableArgs: false
  47320. };
  47321. t['Tz'] = {
  47322. id: OPS.setHScale,
  47323. numArgs: 1,
  47324. variableArgs: false
  47325. };
  47326. t['TL'] = {
  47327. id: OPS.setLeading,
  47328. numArgs: 1,
  47329. variableArgs: false
  47330. };
  47331. t['Tf'] = {
  47332. id: OPS.setFont,
  47333. numArgs: 2,
  47334. variableArgs: false
  47335. };
  47336. t['Tr'] = {
  47337. id: OPS.setTextRenderingMode,
  47338. numArgs: 1,
  47339. variableArgs: false
  47340. };
  47341. t['Ts'] = {
  47342. id: OPS.setTextRise,
  47343. numArgs: 1,
  47344. variableArgs: false
  47345. };
  47346. t['Td'] = {
  47347. id: OPS.moveText,
  47348. numArgs: 2,
  47349. variableArgs: false
  47350. };
  47351. t['TD'] = {
  47352. id: OPS.setLeadingMoveText,
  47353. numArgs: 2,
  47354. variableArgs: false
  47355. };
  47356. t['Tm'] = {
  47357. id: OPS.setTextMatrix,
  47358. numArgs: 6,
  47359. variableArgs: false
  47360. };
  47361. t['T*'] = {
  47362. id: OPS.nextLine,
  47363. numArgs: 0,
  47364. variableArgs: false
  47365. };
  47366. t['Tj'] = {
  47367. id: OPS.showText,
  47368. numArgs: 1,
  47369. variableArgs: false
  47370. };
  47371. t['TJ'] = {
  47372. id: OPS.showSpacedText,
  47373. numArgs: 1,
  47374. variableArgs: false
  47375. };
  47376. t['\''] = {
  47377. id: OPS.nextLineShowText,
  47378. numArgs: 1,
  47379. variableArgs: false
  47380. };
  47381. t['"'] = {
  47382. id: OPS.nextLineSetSpacingShowText,
  47383. numArgs: 3,
  47384. variableArgs: false
  47385. };
  47386. t['d0'] = {
  47387. id: OPS.setCharWidth,
  47388. numArgs: 2,
  47389. variableArgs: false
  47390. };
  47391. t['d1'] = {
  47392. id: OPS.setCharWidthAndBounds,
  47393. numArgs: 6,
  47394. variableArgs: false
  47395. };
  47396. t['CS'] = {
  47397. id: OPS.setStrokeColorSpace,
  47398. numArgs: 1,
  47399. variableArgs: false
  47400. };
  47401. t['cs'] = {
  47402. id: OPS.setFillColorSpace,
  47403. numArgs: 1,
  47404. variableArgs: false
  47405. };
  47406. t['SC'] = {
  47407. id: OPS.setStrokeColor,
  47408. numArgs: 4,
  47409. variableArgs: true
  47410. };
  47411. t['SCN'] = {
  47412. id: OPS.setStrokeColorN,
  47413. numArgs: 33,
  47414. variableArgs: true
  47415. };
  47416. t['sc'] = {
  47417. id: OPS.setFillColor,
  47418. numArgs: 4,
  47419. variableArgs: true
  47420. };
  47421. t['scn'] = {
  47422. id: OPS.setFillColorN,
  47423. numArgs: 33,
  47424. variableArgs: true
  47425. };
  47426. t['G'] = {
  47427. id: OPS.setStrokeGray,
  47428. numArgs: 1,
  47429. variableArgs: false
  47430. };
  47431. t['g'] = {
  47432. id: OPS.setFillGray,
  47433. numArgs: 1,
  47434. variableArgs: false
  47435. };
  47436. t['RG'] = {
  47437. id: OPS.setStrokeRGBColor,
  47438. numArgs: 3,
  47439. variableArgs: false
  47440. };
  47441. t['rg'] = {
  47442. id: OPS.setFillRGBColor,
  47443. numArgs: 3,
  47444. variableArgs: false
  47445. };
  47446. t['K'] = {
  47447. id: OPS.setStrokeCMYKColor,
  47448. numArgs: 4,
  47449. variableArgs: false
  47450. };
  47451. t['k'] = {
  47452. id: OPS.setFillCMYKColor,
  47453. numArgs: 4,
  47454. variableArgs: false
  47455. };
  47456. t['sh'] = {
  47457. id: OPS.shadingFill,
  47458. numArgs: 1,
  47459. variableArgs: false
  47460. };
  47461. t['BI'] = {
  47462. id: OPS.beginInlineImage,
  47463. numArgs: 0,
  47464. variableArgs: false
  47465. };
  47466. t['ID'] = {
  47467. id: OPS.beginImageData,
  47468. numArgs: 0,
  47469. variableArgs: false
  47470. };
  47471. t['EI'] = {
  47472. id: OPS.endInlineImage,
  47473. numArgs: 1,
  47474. variableArgs: false
  47475. };
  47476. t['Do'] = {
  47477. id: OPS.paintXObject,
  47478. numArgs: 1,
  47479. variableArgs: false
  47480. };
  47481. t['MP'] = {
  47482. id: OPS.markPoint,
  47483. numArgs: 1,
  47484. variableArgs: false
  47485. };
  47486. t['DP'] = {
  47487. id: OPS.markPointProps,
  47488. numArgs: 2,
  47489. variableArgs: false
  47490. };
  47491. t['BMC'] = {
  47492. id: OPS.beginMarkedContent,
  47493. numArgs: 1,
  47494. variableArgs: false
  47495. };
  47496. t['BDC'] = {
  47497. id: OPS.beginMarkedContentProps,
  47498. numArgs: 2,
  47499. variableArgs: false
  47500. };
  47501. t['EMC'] = {
  47502. id: OPS.endMarkedContent,
  47503. numArgs: 0,
  47504. variableArgs: false
  47505. };
  47506. t['BX'] = {
  47507. id: OPS.beginCompat,
  47508. numArgs: 0,
  47509. variableArgs: false
  47510. };
  47511. t['EX'] = {
  47512. id: OPS.endCompat,
  47513. numArgs: 0,
  47514. variableArgs: false
  47515. };
  47516. t['BM'] = null;
  47517. t['BD'] = null;
  47518. t['true'] = null;
  47519. t['fa'] = null;
  47520. t['fal'] = null;
  47521. t['fals'] = null;
  47522. t['false'] = null;
  47523. t['nu'] = null;
  47524. t['nul'] = null;
  47525. t['null'] = null;
  47526. });
  47527. function EvaluatorPreprocessor(stream, xref, stateManager) {
  47528. this.opMap = getOPMap();
  47529. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  47530. this.stateManager = stateManager;
  47531. this.nonProcessedArgs = [];
  47532. }
  47533. EvaluatorPreprocessor.prototype = {
  47534. get savedStatesDepth() {
  47535. return this.stateManager.stateStack.length;
  47536. },
  47537. read: function EvaluatorPreprocessor_read(operation) {
  47538. var args = operation.args;
  47539. while (true) {
  47540. var obj = this.parser.getObj();
  47541. if (isCmd(obj)) {
  47542. var cmd = obj.cmd;
  47543. var opSpec = this.opMap[cmd];
  47544. if (!opSpec) {
  47545. warn('Unknown command "' + cmd + '"');
  47546. continue;
  47547. }
  47548. var fn = opSpec.id;
  47549. var numArgs = opSpec.numArgs;
  47550. var argsLength = args !== null ? args.length : 0;
  47551. if (!opSpec.variableArgs) {
  47552. if (argsLength !== numArgs) {
  47553. var nonProcessedArgs = this.nonProcessedArgs;
  47554. while (argsLength > numArgs) {
  47555. nonProcessedArgs.push(args.shift());
  47556. argsLength--;
  47557. }
  47558. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  47559. if (args === null) {
  47560. args = [];
  47561. }
  47562. args.unshift(nonProcessedArgs.pop());
  47563. argsLength++;
  47564. }
  47565. }
  47566. if (argsLength < numArgs) {
  47567. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  47568. if (args !== null) {
  47569. args.length = 0;
  47570. }
  47571. continue;
  47572. }
  47573. } else if (argsLength > numArgs) {
  47574. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  47575. }
  47576. this.preprocessCommand(fn, args);
  47577. operation.fn = fn;
  47578. operation.args = args;
  47579. return true;
  47580. }
  47581. if (isEOF(obj)) {
  47582. return false;
  47583. }
  47584. if (obj !== null) {
  47585. if (args === null) {
  47586. args = [];
  47587. }
  47588. args.push(obj);
  47589. assert(args.length <= 33, 'Too many arguments');
  47590. }
  47591. }
  47592. },
  47593. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  47594. switch (fn | 0) {
  47595. case OPS.save:
  47596. this.stateManager.save();
  47597. break;
  47598. case OPS.restore:
  47599. this.stateManager.restore();
  47600. break;
  47601. case OPS.transform:
  47602. this.stateManager.transform(args);
  47603. break;
  47604. }
  47605. }
  47606. };
  47607. return EvaluatorPreprocessor;
  47608. }();
  47609. var QueueOptimizer = function QueueOptimizerClosure() {
  47610. function addState(parentState, pattern, fn) {
  47611. var state = parentState;
  47612. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  47613. var item = pattern[i];
  47614. state = state[item] || (state[item] = []);
  47615. }
  47616. state[pattern[pattern.length - 1]] = fn;
  47617. }
  47618. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  47619. var iFirstPIMXO = iFirstSave + 2;
  47620. for (var i = 0; i < count; i++) {
  47621. var arg = argsArray[iFirstPIMXO + 4 * i];
  47622. var imageMask = arg.length === 1 && arg[0];
  47623. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  47624. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  47625. continue;
  47626. }
  47627. break;
  47628. }
  47629. return count - i;
  47630. }
  47631. var InitialState = [];
  47632. addState(InitialState, [
  47633. OPS.save,
  47634. OPS.transform,
  47635. OPS.paintInlineImageXObject,
  47636. OPS.restore
  47637. ], function foundInlineImageGroup(context) {
  47638. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  47639. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  47640. var MAX_WIDTH = 1000;
  47641. var IMAGE_PADDING = 1;
  47642. var fnArray = context.fnArray, argsArray = context.argsArray;
  47643. var curr = context.iCurr;
  47644. var iFirstSave = curr - 3;
  47645. var iFirstTransform = curr - 2;
  47646. var iFirstPIIXO = curr - 1;
  47647. var i = iFirstSave + 4;
  47648. var ii = fnArray.length;
  47649. while (i + 3 < ii) {
  47650. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  47651. break;
  47652. }
  47653. i += 4;
  47654. }
  47655. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  47656. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  47657. return i;
  47658. }
  47659. var maxX = 0;
  47660. var map = [], maxLineHeight = 0;
  47661. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  47662. var q;
  47663. for (q = 0; q < count; q++) {
  47664. var transform = argsArray[iFirstTransform + (q << 2)];
  47665. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  47666. if (currentX + img.width > MAX_WIDTH) {
  47667. maxX = Math.max(maxX, currentX);
  47668. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  47669. currentX = 0;
  47670. maxLineHeight = 0;
  47671. }
  47672. map.push({
  47673. transform: transform,
  47674. x: currentX,
  47675. y: currentY,
  47676. w: img.width,
  47677. h: img.height
  47678. });
  47679. currentX += img.width + 2 * IMAGE_PADDING;
  47680. maxLineHeight = Math.max(maxLineHeight, img.height);
  47681. }
  47682. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  47683. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  47684. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  47685. var imgRowSize = imgWidth << 2;
  47686. for (q = 0; q < count; q++) {
  47687. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  47688. var rowSize = map[q].w << 2;
  47689. var dataOffset = 0;
  47690. var offset = map[q].x + map[q].y * imgWidth << 2;
  47691. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  47692. for (var k = 0, kk = map[q].h; k < kk; k++) {
  47693. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  47694. dataOffset += rowSize;
  47695. offset += imgRowSize;
  47696. }
  47697. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  47698. while (offset >= 0) {
  47699. data[offset - 4] = data[offset];
  47700. data[offset - 3] = data[offset + 1];
  47701. data[offset - 2] = data[offset + 2];
  47702. data[offset - 1] = data[offset + 3];
  47703. data[offset + rowSize] = data[offset + rowSize - 4];
  47704. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  47705. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  47706. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  47707. offset -= imgRowSize;
  47708. }
  47709. }
  47710. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  47711. argsArray.splice(iFirstSave, count * 4, [
  47712. {
  47713. width: imgWidth,
  47714. height: imgHeight,
  47715. kind: ImageKind.RGBA_32BPP,
  47716. data: imgData
  47717. },
  47718. map
  47719. ]);
  47720. return iFirstSave + 1;
  47721. });
  47722. addState(InitialState, [
  47723. OPS.save,
  47724. OPS.transform,
  47725. OPS.paintImageMaskXObject,
  47726. OPS.restore
  47727. ], function foundImageMaskGroup(context) {
  47728. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  47729. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  47730. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  47731. var fnArray = context.fnArray, argsArray = context.argsArray;
  47732. var curr = context.iCurr;
  47733. var iFirstSave = curr - 3;
  47734. var iFirstTransform = curr - 2;
  47735. var iFirstPIMXO = curr - 1;
  47736. var i = iFirstSave + 4;
  47737. var ii = fnArray.length;
  47738. while (i + 3 < ii) {
  47739. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  47740. break;
  47741. }
  47742. i += 4;
  47743. }
  47744. var count = (i - iFirstSave) / 4;
  47745. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  47746. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  47747. return i;
  47748. }
  47749. var q;
  47750. var isSameImage = false;
  47751. var iTransform, transformArgs;
  47752. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  47753. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  47754. isSameImage = true;
  47755. var firstTransformArg0 = argsArray[iFirstTransform][0];
  47756. var firstTransformArg3 = argsArray[iFirstTransform][3];
  47757. iTransform = iFirstTransform + 4;
  47758. var iPIMXO = iFirstPIMXO + 4;
  47759. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  47760. transformArgs = argsArray[iTransform];
  47761. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  47762. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  47763. isSameImage = false;
  47764. } else {
  47765. count = q;
  47766. }
  47767. break;
  47768. }
  47769. }
  47770. }
  47771. if (isSameImage) {
  47772. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  47773. var positions = new Float32Array(count * 2);
  47774. iTransform = iFirstTransform;
  47775. for (q = 0; q < count; q++, iTransform += 4) {
  47776. transformArgs = argsArray[iTransform];
  47777. positions[q << 1] = transformArgs[4];
  47778. positions[(q << 1) + 1] = transformArgs[5];
  47779. }
  47780. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  47781. argsArray.splice(iFirstSave, count * 4, [
  47782. firstPIMXOArg0,
  47783. firstTransformArg0,
  47784. firstTransformArg3,
  47785. positions
  47786. ]);
  47787. } else {
  47788. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  47789. var images = [];
  47790. for (q = 0; q < count; q++) {
  47791. transformArgs = argsArray[iFirstTransform + (q << 2)];
  47792. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  47793. images.push({
  47794. data: maskParams.data,
  47795. width: maskParams.width,
  47796. height: maskParams.height,
  47797. transform: transformArgs
  47798. });
  47799. }
  47800. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  47801. argsArray.splice(iFirstSave, count * 4, [images]);
  47802. }
  47803. return iFirstSave + 1;
  47804. });
  47805. addState(InitialState, [
  47806. OPS.save,
  47807. OPS.transform,
  47808. OPS.paintImageXObject,
  47809. OPS.restore
  47810. ], function (context) {
  47811. var MIN_IMAGES_IN_BLOCK = 3;
  47812. var MAX_IMAGES_IN_BLOCK = 1000;
  47813. var fnArray = context.fnArray, argsArray = context.argsArray;
  47814. var curr = context.iCurr;
  47815. var iFirstSave = curr - 3;
  47816. var iFirstTransform = curr - 2;
  47817. var iFirstPIXO = curr - 1;
  47818. var iFirstRestore = curr;
  47819. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  47820. return iFirstRestore + 1;
  47821. }
  47822. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  47823. var firstTransformArg0 = argsArray[iFirstTransform][0];
  47824. var firstTransformArg3 = argsArray[iFirstTransform][3];
  47825. var i = iFirstSave + 4;
  47826. var ii = fnArray.length;
  47827. while (i + 3 < ii) {
  47828. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  47829. break;
  47830. }
  47831. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  47832. break;
  47833. }
  47834. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  47835. break;
  47836. }
  47837. i += 4;
  47838. }
  47839. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  47840. if (count < MIN_IMAGES_IN_BLOCK) {
  47841. return i;
  47842. }
  47843. var positions = new Float32Array(count * 2);
  47844. var iTransform = iFirstTransform;
  47845. for (var q = 0; q < count; q++, iTransform += 4) {
  47846. var transformArgs = argsArray[iTransform];
  47847. positions[q << 1] = transformArgs[4];
  47848. positions[(q << 1) + 1] = transformArgs[5];
  47849. }
  47850. var args = [
  47851. firstPIXOArg0,
  47852. firstTransformArg0,
  47853. firstTransformArg3,
  47854. positions
  47855. ];
  47856. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  47857. argsArray.splice(iFirstSave, count * 4, args);
  47858. return iFirstSave + 1;
  47859. });
  47860. addState(InitialState, [
  47861. OPS.beginText,
  47862. OPS.setFont,
  47863. OPS.setTextMatrix,
  47864. OPS.showText,
  47865. OPS.endText
  47866. ], function (context) {
  47867. var MIN_CHARS_IN_BLOCK = 3;
  47868. var MAX_CHARS_IN_BLOCK = 1000;
  47869. var fnArray = context.fnArray, argsArray = context.argsArray;
  47870. var curr = context.iCurr;
  47871. var iFirstBeginText = curr - 4;
  47872. var iFirstSetFont = curr - 3;
  47873. var iFirstSetTextMatrix = curr - 2;
  47874. var iFirstShowText = curr - 1;
  47875. var iFirstEndText = curr;
  47876. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  47877. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  47878. var i = iFirstBeginText + 5;
  47879. var ii = fnArray.length;
  47880. while (i + 4 < ii) {
  47881. 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) {
  47882. break;
  47883. }
  47884. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  47885. break;
  47886. }
  47887. i += 5;
  47888. }
  47889. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  47890. if (count < MIN_CHARS_IN_BLOCK) {
  47891. return i;
  47892. }
  47893. var iFirst = iFirstBeginText;
  47894. 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) {
  47895. count++;
  47896. iFirst -= 5;
  47897. }
  47898. var iEndText = iFirst + 4;
  47899. for (var q = 1; q < count; q++) {
  47900. fnArray.splice(iEndText, 3);
  47901. argsArray.splice(iEndText, 3);
  47902. iEndText += 2;
  47903. }
  47904. return iEndText + 1;
  47905. });
  47906. function QueueOptimizer() {
  47907. }
  47908. QueueOptimizer.prototype = {
  47909. optimize: function QueueOptimizer_optimize(queue) {
  47910. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  47911. var context = {
  47912. iCurr: 0,
  47913. fnArray: fnArray,
  47914. argsArray: argsArray
  47915. };
  47916. var state;
  47917. var i = 0, ii = fnArray.length;
  47918. while (i < ii) {
  47919. state = (state || InitialState)[fnArray[i]];
  47920. if (typeof state === 'function') {
  47921. context.iCurr = i;
  47922. i = state(context);
  47923. state = undefined;
  47924. ii = context.fnArray.length;
  47925. } else {
  47926. i++;
  47927. }
  47928. }
  47929. }
  47930. };
  47931. return QueueOptimizer;
  47932. }();
  47933. exports.OperatorList = OperatorList;
  47934. exports.PartialEvaluator = PartialEvaluator;
  47935. }));
  47936. (function (root, factory) {
  47937. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  47938. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  47939. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  47940. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  47941. var AnnotationFlag = sharedUtil.AnnotationFlag;
  47942. var AnnotationType = sharedUtil.AnnotationType;
  47943. var OPS = sharedUtil.OPS;
  47944. var Util = sharedUtil.Util;
  47945. var isString = sharedUtil.isString;
  47946. var isArray = sharedUtil.isArray;
  47947. var isInt = sharedUtil.isInt;
  47948. var stringToBytes = sharedUtil.stringToBytes;
  47949. var stringToPDFString = sharedUtil.stringToPDFString;
  47950. var warn = sharedUtil.warn;
  47951. var Dict = corePrimitives.Dict;
  47952. var isDict = corePrimitives.isDict;
  47953. var isName = corePrimitives.isName;
  47954. var isRef = corePrimitives.isRef;
  47955. var Stream = coreStream.Stream;
  47956. var ColorSpace = coreColorSpace.ColorSpace;
  47957. var Catalog = coreObj.Catalog;
  47958. var ObjectLoader = coreObj.ObjectLoader;
  47959. var FileSpec = coreObj.FileSpec;
  47960. var OperatorList = coreEvaluator.OperatorList;
  47961. function AnnotationFactory() {
  47962. }
  47963. AnnotationFactory.prototype = {
  47964. create: function AnnotationFactory_create(xref, ref, pdfManager, idFactory) {
  47965. var dict = xref.fetchIfRef(ref);
  47966. if (!isDict(dict)) {
  47967. return;
  47968. }
  47969. var id = isRef(ref) ? ref.toString() : 'annot_' + idFactory.createObjId();
  47970. var subtype = dict.get('Subtype');
  47971. subtype = isName(subtype) ? subtype.name : null;
  47972. var parameters = {
  47973. xref: xref,
  47974. dict: dict,
  47975. ref: isRef(ref) ? ref : null,
  47976. subtype: subtype,
  47977. id: id,
  47978. pdfManager: pdfManager
  47979. };
  47980. switch (subtype) {
  47981. case 'Link':
  47982. return new LinkAnnotation(parameters);
  47983. case 'Text':
  47984. return new TextAnnotation(parameters);
  47985. case 'Widget':
  47986. var fieldType = Util.getInheritableProperty(dict, 'FT');
  47987. fieldType = isName(fieldType) ? fieldType.name : null;
  47988. switch (fieldType) {
  47989. case 'Tx':
  47990. return new TextWidgetAnnotation(parameters);
  47991. case 'Btn':
  47992. return new ButtonWidgetAnnotation(parameters);
  47993. case 'Ch':
  47994. return new ChoiceWidgetAnnotation(parameters);
  47995. }
  47996. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  47997. return new WidgetAnnotation(parameters);
  47998. case 'Popup':
  47999. return new PopupAnnotation(parameters);
  48000. case 'Highlight':
  48001. return new HighlightAnnotation(parameters);
  48002. case 'Underline':
  48003. return new UnderlineAnnotation(parameters);
  48004. case 'Squiggly':
  48005. return new SquigglyAnnotation(parameters);
  48006. case 'StrikeOut':
  48007. return new StrikeOutAnnotation(parameters);
  48008. case 'FileAttachment':
  48009. return new FileAttachmentAnnotation(parameters);
  48010. default:
  48011. if (!subtype) {
  48012. warn('Annotation is missing the required /Subtype.');
  48013. } else {
  48014. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  48015. }
  48016. return new Annotation(parameters);
  48017. }
  48018. }
  48019. };
  48020. var Annotation = function AnnotationClosure() {
  48021. function getTransformMatrix(rect, bbox, matrix) {
  48022. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  48023. var minX = bounds[0];
  48024. var minY = bounds[1];
  48025. var maxX = bounds[2];
  48026. var maxY = bounds[3];
  48027. if (minX === maxX || minY === maxY) {
  48028. return [
  48029. 1,
  48030. 0,
  48031. 0,
  48032. 1,
  48033. rect[0],
  48034. rect[1]
  48035. ];
  48036. }
  48037. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  48038. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  48039. return [
  48040. xRatio,
  48041. 0,
  48042. 0,
  48043. yRatio,
  48044. rect[0] - minX * xRatio,
  48045. rect[1] - minY * yRatio
  48046. ];
  48047. }
  48048. function getDefaultAppearance(dict) {
  48049. var appearanceState = dict.get('AP');
  48050. if (!isDict(appearanceState)) {
  48051. return;
  48052. }
  48053. var appearance;
  48054. var appearances = appearanceState.get('N');
  48055. if (isDict(appearances)) {
  48056. var as = dict.get('AS');
  48057. if (as && appearances.has(as.name)) {
  48058. appearance = appearances.get(as.name);
  48059. }
  48060. } else {
  48061. appearance = appearances;
  48062. }
  48063. return appearance;
  48064. }
  48065. function Annotation(params) {
  48066. var dict = params.dict;
  48067. this.setFlags(dict.get('F'));
  48068. this.setRectangle(dict.getArray('Rect'));
  48069. this.setColor(dict.getArray('C'));
  48070. this.setBorderStyle(dict);
  48071. this.appearance = getDefaultAppearance(dict);
  48072. this.data = {};
  48073. this.data.id = params.id;
  48074. this.data.subtype = params.subtype;
  48075. this.data.annotationFlags = this.flags;
  48076. this.data.rect = this.rectangle;
  48077. this.data.color = this.color;
  48078. this.data.borderStyle = this.borderStyle;
  48079. this.data.hasAppearance = !!this.appearance;
  48080. }
  48081. Annotation.prototype = {
  48082. _hasFlag: function Annotation_hasFlag(flags, flag) {
  48083. return !!(flags & flag);
  48084. },
  48085. _isViewable: function Annotation_isViewable(flags) {
  48086. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  48087. },
  48088. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  48089. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  48090. },
  48091. get viewable() {
  48092. if (this.flags === 0) {
  48093. return true;
  48094. }
  48095. return this._isViewable(this.flags);
  48096. },
  48097. get printable() {
  48098. if (this.flags === 0) {
  48099. return false;
  48100. }
  48101. return this._isPrintable(this.flags);
  48102. },
  48103. setFlags: function Annotation_setFlags(flags) {
  48104. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  48105. },
  48106. hasFlag: function Annotation_hasFlag(flag) {
  48107. return this._hasFlag(this.flags, flag);
  48108. },
  48109. setRectangle: function Annotation_setRectangle(rectangle) {
  48110. if (isArray(rectangle) && rectangle.length === 4) {
  48111. this.rectangle = Util.normalizeRect(rectangle);
  48112. } else {
  48113. this.rectangle = [
  48114. 0,
  48115. 0,
  48116. 0,
  48117. 0
  48118. ];
  48119. }
  48120. },
  48121. setColor: function Annotation_setColor(color) {
  48122. var rgbColor = new Uint8Array(3);
  48123. if (!isArray(color)) {
  48124. this.color = rgbColor;
  48125. return;
  48126. }
  48127. switch (color.length) {
  48128. case 0:
  48129. this.color = null;
  48130. break;
  48131. case 1:
  48132. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  48133. this.color = rgbColor;
  48134. break;
  48135. case 3:
  48136. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  48137. this.color = rgbColor;
  48138. break;
  48139. case 4:
  48140. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  48141. this.color = rgbColor;
  48142. break;
  48143. default:
  48144. this.color = rgbColor;
  48145. break;
  48146. }
  48147. },
  48148. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  48149. this.borderStyle = new AnnotationBorderStyle();
  48150. if (!isDict(borderStyle)) {
  48151. return;
  48152. }
  48153. if (borderStyle.has('BS')) {
  48154. var dict = borderStyle.get('BS');
  48155. var dictType = dict.get('Type');
  48156. if (!dictType || isName(dictType, 'Border')) {
  48157. this.borderStyle.setWidth(dict.get('W'));
  48158. this.borderStyle.setStyle(dict.get('S'));
  48159. this.borderStyle.setDashArray(dict.getArray('D'));
  48160. }
  48161. } else if (borderStyle.has('Border')) {
  48162. var array = borderStyle.getArray('Border');
  48163. if (isArray(array) && array.length >= 3) {
  48164. this.borderStyle.setHorizontalCornerRadius(array[0]);
  48165. this.borderStyle.setVerticalCornerRadius(array[1]);
  48166. this.borderStyle.setWidth(array[2]);
  48167. if (array.length === 4) {
  48168. this.borderStyle.setDashArray(array[3]);
  48169. }
  48170. }
  48171. } else {
  48172. this.borderStyle.setWidth(0);
  48173. }
  48174. },
  48175. _preparePopup: function Annotation_preparePopup(dict) {
  48176. if (!dict.has('C')) {
  48177. this.data.color = null;
  48178. }
  48179. this.data.hasPopup = dict.has('Popup');
  48180. this.data.title = stringToPDFString(dict.get('T') || '');
  48181. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  48182. },
  48183. loadResources: function Annotation_loadResources(keys) {
  48184. return new Promise(function (resolve, reject) {
  48185. this.appearance.dict.getAsync('Resources').then(function (resources) {
  48186. if (!resources) {
  48187. resolve();
  48188. return;
  48189. }
  48190. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  48191. objectLoader.load().then(function () {
  48192. resolve(resources);
  48193. }, reject);
  48194. }, reject);
  48195. }.bind(this));
  48196. },
  48197. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  48198. if (!this.appearance) {
  48199. return Promise.resolve(new OperatorList());
  48200. }
  48201. var data = this.data;
  48202. var appearanceDict = this.appearance.dict;
  48203. var resourcesPromise = this.loadResources([
  48204. 'ExtGState',
  48205. 'ColorSpace',
  48206. 'Pattern',
  48207. 'Shading',
  48208. 'XObject',
  48209. 'Font'
  48210. ]);
  48211. var bbox = appearanceDict.getArray('BBox') || [
  48212. 0,
  48213. 0,
  48214. 1,
  48215. 1
  48216. ];
  48217. var matrix = appearanceDict.getArray('Matrix') || [
  48218. 1,
  48219. 0,
  48220. 0,
  48221. 1,
  48222. 0,
  48223. 0
  48224. ];
  48225. var transform = getTransformMatrix(data.rect, bbox, matrix);
  48226. var self = this;
  48227. return resourcesPromise.then(function (resources) {
  48228. var opList = new OperatorList();
  48229. opList.addOp(OPS.beginAnnotation, [
  48230. data.rect,
  48231. transform,
  48232. matrix
  48233. ]);
  48234. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  48235. opList.addOp(OPS.endAnnotation, []);
  48236. self.appearance.reset();
  48237. return opList;
  48238. });
  48239. });
  48240. }
  48241. };
  48242. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  48243. var annotationPromises = [];
  48244. for (var i = 0, n = annotations.length; i < n; ++i) {
  48245. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  48246. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  48247. }
  48248. }
  48249. return Promise.all(annotationPromises).then(function (operatorLists) {
  48250. opList.addOp(OPS.beginAnnotations, []);
  48251. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  48252. opList.addOpList(operatorLists[i]);
  48253. }
  48254. opList.addOp(OPS.endAnnotations, []);
  48255. });
  48256. };
  48257. return Annotation;
  48258. }();
  48259. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  48260. function AnnotationBorderStyle() {
  48261. this.width = 1;
  48262. this.style = AnnotationBorderStyleType.SOLID;
  48263. this.dashArray = [3];
  48264. this.horizontalCornerRadius = 0;
  48265. this.verticalCornerRadius = 0;
  48266. }
  48267. AnnotationBorderStyle.prototype = {
  48268. setWidth: function AnnotationBorderStyle_setWidth(width) {
  48269. if (width === (width | 0)) {
  48270. this.width = width;
  48271. }
  48272. },
  48273. setStyle: function AnnotationBorderStyle_setStyle(style) {
  48274. if (!style) {
  48275. return;
  48276. }
  48277. switch (style.name) {
  48278. case 'S':
  48279. this.style = AnnotationBorderStyleType.SOLID;
  48280. break;
  48281. case 'D':
  48282. this.style = AnnotationBorderStyleType.DASHED;
  48283. break;
  48284. case 'B':
  48285. this.style = AnnotationBorderStyleType.BEVELED;
  48286. break;
  48287. case 'I':
  48288. this.style = AnnotationBorderStyleType.INSET;
  48289. break;
  48290. case 'U':
  48291. this.style = AnnotationBorderStyleType.UNDERLINE;
  48292. break;
  48293. default:
  48294. break;
  48295. }
  48296. },
  48297. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  48298. if (isArray(dashArray) && dashArray.length > 0) {
  48299. var isValid = true;
  48300. var allZeros = true;
  48301. for (var i = 0, len = dashArray.length; i < len; i++) {
  48302. var element = dashArray[i];
  48303. var validNumber = +element >= 0;
  48304. if (!validNumber) {
  48305. isValid = false;
  48306. break;
  48307. } else if (element > 0) {
  48308. allZeros = false;
  48309. }
  48310. }
  48311. if (isValid && !allZeros) {
  48312. this.dashArray = dashArray;
  48313. } else {
  48314. this.width = 0;
  48315. }
  48316. } else if (dashArray) {
  48317. this.width = 0;
  48318. }
  48319. },
  48320. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  48321. if (radius === (radius | 0)) {
  48322. this.horizontalCornerRadius = radius;
  48323. }
  48324. },
  48325. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  48326. if (radius === (radius | 0)) {
  48327. this.verticalCornerRadius = radius;
  48328. }
  48329. }
  48330. };
  48331. return AnnotationBorderStyle;
  48332. }();
  48333. var WidgetAnnotation = function WidgetAnnotationClosure() {
  48334. function WidgetAnnotation(params) {
  48335. Annotation.call(this, params);
  48336. var dict = params.dict;
  48337. var data = this.data;
  48338. data.annotationType = AnnotationType.WIDGET;
  48339. data.fieldName = this._constructFieldName(dict);
  48340. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  48341. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  48342. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  48343. var fieldType = Util.getInheritableProperty(dict, 'FT');
  48344. data.fieldType = isName(fieldType) ? fieldType.name : null;
  48345. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  48346. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  48347. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  48348. data.fieldFlags = 0;
  48349. }
  48350. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  48351. if (data.fieldType === 'Sig') {
  48352. this.setFlags(AnnotationFlag.HIDDEN);
  48353. }
  48354. }
  48355. Util.inherit(WidgetAnnotation, Annotation, {
  48356. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  48357. if (!dict.has('T') && !dict.has('Parent')) {
  48358. warn('Unknown field name, falling back to empty field name.');
  48359. return '';
  48360. }
  48361. if (!dict.has('Parent')) {
  48362. return stringToPDFString(dict.get('T'));
  48363. }
  48364. var fieldName = [];
  48365. if (dict.has('T')) {
  48366. fieldName.unshift(stringToPDFString(dict.get('T')));
  48367. }
  48368. var loopDict = dict;
  48369. while (loopDict.has('Parent')) {
  48370. loopDict = loopDict.get('Parent');
  48371. if (loopDict.has('T')) {
  48372. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  48373. }
  48374. }
  48375. return fieldName.join('.');
  48376. },
  48377. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  48378. return !!(this.data.fieldFlags & flag);
  48379. }
  48380. });
  48381. return WidgetAnnotation;
  48382. }();
  48383. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  48384. function TextWidgetAnnotation(params) {
  48385. WidgetAnnotation.call(this, params);
  48386. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  48387. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  48388. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  48389. alignment = null;
  48390. }
  48391. this.data.textAlignment = alignment;
  48392. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  48393. if (!isInt(maximumLength) || maximumLength < 0) {
  48394. maximumLength = null;
  48395. }
  48396. this.data.maxLen = maximumLength;
  48397. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  48398. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  48399. }
  48400. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  48401. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  48402. var operatorList = new OperatorList();
  48403. if (renderForms) {
  48404. return Promise.resolve(operatorList);
  48405. }
  48406. if (this.appearance) {
  48407. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  48408. }
  48409. if (!this.data.defaultAppearance) {
  48410. return Promise.resolve(operatorList);
  48411. }
  48412. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  48413. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  48414. return operatorList;
  48415. });
  48416. }
  48417. });
  48418. return TextWidgetAnnotation;
  48419. }();
  48420. var ButtonWidgetAnnotation = function ButtonWidgetAnnotationClosure() {
  48421. function ButtonWidgetAnnotation(params) {
  48422. WidgetAnnotation.call(this, params);
  48423. this.data.checkBox = !this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  48424. if (this.data.checkBox) {
  48425. if (!isName(this.data.fieldValue)) {
  48426. return;
  48427. }
  48428. this.data.fieldValue = this.data.fieldValue.name;
  48429. }
  48430. this.data.radioButton = this.hasFieldFlag(AnnotationFieldFlag.RADIO) && !this.hasFieldFlag(AnnotationFieldFlag.PUSHBUTTON);
  48431. if (this.data.radioButton) {
  48432. this.data.fieldValue = this.data.buttonValue = null;
  48433. var fieldParent = params.dict.get('Parent');
  48434. if (!isDict(fieldParent) || !fieldParent.has('V')) {
  48435. return;
  48436. }
  48437. var fieldParentValue = fieldParent.get('V');
  48438. if (!isName(fieldParentValue)) {
  48439. return;
  48440. }
  48441. this.data.fieldValue = fieldParentValue.name;
  48442. var appearanceStates = params.dict.get('AP');
  48443. if (!isDict(appearanceStates)) {
  48444. return;
  48445. }
  48446. var normalAppearanceState = appearanceStates.get('N');
  48447. if (!isDict(normalAppearanceState)) {
  48448. return;
  48449. }
  48450. var keys = normalAppearanceState.getKeys();
  48451. for (var i = 0, ii = keys.length; i < ii; i++) {
  48452. if (keys[i] !== 'Off') {
  48453. this.data.buttonValue = keys[i];
  48454. break;
  48455. }
  48456. }
  48457. }
  48458. }
  48459. Util.inherit(ButtonWidgetAnnotation, WidgetAnnotation, {
  48460. getOperatorList: function ButtonWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  48461. var operatorList = new OperatorList();
  48462. if (renderForms) {
  48463. return Promise.resolve(operatorList);
  48464. }
  48465. if (this.appearance) {
  48466. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  48467. }
  48468. return Promise.resolve(operatorList);
  48469. }
  48470. });
  48471. return ButtonWidgetAnnotation;
  48472. }();
  48473. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  48474. function ChoiceWidgetAnnotation(params) {
  48475. WidgetAnnotation.call(this, params);
  48476. this.data.options = [];
  48477. var options = params.dict.get('Opt');
  48478. if (isArray(options)) {
  48479. var xref = params.xref;
  48480. for (var i = 0, ii = options.length; i < ii; i++) {
  48481. var option = xref.fetchIfRef(options[i]);
  48482. var isOptionArray = isArray(option);
  48483. this.data.options[i] = {
  48484. exportValue: isOptionArray ? xref.fetchIfRef(option[0]) : option,
  48485. displayValue: isOptionArray ? xref.fetchIfRef(option[1]) : option
  48486. };
  48487. }
  48488. }
  48489. if (!isArray(this.data.fieldValue)) {
  48490. this.data.fieldValue = [this.data.fieldValue];
  48491. }
  48492. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  48493. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  48494. }
  48495. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  48496. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  48497. var operatorList = new OperatorList();
  48498. if (renderForms) {
  48499. return Promise.resolve(operatorList);
  48500. }
  48501. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  48502. }
  48503. });
  48504. return ChoiceWidgetAnnotation;
  48505. }();
  48506. var TextAnnotation = function TextAnnotationClosure() {
  48507. var DEFAULT_ICON_SIZE = 22;
  48508. function TextAnnotation(parameters) {
  48509. Annotation.call(this, parameters);
  48510. this.data.annotationType = AnnotationType.TEXT;
  48511. if (this.data.hasAppearance) {
  48512. this.data.name = 'NoIcon';
  48513. } else {
  48514. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  48515. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  48516. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  48517. }
  48518. this._preparePopup(parameters.dict);
  48519. }
  48520. Util.inherit(TextAnnotation, Annotation, {});
  48521. return TextAnnotation;
  48522. }();
  48523. var LinkAnnotation = function LinkAnnotationClosure() {
  48524. function LinkAnnotation(params) {
  48525. Annotation.call(this, params);
  48526. var data = this.data;
  48527. data.annotationType = AnnotationType.LINK;
  48528. Catalog.parseDestDictionary({
  48529. destDict: params.dict,
  48530. resultObj: data,
  48531. docBaseUrl: params.pdfManager.docBaseUrl
  48532. });
  48533. }
  48534. Util.inherit(LinkAnnotation, Annotation, {});
  48535. return LinkAnnotation;
  48536. }();
  48537. var PopupAnnotation = function PopupAnnotationClosure() {
  48538. function PopupAnnotation(parameters) {
  48539. Annotation.call(this, parameters);
  48540. this.data.annotationType = AnnotationType.POPUP;
  48541. var dict = parameters.dict;
  48542. var parentItem = dict.get('Parent');
  48543. if (!parentItem) {
  48544. warn('Popup annotation has a missing or invalid parent annotation.');
  48545. return;
  48546. }
  48547. this.data.parentId = dict.getRaw('Parent').toString();
  48548. this.data.title = stringToPDFString(parentItem.get('T') || '');
  48549. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  48550. if (!parentItem.has('C')) {
  48551. this.data.color = null;
  48552. } else {
  48553. this.setColor(parentItem.getArray('C'));
  48554. this.data.color = this.color;
  48555. }
  48556. if (!this.viewable) {
  48557. var parentFlags = parentItem.get('F');
  48558. if (this._isViewable(parentFlags)) {
  48559. this.setFlags(parentFlags);
  48560. }
  48561. }
  48562. }
  48563. Util.inherit(PopupAnnotation, Annotation, {});
  48564. return PopupAnnotation;
  48565. }();
  48566. var HighlightAnnotation = function HighlightAnnotationClosure() {
  48567. function HighlightAnnotation(parameters) {
  48568. Annotation.call(this, parameters);
  48569. this.data.annotationType = AnnotationType.HIGHLIGHT;
  48570. this._preparePopup(parameters.dict);
  48571. this.data.borderStyle.setWidth(0);
  48572. }
  48573. Util.inherit(HighlightAnnotation, Annotation, {});
  48574. return HighlightAnnotation;
  48575. }();
  48576. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  48577. function UnderlineAnnotation(parameters) {
  48578. Annotation.call(this, parameters);
  48579. this.data.annotationType = AnnotationType.UNDERLINE;
  48580. this._preparePopup(parameters.dict);
  48581. this.data.borderStyle.setWidth(0);
  48582. }
  48583. Util.inherit(UnderlineAnnotation, Annotation, {});
  48584. return UnderlineAnnotation;
  48585. }();
  48586. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  48587. function SquigglyAnnotation(parameters) {
  48588. Annotation.call(this, parameters);
  48589. this.data.annotationType = AnnotationType.SQUIGGLY;
  48590. this._preparePopup(parameters.dict);
  48591. this.data.borderStyle.setWidth(0);
  48592. }
  48593. Util.inherit(SquigglyAnnotation, Annotation, {});
  48594. return SquigglyAnnotation;
  48595. }();
  48596. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  48597. function StrikeOutAnnotation(parameters) {
  48598. Annotation.call(this, parameters);
  48599. this.data.annotationType = AnnotationType.STRIKEOUT;
  48600. this._preparePopup(parameters.dict);
  48601. this.data.borderStyle.setWidth(0);
  48602. }
  48603. Util.inherit(StrikeOutAnnotation, Annotation, {});
  48604. return StrikeOutAnnotation;
  48605. }();
  48606. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  48607. function FileAttachmentAnnotation(parameters) {
  48608. Annotation.call(this, parameters);
  48609. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  48610. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  48611. this.data.file = file.serializable;
  48612. this._preparePopup(parameters.dict);
  48613. }
  48614. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  48615. return FileAttachmentAnnotation;
  48616. }();
  48617. exports.Annotation = Annotation;
  48618. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  48619. exports.AnnotationFactory = AnnotationFactory;
  48620. }));
  48621. (function (root, factory) {
  48622. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  48623. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  48624. var MissingDataException = sharedUtil.MissingDataException;
  48625. var Util = sharedUtil.Util;
  48626. var assert = sharedUtil.assert;
  48627. var error = sharedUtil.error;
  48628. var info = sharedUtil.info;
  48629. var isArray = sharedUtil.isArray;
  48630. var isArrayBuffer = sharedUtil.isArrayBuffer;
  48631. var isNum = sharedUtil.isNum;
  48632. var isString = sharedUtil.isString;
  48633. var shadow = sharedUtil.shadow;
  48634. var stringToBytes = sharedUtil.stringToBytes;
  48635. var stringToPDFString = sharedUtil.stringToPDFString;
  48636. var warn = sharedUtil.warn;
  48637. var isSpace = sharedUtil.isSpace;
  48638. var Dict = corePrimitives.Dict;
  48639. var isDict = corePrimitives.isDict;
  48640. var isName = corePrimitives.isName;
  48641. var isStream = corePrimitives.isStream;
  48642. var NullStream = coreStream.NullStream;
  48643. var Stream = coreStream.Stream;
  48644. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  48645. var Catalog = coreObj.Catalog;
  48646. var ObjectLoader = coreObj.ObjectLoader;
  48647. var XRef = coreObj.XRef;
  48648. var Linearization = coreParser.Linearization;
  48649. var calculateMD5 = coreCrypto.calculateMD5;
  48650. var OperatorList = coreEvaluator.OperatorList;
  48651. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  48652. var Annotation = coreAnnotation.Annotation;
  48653. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  48654. var Page = function PageClosure() {
  48655. var DEFAULT_USER_UNIT = 1.0;
  48656. var LETTER_SIZE_MEDIABOX = [
  48657. 0,
  48658. 0,
  48659. 612,
  48660. 792
  48661. ];
  48662. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  48663. this.pdfManager = pdfManager;
  48664. this.pageIndex = pageIndex;
  48665. this.pageDict = pageDict;
  48666. this.xref = xref;
  48667. this.ref = ref;
  48668. this.fontCache = fontCache;
  48669. this.evaluatorOptions = pdfManager.evaluatorOptions;
  48670. this.resourcesPromise = null;
  48671. var uniquePrefix = 'p' + this.pageIndex + '_';
  48672. var idCounters = { obj: 0 };
  48673. this.idFactory = {
  48674. createObjId: function () {
  48675. return uniquePrefix + ++idCounters.obj;
  48676. }
  48677. };
  48678. }
  48679. Page.prototype = {
  48680. getPageProp: function Page_getPageProp(key) {
  48681. return this.pageDict.get(key);
  48682. },
  48683. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  48684. var dict = this.pageDict, valueArray = null, loopCount = 0;
  48685. var MAX_LOOP_COUNT = 100;
  48686. getArray = getArray || false;
  48687. while (dict) {
  48688. var value = getArray ? dict.getArray(key) : dict.get(key);
  48689. if (value) {
  48690. if (!valueArray) {
  48691. valueArray = [];
  48692. }
  48693. valueArray.push(value);
  48694. }
  48695. if (++loopCount > MAX_LOOP_COUNT) {
  48696. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  48697. break;
  48698. }
  48699. dict = dict.get('Parent');
  48700. }
  48701. if (!valueArray) {
  48702. return Dict.empty;
  48703. }
  48704. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  48705. return valueArray[0];
  48706. }
  48707. return Dict.merge(this.xref, valueArray);
  48708. },
  48709. get content() {
  48710. return this.getPageProp('Contents');
  48711. },
  48712. get resources() {
  48713. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  48714. },
  48715. get mediaBox() {
  48716. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  48717. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  48718. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  48719. }
  48720. return shadow(this, 'mediaBox', mediaBox);
  48721. },
  48722. get cropBox() {
  48723. var cropBox = this.getInheritedPageProp('CropBox', true);
  48724. if (!isArray(cropBox) || cropBox.length !== 4) {
  48725. return shadow(this, 'cropBox', this.mediaBox);
  48726. }
  48727. return shadow(this, 'cropBox', cropBox);
  48728. },
  48729. get userUnit() {
  48730. var obj = this.getPageProp('UserUnit');
  48731. if (!isNum(obj) || obj <= 0) {
  48732. obj = DEFAULT_USER_UNIT;
  48733. }
  48734. return shadow(this, 'userUnit', obj);
  48735. },
  48736. get view() {
  48737. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  48738. if (mediaBox === cropBox) {
  48739. return shadow(this, 'view', mediaBox);
  48740. }
  48741. var intersection = Util.intersect(cropBox, mediaBox);
  48742. return shadow(this, 'view', intersection || mediaBox);
  48743. },
  48744. get rotate() {
  48745. var rotate = this.getInheritedPageProp('Rotate') || 0;
  48746. if (rotate % 90 !== 0) {
  48747. rotate = 0;
  48748. } else if (rotate >= 360) {
  48749. rotate = rotate % 360;
  48750. } else if (rotate < 0) {
  48751. rotate = (rotate % 360 + 360) % 360;
  48752. }
  48753. return shadow(this, 'rotate', rotate);
  48754. },
  48755. getContentStream: function Page_getContentStream() {
  48756. var content = this.content;
  48757. var stream;
  48758. if (isArray(content)) {
  48759. var xref = this.xref;
  48760. var i, n = content.length;
  48761. var streams = [];
  48762. for (i = 0; i < n; ++i) {
  48763. streams.push(xref.fetchIfRef(content[i]));
  48764. }
  48765. stream = new StreamsSequenceStream(streams);
  48766. } else if (isStream(content)) {
  48767. stream = content;
  48768. } else {
  48769. stream = new NullStream();
  48770. }
  48771. return stream;
  48772. },
  48773. loadResources: function Page_loadResources(keys) {
  48774. if (!this.resourcesPromise) {
  48775. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  48776. }
  48777. return this.resourcesPromise.then(function resourceSuccess() {
  48778. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  48779. return objectLoader.load();
  48780. }.bind(this));
  48781. },
  48782. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  48783. var self = this;
  48784. var pdfManager = this.pdfManager;
  48785. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  48786. var resourcesPromise = this.loadResources([
  48787. 'ExtGState',
  48788. 'ColorSpace',
  48789. 'Pattern',
  48790. 'Shading',
  48791. 'XObject',
  48792. 'Font'
  48793. ]);
  48794. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.idFactory, this.fontCache, this.evaluatorOptions);
  48795. var dataPromises = Promise.all([
  48796. contentStreamPromise,
  48797. resourcesPromise
  48798. ]);
  48799. var pageListPromise = dataPromises.then(function (data) {
  48800. var contentStream = data[0];
  48801. var opList = new OperatorList(intent, handler, self.pageIndex);
  48802. handler.send('StartRenderPage', {
  48803. transparency: partialEvaluator.hasBlendModes(self.resources),
  48804. pageIndex: self.pageIndex,
  48805. intent: intent
  48806. });
  48807. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  48808. return opList;
  48809. });
  48810. });
  48811. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  48812. return Promise.all([
  48813. pageListPromise,
  48814. annotationsPromise
  48815. ]).then(function (datas) {
  48816. var pageOpList = datas[0];
  48817. var annotations = datas[1];
  48818. if (annotations.length === 0) {
  48819. pageOpList.flush(true);
  48820. return pageOpList;
  48821. }
  48822. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  48823. return annotationsReadyPromise.then(function () {
  48824. pageOpList.flush(true);
  48825. return pageOpList;
  48826. });
  48827. });
  48828. },
  48829. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  48830. var handler = {
  48831. on: function nullHandlerOn() {
  48832. },
  48833. send: function nullHandlerSend() {
  48834. }
  48835. };
  48836. var self = this;
  48837. var pdfManager = this.pdfManager;
  48838. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  48839. var resourcesPromise = this.loadResources([
  48840. 'ExtGState',
  48841. 'XObject',
  48842. 'Font'
  48843. ]);
  48844. var dataPromises = Promise.all([
  48845. contentStreamPromise,
  48846. resourcesPromise
  48847. ]);
  48848. return dataPromises.then(function (data) {
  48849. var contentStream = data[0];
  48850. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.idFactory, self.fontCache, self.evaluatorOptions);
  48851. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  48852. });
  48853. },
  48854. getAnnotationsData: function Page_getAnnotationsData(intent) {
  48855. var annotations = this.annotations;
  48856. var annotationsData = [];
  48857. for (var i = 0, n = annotations.length; i < n; ++i) {
  48858. if (intent) {
  48859. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  48860. continue;
  48861. }
  48862. }
  48863. annotationsData.push(annotations[i].data);
  48864. }
  48865. return annotationsData;
  48866. },
  48867. get annotations() {
  48868. var annotations = [];
  48869. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  48870. var annotationFactory = new AnnotationFactory();
  48871. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  48872. var annotationRef = annotationRefs[i];
  48873. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.idFactory);
  48874. if (annotation) {
  48875. annotations.push(annotation);
  48876. }
  48877. }
  48878. return shadow(this, 'annotations', annotations);
  48879. }
  48880. };
  48881. return Page;
  48882. }();
  48883. var PDFDocument = function PDFDocumentClosure() {
  48884. var FINGERPRINT_FIRST_BYTES = 1024;
  48885. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  48886. function PDFDocument(pdfManager, arg) {
  48887. var stream;
  48888. if (isStream(arg)) {
  48889. stream = arg;
  48890. } else if (isArrayBuffer(arg)) {
  48891. stream = new Stream(arg);
  48892. } else {
  48893. error('PDFDocument: Unknown argument type');
  48894. }
  48895. assert(stream.length > 0, 'stream must have data');
  48896. this.pdfManager = pdfManager;
  48897. this.stream = stream;
  48898. this.xref = new XRef(stream, pdfManager);
  48899. }
  48900. function find(stream, needle, limit, backwards) {
  48901. var pos = stream.pos;
  48902. var end = stream.end;
  48903. var strBuf = [];
  48904. if (pos + limit > end) {
  48905. limit = end - pos;
  48906. }
  48907. for (var n = 0; n < limit; ++n) {
  48908. strBuf.push(String.fromCharCode(stream.getByte()));
  48909. }
  48910. var str = strBuf.join('');
  48911. stream.pos = pos;
  48912. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  48913. if (index === -1) {
  48914. return false;
  48915. }
  48916. stream.pos += index;
  48917. return true;
  48918. }
  48919. var DocumentInfoValidators = {
  48920. get entries() {
  48921. return shadow(this, 'entries', {
  48922. Title: isString,
  48923. Author: isString,
  48924. Subject: isString,
  48925. Keywords: isString,
  48926. Creator: isString,
  48927. Producer: isString,
  48928. CreationDate: isString,
  48929. ModDate: isString,
  48930. Trapped: isName
  48931. });
  48932. }
  48933. };
  48934. PDFDocument.prototype = {
  48935. parse: function PDFDocument_parse(recoveryMode) {
  48936. this.setup(recoveryMode);
  48937. var version = this.catalog.catDict.get('Version');
  48938. if (isName(version)) {
  48939. this.pdfFormatVersion = version.name;
  48940. }
  48941. try {
  48942. this.acroForm = this.catalog.catDict.get('AcroForm');
  48943. if (this.acroForm) {
  48944. this.xfa = this.acroForm.get('XFA');
  48945. var fields = this.acroForm.get('Fields');
  48946. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  48947. this.acroForm = null;
  48948. }
  48949. }
  48950. } catch (ex) {
  48951. info('Something wrong with AcroForm entry');
  48952. this.acroForm = null;
  48953. }
  48954. },
  48955. get linearization() {
  48956. var linearization = null;
  48957. if (this.stream.length) {
  48958. try {
  48959. linearization = Linearization.create(this.stream);
  48960. } catch (err) {
  48961. if (err instanceof MissingDataException) {
  48962. throw err;
  48963. }
  48964. info(err);
  48965. }
  48966. }
  48967. return shadow(this, 'linearization', linearization);
  48968. },
  48969. get startXRef() {
  48970. var stream = this.stream;
  48971. var startXRef = 0;
  48972. var linearization = this.linearization;
  48973. if (linearization) {
  48974. stream.reset();
  48975. if (find(stream, 'endobj', 1024)) {
  48976. startXRef = stream.pos + 6;
  48977. }
  48978. } else {
  48979. var step = 1024;
  48980. var found = false, pos = stream.end;
  48981. while (!found && pos > 0) {
  48982. pos -= step - 'startxref'.length;
  48983. if (pos < 0) {
  48984. pos = 0;
  48985. }
  48986. stream.pos = pos;
  48987. found = find(stream, 'startxref', step, true);
  48988. }
  48989. if (found) {
  48990. stream.skip(9);
  48991. var ch;
  48992. do {
  48993. ch = stream.getByte();
  48994. } while (isSpace(ch));
  48995. var str = '';
  48996. while (ch >= 0x20 && ch <= 0x39) {
  48997. str += String.fromCharCode(ch);
  48998. ch = stream.getByte();
  48999. }
  49000. startXRef = parseInt(str, 10);
  49001. if (isNaN(startXRef)) {
  49002. startXRef = 0;
  49003. }
  49004. }
  49005. }
  49006. return shadow(this, 'startXRef', startXRef);
  49007. },
  49008. get mainXRefEntriesOffset() {
  49009. var mainXRefEntriesOffset = 0;
  49010. var linearization = this.linearization;
  49011. if (linearization) {
  49012. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  49013. }
  49014. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  49015. },
  49016. checkHeader: function PDFDocument_checkHeader() {
  49017. var stream = this.stream;
  49018. stream.reset();
  49019. if (find(stream, '%PDF-', 1024)) {
  49020. stream.moveStart();
  49021. var MAX_VERSION_LENGTH = 12;
  49022. var version = '', ch;
  49023. while ((ch = stream.getByte()) > 0x20) {
  49024. if (version.length >= MAX_VERSION_LENGTH) {
  49025. break;
  49026. }
  49027. version += String.fromCharCode(ch);
  49028. }
  49029. if (!this.pdfFormatVersion) {
  49030. this.pdfFormatVersion = version.substring(5);
  49031. }
  49032. return;
  49033. }
  49034. },
  49035. parseStartXRef: function PDFDocument_parseStartXRef() {
  49036. var startXRef = this.startXRef;
  49037. this.xref.setStartXRef(startXRef);
  49038. },
  49039. setup: function PDFDocument_setup(recoveryMode) {
  49040. this.xref.parse(recoveryMode);
  49041. var self = this;
  49042. var pageFactory = {
  49043. createPage: function (pageIndex, dict, ref, fontCache) {
  49044. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  49045. }
  49046. };
  49047. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  49048. },
  49049. get numPages() {
  49050. var linearization = this.linearization;
  49051. var num = linearization ? linearization.numPages : this.catalog.numPages;
  49052. return shadow(this, 'numPages', num);
  49053. },
  49054. get documentInfo() {
  49055. var docInfo = {
  49056. PDFFormatVersion: this.pdfFormatVersion,
  49057. IsAcroFormPresent: !!this.acroForm,
  49058. IsXFAPresent: !!this.xfa
  49059. };
  49060. var infoDict;
  49061. try {
  49062. infoDict = this.xref.trailer.get('Info');
  49063. } catch (err) {
  49064. info('The document information dictionary is invalid.');
  49065. }
  49066. if (infoDict) {
  49067. var validEntries = DocumentInfoValidators.entries;
  49068. for (var key in validEntries) {
  49069. if (infoDict.has(key)) {
  49070. var value = infoDict.get(key);
  49071. if (validEntries[key](value)) {
  49072. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  49073. } else {
  49074. info('Bad value in document info for "' + key + '"');
  49075. }
  49076. }
  49077. }
  49078. }
  49079. return shadow(this, 'documentInfo', docInfo);
  49080. },
  49081. get fingerprint() {
  49082. var xref = this.xref, hash, fileID = '';
  49083. var idArray = xref.trailer.get('ID');
  49084. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  49085. hash = stringToBytes(idArray[0]);
  49086. } else {
  49087. if (this.stream.ensureRange) {
  49088. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  49089. }
  49090. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  49091. }
  49092. for (var i = 0, n = hash.length; i < n; i++) {
  49093. var hex = hash[i].toString(16);
  49094. fileID += hex.length === 1 ? '0' + hex : hex;
  49095. }
  49096. return shadow(this, 'fingerprint', fileID);
  49097. },
  49098. getPage: function PDFDocument_getPage(pageIndex) {
  49099. return this.catalog.getPage(pageIndex);
  49100. },
  49101. cleanup: function PDFDocument_cleanup() {
  49102. return this.catalog.cleanup();
  49103. }
  49104. };
  49105. return PDFDocument;
  49106. }();
  49107. exports.Page = Page;
  49108. exports.PDFDocument = PDFDocument;
  49109. }));
  49110. (function (root, factory) {
  49111. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  49112. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  49113. var warn = sharedUtil.warn;
  49114. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  49115. var shadow = sharedUtil.shadow;
  49116. var NotImplementedException = sharedUtil.NotImplementedException;
  49117. var MissingDataException = sharedUtil.MissingDataException;
  49118. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49119. var Util = sharedUtil.Util;
  49120. var Stream = coreStream.Stream;
  49121. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  49122. var PDFDocument = coreDocument.PDFDocument;
  49123. var BasePdfManager = function BasePdfManagerClosure() {
  49124. function BasePdfManager() {
  49125. throw new Error('Cannot initialize BaseManagerManager');
  49126. }
  49127. BasePdfManager.prototype = {
  49128. get docId() {
  49129. return this._docId;
  49130. },
  49131. get password() {
  49132. return this._password;
  49133. },
  49134. get docBaseUrl() {
  49135. var docBaseUrl = null;
  49136. if (this._docBaseUrl) {
  49137. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  49138. if (absoluteUrl) {
  49139. docBaseUrl = absoluteUrl.href;
  49140. } else {
  49141. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  49142. }
  49143. }
  49144. return shadow(this, 'docBaseUrl', docBaseUrl);
  49145. },
  49146. onLoadedStream: function BasePdfManager_onLoadedStream() {
  49147. throw new NotImplementedException();
  49148. },
  49149. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  49150. return this.ensure(this.pdfDocument, prop, args);
  49151. },
  49152. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  49153. return this.ensure(this.pdfDocument.xref, prop, args);
  49154. },
  49155. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  49156. return this.ensure(this.pdfDocument.catalog, prop, args);
  49157. },
  49158. getPage: function BasePdfManager_getPage(pageIndex) {
  49159. return this.pdfDocument.getPage(pageIndex);
  49160. },
  49161. cleanup: function BasePdfManager_cleanup() {
  49162. return this.pdfDocument.cleanup();
  49163. },
  49164. ensure: function BasePdfManager_ensure(obj, prop, args) {
  49165. return new NotImplementedException();
  49166. },
  49167. requestRange: function BasePdfManager_requestRange(begin, end) {
  49168. return new NotImplementedException();
  49169. },
  49170. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  49171. return new NotImplementedException();
  49172. },
  49173. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  49174. return new NotImplementedException();
  49175. },
  49176. updatePassword: function BasePdfManager_updatePassword(password) {
  49177. this._password = password;
  49178. },
  49179. terminate: function BasePdfManager_terminate() {
  49180. return new NotImplementedException();
  49181. }
  49182. };
  49183. return BasePdfManager;
  49184. }();
  49185. var LocalPdfManager = function LocalPdfManagerClosure() {
  49186. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  49187. this._docId = docId;
  49188. this._password = password;
  49189. this._docBaseUrl = docBaseUrl;
  49190. this.evaluatorOptions = evaluatorOptions;
  49191. var stream = new Stream(data);
  49192. this.pdfDocument = new PDFDocument(this, stream);
  49193. this._loadedStreamCapability = createPromiseCapability();
  49194. this._loadedStreamCapability.resolve(stream);
  49195. }
  49196. Util.inherit(LocalPdfManager, BasePdfManager, {
  49197. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  49198. return new Promise(function (resolve, reject) {
  49199. try {
  49200. var value = obj[prop];
  49201. var result;
  49202. if (typeof value === 'function') {
  49203. result = value.apply(obj, args);
  49204. } else {
  49205. result = value;
  49206. }
  49207. resolve(result);
  49208. } catch (e) {
  49209. reject(e);
  49210. }
  49211. });
  49212. },
  49213. requestRange: function LocalPdfManager_requestRange(begin, end) {
  49214. return Promise.resolve();
  49215. },
  49216. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  49217. },
  49218. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  49219. return this._loadedStreamCapability.promise;
  49220. },
  49221. terminate: function LocalPdfManager_terminate() {
  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._password = args.password;
  49230. this._docBaseUrl = docBaseUrl;
  49231. this.msgHandler = args.msgHandler;
  49232. this.evaluatorOptions = evaluatorOptions;
  49233. var params = {
  49234. msgHandler: args.msgHandler,
  49235. url: args.url,
  49236. length: args.length,
  49237. disableAutoFetch: args.disableAutoFetch,
  49238. rangeChunkSize: args.rangeChunkSize
  49239. };
  49240. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  49241. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream());
  49242. }
  49243. Util.inherit(NetworkPdfManager, BasePdfManager, {
  49244. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  49245. var pdfManager = this;
  49246. return new Promise(function (resolve, reject) {
  49247. function ensureHelper() {
  49248. try {
  49249. var result;
  49250. var value = obj[prop];
  49251. if (typeof value === 'function') {
  49252. result = value.apply(obj, args);
  49253. } else {
  49254. result = value;
  49255. }
  49256. resolve(result);
  49257. } catch (e) {
  49258. if (!(e instanceof MissingDataException)) {
  49259. reject(e);
  49260. return;
  49261. }
  49262. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  49263. }
  49264. }
  49265. ensureHelper();
  49266. });
  49267. },
  49268. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  49269. return this.streamManager.requestRange(begin, end);
  49270. },
  49271. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  49272. this.streamManager.requestAllChunks();
  49273. },
  49274. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  49275. this.streamManager.onReceiveData({ chunk: chunk });
  49276. },
  49277. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  49278. return this.streamManager.onLoadedStream();
  49279. },
  49280. terminate: function NetworkPdfManager_terminate() {
  49281. this.streamManager.abort();
  49282. }
  49283. });
  49284. return NetworkPdfManager;
  49285. }();
  49286. exports.LocalPdfManager = LocalPdfManager;
  49287. exports.NetworkPdfManager = NetworkPdfManager;
  49288. }));
  49289. (function (root, factory) {
  49290. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  49291. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  49292. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  49293. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49294. var MessageHandler = sharedUtil.MessageHandler;
  49295. var MissingPDFException = sharedUtil.MissingPDFException;
  49296. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  49297. var PasswordException = sharedUtil.PasswordException;
  49298. var PasswordResponses = sharedUtil.PasswordResponses;
  49299. var UnknownErrorException = sharedUtil.UnknownErrorException;
  49300. var XRefParseException = sharedUtil.XRefParseException;
  49301. var arrayByteLength = sharedUtil.arrayByteLength;
  49302. var arraysToBytes = sharedUtil.arraysToBytes;
  49303. var assert = sharedUtil.assert;
  49304. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49305. var error = sharedUtil.error;
  49306. var info = sharedUtil.info;
  49307. var warn = sharedUtil.warn;
  49308. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  49309. var Ref = corePrimitives.Ref;
  49310. var LocalPdfManager = corePdfManager.LocalPdfManager;
  49311. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  49312. var globalScope = sharedUtil.globalScope;
  49313. var WorkerTask = function WorkerTaskClosure() {
  49314. function WorkerTask(name) {
  49315. this.name = name;
  49316. this.terminated = false;
  49317. this._capability = createPromiseCapability();
  49318. }
  49319. WorkerTask.prototype = {
  49320. get finished() {
  49321. return this._capability.promise;
  49322. },
  49323. finish: function () {
  49324. this._capability.resolve();
  49325. },
  49326. terminate: function () {
  49327. this.terminated = true;
  49328. },
  49329. ensureNotTerminated: function () {
  49330. if (this.terminated) {
  49331. throw new Error('Worker task was terminated');
  49332. }
  49333. }
  49334. };
  49335. return WorkerTask;
  49336. }();
  49337. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  49338. function PDFWorkerStream(params, msgHandler) {
  49339. this._queuedChunks = [];
  49340. var initialData = params.initialData;
  49341. if (initialData && initialData.length > 0) {
  49342. this._queuedChunks.push(initialData);
  49343. }
  49344. this._msgHandler = msgHandler;
  49345. this._isRangeSupported = !params.disableRange;
  49346. this._isStreamingSupported = !params.disableStream;
  49347. this._contentLength = params.length;
  49348. this._fullRequestReader = null;
  49349. this._rangeReaders = [];
  49350. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  49351. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  49352. }
  49353. PDFWorkerStream.prototype = {
  49354. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  49355. if (args.begin === undefined) {
  49356. if (this._fullRequestReader) {
  49357. this._fullRequestReader._enqueue(args.chunk);
  49358. } else {
  49359. this._queuedChunks.push(args.chunk);
  49360. }
  49361. } else {
  49362. var found = this._rangeReaders.some(function (rangeReader) {
  49363. if (rangeReader._begin !== args.begin) {
  49364. return false;
  49365. }
  49366. rangeReader._enqueue(args.chunk);
  49367. return true;
  49368. });
  49369. assert(found);
  49370. }
  49371. },
  49372. _onProgress: function PDFWorkerStream_onProgress(evt) {
  49373. if (this._rangeReaders.length > 0) {
  49374. var firstReader = this._rangeReaders[0];
  49375. if (firstReader.onProgress) {
  49376. firstReader.onProgress({ loaded: evt.loaded });
  49377. }
  49378. }
  49379. },
  49380. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  49381. var i = this._rangeReaders.indexOf(reader);
  49382. if (i >= 0) {
  49383. this._rangeReaders.splice(i, 1);
  49384. }
  49385. },
  49386. getFullReader: function PDFWorkerStream_getFullReader() {
  49387. assert(!this._fullRequestReader);
  49388. var queuedChunks = this._queuedChunks;
  49389. this._queuedChunks = null;
  49390. return new PDFWorkerStreamReader(this, queuedChunks);
  49391. },
  49392. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  49393. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  49394. this._msgHandler.send('RequestDataRange', {
  49395. begin: begin,
  49396. end: end
  49397. });
  49398. this._rangeReaders.push(reader);
  49399. return reader;
  49400. },
  49401. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  49402. if (this._fullRequestReader) {
  49403. this._fullRequestReader.cancel(reason);
  49404. }
  49405. var readers = this._rangeReaders.slice(0);
  49406. readers.forEach(function (rangeReader) {
  49407. rangeReader.cancel(reason);
  49408. });
  49409. }
  49410. };
  49411. function PDFWorkerStreamReader(stream, queuedChunks) {
  49412. this._stream = stream;
  49413. this._done = false;
  49414. this._queuedChunks = queuedChunks || [];
  49415. this._requests = [];
  49416. this._headersReady = Promise.resolve();
  49417. stream._fullRequestReader = this;
  49418. this.onProgress = null;
  49419. }
  49420. PDFWorkerStreamReader.prototype = {
  49421. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  49422. if (this._done) {
  49423. return;
  49424. }
  49425. if (this._requests.length > 0) {
  49426. var requestCapability = this._requests.shift();
  49427. requestCapability.resolve({
  49428. value: chunk,
  49429. done: false
  49430. });
  49431. return;
  49432. }
  49433. this._queuedChunks.push(chunk);
  49434. },
  49435. get headersReady() {
  49436. return this._headersReady;
  49437. },
  49438. get isRangeSupported() {
  49439. return this._stream._isRangeSupported;
  49440. },
  49441. get isStreamingSupported() {
  49442. return this._stream._isStreamingSupported;
  49443. },
  49444. get contentLength() {
  49445. return this._stream._contentLength;
  49446. },
  49447. read: function PDFWorkerStreamReader_read() {
  49448. if (this._queuedChunks.length > 0) {
  49449. var chunk = this._queuedChunks.shift();
  49450. return Promise.resolve({
  49451. value: chunk,
  49452. done: false
  49453. });
  49454. }
  49455. if (this._done) {
  49456. return Promise.resolve({
  49457. value: undefined,
  49458. done: true
  49459. });
  49460. }
  49461. var requestCapability = createPromiseCapability();
  49462. this._requests.push(requestCapability);
  49463. return requestCapability.promise;
  49464. },
  49465. cancel: function PDFWorkerStreamReader_cancel(reason) {
  49466. this._done = true;
  49467. this._requests.forEach(function (requestCapability) {
  49468. requestCapability.resolve({
  49469. value: undefined,
  49470. done: true
  49471. });
  49472. });
  49473. this._requests = [];
  49474. }
  49475. };
  49476. function PDFWorkerStreamRangeReader(stream, begin, end) {
  49477. this._stream = stream;
  49478. this._begin = begin;
  49479. this._end = end;
  49480. this._queuedChunk = null;
  49481. this._requests = [];
  49482. this._done = false;
  49483. this.onProgress = null;
  49484. }
  49485. PDFWorkerStreamRangeReader.prototype = {
  49486. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  49487. if (this._done) {
  49488. return;
  49489. }
  49490. if (this._requests.length === 0) {
  49491. this._queuedChunk = chunk;
  49492. } else {
  49493. var requestsCapability = this._requests.shift();
  49494. requestsCapability.resolve({
  49495. value: chunk,
  49496. done: false
  49497. });
  49498. this._requests.forEach(function (requestCapability) {
  49499. requestCapability.resolve({
  49500. value: undefined,
  49501. done: true
  49502. });
  49503. });
  49504. this._requests = [];
  49505. }
  49506. this._done = true;
  49507. this._stream._removeRangeReader(this);
  49508. },
  49509. get isStreamingSupported() {
  49510. return false;
  49511. },
  49512. read: function PDFWorkerStreamRangeReader_read() {
  49513. if (this._queuedChunk) {
  49514. return Promise.resolve({
  49515. value: this._queuedChunk,
  49516. done: false
  49517. });
  49518. }
  49519. if (this._done) {
  49520. return Promise.resolve({
  49521. value: undefined,
  49522. done: true
  49523. });
  49524. }
  49525. var requestCapability = createPromiseCapability();
  49526. this._requests.push(requestCapability);
  49527. return requestCapability.promise;
  49528. },
  49529. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  49530. this._done = true;
  49531. this._requests.forEach(function (requestCapability) {
  49532. requestCapability.resolve({
  49533. value: undefined,
  49534. done: true
  49535. });
  49536. });
  49537. this._requests = [];
  49538. this._stream._removeRangeReader(this);
  49539. }
  49540. };
  49541. return PDFWorkerStream;
  49542. }();
  49543. var PDFNetworkStream;
  49544. function setPDFNetworkStreamClass(cls) {
  49545. PDFNetworkStream = cls;
  49546. }
  49547. var WorkerMessageHandler = {
  49548. setup: function wphSetup(handler, port) {
  49549. var testMessageProcessed = false;
  49550. handler.on('test', function wphSetupTest(data) {
  49551. if (testMessageProcessed) {
  49552. return;
  49553. }
  49554. testMessageProcessed = true;
  49555. if (!(data instanceof Uint8Array)) {
  49556. handler.send('test', 'main', false);
  49557. return;
  49558. }
  49559. var supportTransfers = data[0] === 255;
  49560. handler.postMessageTransfers = supportTransfers;
  49561. var xhr = new XMLHttpRequest();
  49562. var responseExists = 'response' in xhr;
  49563. try {
  49564. var dummy = xhr.responseType;
  49565. } catch (e) {
  49566. responseExists = false;
  49567. }
  49568. if (!responseExists) {
  49569. handler.send('test', false);
  49570. return;
  49571. }
  49572. handler.send('test', {
  49573. supportTypedArray: true,
  49574. supportTransfers: supportTransfers
  49575. });
  49576. });
  49577. handler.on('configure', function wphConfigure(data) {
  49578. setVerbosityLevel(data.verbosity);
  49579. });
  49580. handler.on('GetDocRequest', function wphSetupDoc(data) {
  49581. return WorkerMessageHandler.createDocumentHandler(data, port);
  49582. });
  49583. },
  49584. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  49585. var pdfManager;
  49586. var terminated = false;
  49587. var cancelXHRs = null;
  49588. var WorkerTasks = [];
  49589. var docId = docParams.docId;
  49590. var docBaseUrl = docParams.docBaseUrl;
  49591. var workerHandlerName = docParams.docId + '_worker';
  49592. var handler = new MessageHandler(workerHandlerName, docId, port);
  49593. handler.postMessageTransfers = docParams.postMessageTransfers;
  49594. function ensureNotTerminated() {
  49595. if (terminated) {
  49596. throw new Error('Worker was terminated');
  49597. }
  49598. }
  49599. function startWorkerTask(task) {
  49600. WorkerTasks.push(task);
  49601. }
  49602. function finishWorkerTask(task) {
  49603. task.finish();
  49604. var i = WorkerTasks.indexOf(task);
  49605. WorkerTasks.splice(i, 1);
  49606. }
  49607. function loadDocument(recoveryMode) {
  49608. var loadDocumentCapability = createPromiseCapability();
  49609. var parseSuccess = function parseSuccess() {
  49610. var numPagesPromise = pdfManager.ensureDoc('numPages');
  49611. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  49612. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  49613. Promise.all([
  49614. numPagesPromise,
  49615. fingerprintPromise,
  49616. encryptedPromise
  49617. ]).then(function onDocReady(results) {
  49618. var doc = {
  49619. numPages: results[0],
  49620. fingerprint: results[1],
  49621. encrypted: !!results[2]
  49622. };
  49623. loadDocumentCapability.resolve(doc);
  49624. }, parseFailure);
  49625. };
  49626. var parseFailure = function parseFailure(e) {
  49627. loadDocumentCapability.reject(e);
  49628. };
  49629. pdfManager.ensureDoc('checkHeader', []).then(function () {
  49630. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  49631. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  49632. }, parseFailure);
  49633. }, parseFailure);
  49634. return loadDocumentCapability.promise;
  49635. }
  49636. function getPdfManager(data, evaluatorOptions) {
  49637. var pdfManagerCapability = createPromiseCapability();
  49638. var pdfManager;
  49639. var source = data.source;
  49640. if (source.data) {
  49641. try {
  49642. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  49643. pdfManagerCapability.resolve(pdfManager);
  49644. } catch (ex) {
  49645. pdfManagerCapability.reject(ex);
  49646. }
  49647. return pdfManagerCapability.promise;
  49648. }
  49649. var pdfStream;
  49650. try {
  49651. if (source.chunkedViewerLoading) {
  49652. pdfStream = new PDFWorkerStream(source, handler);
  49653. } else {
  49654. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  49655. pdfStream = new PDFNetworkStream(data);
  49656. }
  49657. } catch (ex) {
  49658. pdfManagerCapability.reject(ex);
  49659. return pdfManagerCapability.promise;
  49660. }
  49661. var fullRequest = pdfStream.getFullReader();
  49662. fullRequest.headersReady.then(function () {
  49663. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  49664. fullRequest.onProgress = function (evt) {
  49665. handler.send('DocProgress', {
  49666. loaded: evt.loaded,
  49667. total: evt.total
  49668. });
  49669. };
  49670. }
  49671. if (!fullRequest.isRangeSupported) {
  49672. return;
  49673. }
  49674. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  49675. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  49676. msgHandler: handler,
  49677. url: source.url,
  49678. password: source.password,
  49679. length: fullRequest.contentLength,
  49680. disableAutoFetch: disableAutoFetch,
  49681. rangeChunkSize: source.rangeChunkSize
  49682. }, evaluatorOptions, docBaseUrl);
  49683. pdfManagerCapability.resolve(pdfManager);
  49684. cancelXHRs = null;
  49685. }).catch(function (reason) {
  49686. pdfManagerCapability.reject(reason);
  49687. cancelXHRs = null;
  49688. });
  49689. var cachedChunks = [], loaded = 0;
  49690. var flushChunks = function () {
  49691. var pdfFile = arraysToBytes(cachedChunks);
  49692. if (source.length && pdfFile.length !== source.length) {
  49693. warn('reported HTTP length is different from actual');
  49694. }
  49695. try {
  49696. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  49697. pdfManagerCapability.resolve(pdfManager);
  49698. } catch (ex) {
  49699. pdfManagerCapability.reject(ex);
  49700. }
  49701. cachedChunks = [];
  49702. };
  49703. var readPromise = new Promise(function (resolve, reject) {
  49704. var readChunk = function (chunk) {
  49705. try {
  49706. ensureNotTerminated();
  49707. if (chunk.done) {
  49708. if (!pdfManager) {
  49709. flushChunks();
  49710. }
  49711. cancelXHRs = null;
  49712. return;
  49713. }
  49714. var data = chunk.value;
  49715. loaded += arrayByteLength(data);
  49716. if (!fullRequest.isStreamingSupported) {
  49717. handler.send('DocProgress', {
  49718. loaded: loaded,
  49719. total: Math.max(loaded, fullRequest.contentLength || 0)
  49720. });
  49721. }
  49722. if (pdfManager) {
  49723. pdfManager.sendProgressiveData(data);
  49724. } else {
  49725. cachedChunks.push(data);
  49726. }
  49727. fullRequest.read().then(readChunk, reject);
  49728. } catch (e) {
  49729. reject(e);
  49730. }
  49731. };
  49732. fullRequest.read().then(readChunk, reject);
  49733. });
  49734. readPromise.catch(function (e) {
  49735. pdfManagerCapability.reject(e);
  49736. cancelXHRs = null;
  49737. });
  49738. cancelXHRs = function () {
  49739. pdfStream.cancelAllRequests('abort');
  49740. };
  49741. return pdfManagerCapability.promise;
  49742. }
  49743. function setupDoc(data) {
  49744. function onSuccess(doc) {
  49745. ensureNotTerminated();
  49746. handler.send('GetDoc', { pdfInfo: doc });
  49747. }
  49748. function onFailure(e) {
  49749. if (e instanceof PasswordException) {
  49750. var task = new WorkerTask('PasswordException: response ' + e.code);
  49751. startWorkerTask(task);
  49752. handler.sendWithPromise('PasswordRequest', e).then(function (data) {
  49753. finishWorkerTask(task);
  49754. pdfManager.updatePassword(data.password);
  49755. pdfManagerReady();
  49756. }).catch(function (ex) {
  49757. finishWorkerTask(task);
  49758. handler.send('PasswordException', ex);
  49759. }.bind(null, e));
  49760. } else if (e instanceof InvalidPDFException) {
  49761. handler.send('InvalidPDF', e);
  49762. } else if (e instanceof MissingPDFException) {
  49763. handler.send('MissingPDF', e);
  49764. } else if (e instanceof UnexpectedResponseException) {
  49765. handler.send('UnexpectedResponse', e);
  49766. } else {
  49767. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  49768. }
  49769. }
  49770. function pdfManagerReady() {
  49771. ensureNotTerminated();
  49772. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  49773. ensureNotTerminated();
  49774. if (!(ex instanceof XRefParseException)) {
  49775. onFailure(ex);
  49776. return;
  49777. }
  49778. pdfManager.requestLoadedStream();
  49779. pdfManager.onLoadedStream().then(function () {
  49780. ensureNotTerminated();
  49781. loadDocument(true).then(onSuccess, onFailure);
  49782. });
  49783. }, onFailure);
  49784. }
  49785. ensureNotTerminated();
  49786. var cMapOptions = {
  49787. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  49788. packed: data.cMapPacked === true
  49789. };
  49790. var evaluatorOptions = {
  49791. forceDataSchema: data.disableCreateObjectURL,
  49792. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  49793. disableFontFace: data.disableFontFace,
  49794. cMapOptions: cMapOptions
  49795. };
  49796. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  49797. if (terminated) {
  49798. newPdfManager.terminate();
  49799. throw new Error('Worker was terminated');
  49800. }
  49801. pdfManager = newPdfManager;
  49802. handler.send('PDFManagerReady', null);
  49803. pdfManager.onLoadedStream().then(function (stream) {
  49804. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  49805. });
  49806. }).then(pdfManagerReady, onFailure);
  49807. }
  49808. handler.on('GetPage', function wphSetupGetPage(data) {
  49809. return pdfManager.getPage(data.pageIndex).then(function (page) {
  49810. var rotatePromise = pdfManager.ensure(page, 'rotate');
  49811. var refPromise = pdfManager.ensure(page, 'ref');
  49812. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  49813. var viewPromise = pdfManager.ensure(page, 'view');
  49814. return Promise.all([
  49815. rotatePromise,
  49816. refPromise,
  49817. userUnitPromise,
  49818. viewPromise
  49819. ]).then(function (results) {
  49820. return {
  49821. rotate: results[0],
  49822. ref: results[1],
  49823. userUnit: results[2],
  49824. view: results[3]
  49825. };
  49826. });
  49827. });
  49828. });
  49829. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  49830. var ref = new Ref(data.ref.num, data.ref.gen);
  49831. var catalog = pdfManager.pdfDocument.catalog;
  49832. return catalog.getPageIndex(ref);
  49833. });
  49834. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  49835. return pdfManager.ensureCatalog('destinations');
  49836. });
  49837. handler.on('GetDestination', function wphSetupGetDestination(data) {
  49838. return pdfManager.ensureCatalog('getDestination', [data.id]);
  49839. });
  49840. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  49841. return pdfManager.ensureCatalog('pageLabels');
  49842. });
  49843. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  49844. return pdfManager.ensureCatalog('attachments');
  49845. });
  49846. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  49847. return pdfManager.ensureCatalog('javaScript');
  49848. });
  49849. handler.on('GetOutline', function wphSetupGetOutline(data) {
  49850. return pdfManager.ensureCatalog('documentOutline');
  49851. });
  49852. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  49853. return Promise.all([
  49854. pdfManager.ensureDoc('documentInfo'),
  49855. pdfManager.ensureCatalog('metadata')
  49856. ]);
  49857. });
  49858. handler.on('GetData', function wphSetupGetData(data) {
  49859. pdfManager.requestLoadedStream();
  49860. return pdfManager.onLoadedStream().then(function (stream) {
  49861. return stream.bytes;
  49862. });
  49863. });
  49864. handler.on('GetStats', function wphSetupGetStats(data) {
  49865. return pdfManager.pdfDocument.xref.stats;
  49866. });
  49867. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  49868. return pdfManager.getPage(data.pageIndex).then(function (page) {
  49869. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  49870. });
  49871. });
  49872. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  49873. var pageIndex = data.pageIndex;
  49874. pdfManager.getPage(pageIndex).then(function (page) {
  49875. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  49876. startWorkerTask(task);
  49877. var pageNum = pageIndex + 1;
  49878. var start = Date.now();
  49879. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  49880. finishWorkerTask(task);
  49881. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  49882. }, function (e) {
  49883. finishWorkerTask(task);
  49884. if (task.terminated) {
  49885. return;
  49886. }
  49887. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  49888. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  49889. var wrappedException;
  49890. if (typeof e === 'string') {
  49891. wrappedException = {
  49892. message: e,
  49893. stack: minimumStackMessage
  49894. };
  49895. } else if (typeof e === 'object') {
  49896. wrappedException = {
  49897. message: e.message || e.toString(),
  49898. stack: e.stack || minimumStackMessage
  49899. };
  49900. } else {
  49901. wrappedException = {
  49902. message: 'Unknown exception type: ' + typeof e,
  49903. stack: minimumStackMessage
  49904. };
  49905. }
  49906. handler.send('PageError', {
  49907. pageNum: pageNum,
  49908. error: wrappedException,
  49909. intent: data.intent
  49910. });
  49911. });
  49912. });
  49913. }, this);
  49914. handler.on('GetTextContent', function wphExtractText(data) {
  49915. var pageIndex = data.pageIndex;
  49916. var normalizeWhitespace = data.normalizeWhitespace;
  49917. var combineTextItems = data.combineTextItems;
  49918. return pdfManager.getPage(pageIndex).then(function (page) {
  49919. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  49920. startWorkerTask(task);
  49921. var pageNum = pageIndex + 1;
  49922. var start = Date.now();
  49923. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  49924. finishWorkerTask(task);
  49925. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  49926. return textContent;
  49927. }, function (reason) {
  49928. finishWorkerTask(task);
  49929. if (task.terminated) {
  49930. return;
  49931. }
  49932. throw reason;
  49933. });
  49934. });
  49935. });
  49936. handler.on('Cleanup', function wphCleanup(data) {
  49937. return pdfManager.cleanup();
  49938. });
  49939. handler.on('Terminate', function wphTerminate(data) {
  49940. terminated = true;
  49941. if (pdfManager) {
  49942. pdfManager.terminate();
  49943. pdfManager = null;
  49944. }
  49945. if (cancelXHRs) {
  49946. cancelXHRs();
  49947. }
  49948. var waitOn = [];
  49949. WorkerTasks.forEach(function (task) {
  49950. waitOn.push(task.finished);
  49951. task.terminate();
  49952. });
  49953. return Promise.all(waitOn).then(function () {
  49954. handler.destroy();
  49955. handler = null;
  49956. });
  49957. });
  49958. handler.on('Ready', function wphReady(data) {
  49959. setupDoc(docParams);
  49960. docParams = null;
  49961. });
  49962. return workerHandlerName;
  49963. }
  49964. };
  49965. function initializeWorker() {
  49966. if (!('console' in globalScope)) {
  49967. var consoleTimer = {};
  49968. var workerConsole = {
  49969. log: function log() {
  49970. var args = Array.prototype.slice.call(arguments);
  49971. globalScope.postMessage({
  49972. targetName: 'main',
  49973. action: 'console_log',
  49974. data: args
  49975. });
  49976. },
  49977. error: function error() {
  49978. var args = Array.prototype.slice.call(arguments);
  49979. globalScope.postMessage({
  49980. targetName: 'main',
  49981. action: 'console_error',
  49982. data: args
  49983. });
  49984. throw 'pdf.js execution error';
  49985. },
  49986. time: function time(name) {
  49987. consoleTimer[name] = Date.now();
  49988. },
  49989. timeEnd: function timeEnd(name) {
  49990. var time = consoleTimer[name];
  49991. if (!time) {
  49992. error('Unknown timer name ' + name);
  49993. }
  49994. this.log('Timer:', name, Date.now() - time);
  49995. }
  49996. };
  49997. globalScope.console = workerConsole;
  49998. }
  49999. var handler = new MessageHandler('worker', 'main', self);
  50000. WorkerMessageHandler.setup(handler, self);
  50001. handler.send('ready', null);
  50002. }
  50003. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  50004. initializeWorker();
  50005. }
  50006. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  50007. exports.WorkerTask = WorkerTask;
  50008. exports.WorkerMessageHandler = WorkerMessageHandler;
  50009. }));
  50010. (function (root, factory) {
  50011. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  50012. }(this, function (exports, sharedUtil, coreWorker) {
  50013. var OK_RESPONSE = 200;
  50014. var PARTIAL_CONTENT_RESPONSE = 206;
  50015. function NetworkManager(url, args) {
  50016. this.url = url;
  50017. args = args || {};
  50018. this.isHttp = /^https?:/i.test(url);
  50019. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  50020. this.withCredentials = args.withCredentials || false;
  50021. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  50022. return new XMLHttpRequest();
  50023. };
  50024. this.currXhrId = 0;
  50025. this.pendingRequests = Object.create(null);
  50026. this.loadedRequests = Object.create(null);
  50027. }
  50028. function getArrayBuffer(xhr) {
  50029. var data = xhr.response;
  50030. if (typeof data !== 'string') {
  50031. return data;
  50032. }
  50033. var length = data.length;
  50034. var array = new Uint8Array(length);
  50035. for (var i = 0; i < length; i++) {
  50036. array[i] = data.charCodeAt(i) & 0xFF;
  50037. }
  50038. return array.buffer;
  50039. }
  50040. var supportsMozChunked = function supportsMozChunkedClosure() {
  50041. try {
  50042. var x = new XMLHttpRequest();
  50043. x.open('GET', 'https://example.com');
  50044. x.responseType = 'moz-chunked-arraybuffer';
  50045. return x.responseType === 'moz-chunked-arraybuffer';
  50046. } catch (e) {
  50047. return false;
  50048. }
  50049. }();
  50050. NetworkManager.prototype = {
  50051. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  50052. var args = {
  50053. begin: begin,
  50054. end: end
  50055. };
  50056. for (var prop in listeners) {
  50057. args[prop] = listeners[prop];
  50058. }
  50059. return this.request(args);
  50060. },
  50061. requestFull: function NetworkManager_requestFull(listeners) {
  50062. return this.request(listeners);
  50063. },
  50064. request: function NetworkManager_request(args) {
  50065. var xhr = this.getXhr();
  50066. var xhrId = this.currXhrId++;
  50067. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  50068. xhr.open('GET', this.url);
  50069. xhr.withCredentials = this.withCredentials;
  50070. for (var property in this.httpHeaders) {
  50071. var value = this.httpHeaders[property];
  50072. if (typeof value === 'undefined') {
  50073. continue;
  50074. }
  50075. xhr.setRequestHeader(property, value);
  50076. }
  50077. if (this.isHttp && 'begin' in args && 'end' in args) {
  50078. var rangeStr = args.begin + '-' + (args.end - 1);
  50079. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  50080. pendingRequest.expectedStatus = 206;
  50081. } else {
  50082. pendingRequest.expectedStatus = 200;
  50083. }
  50084. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  50085. if (useMozChunkedLoading) {
  50086. xhr.responseType = 'moz-chunked-arraybuffer';
  50087. pendingRequest.onProgressiveData = args.onProgressiveData;
  50088. pendingRequest.mozChunked = true;
  50089. } else {
  50090. xhr.responseType = 'arraybuffer';
  50091. }
  50092. if (args.onError) {
  50093. xhr.onerror = function (evt) {
  50094. args.onError(xhr.status);
  50095. };
  50096. }
  50097. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  50098. xhr.onprogress = this.onProgress.bind(this, xhrId);
  50099. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  50100. pendingRequest.onDone = args.onDone;
  50101. pendingRequest.onError = args.onError;
  50102. pendingRequest.onProgress = args.onProgress;
  50103. xhr.send(null);
  50104. return xhrId;
  50105. },
  50106. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  50107. var pendingRequest = this.pendingRequests[xhrId];
  50108. if (!pendingRequest) {
  50109. return;
  50110. }
  50111. if (pendingRequest.mozChunked) {
  50112. var chunk = getArrayBuffer(pendingRequest.xhr);
  50113. pendingRequest.onProgressiveData(chunk);
  50114. }
  50115. var onProgress = pendingRequest.onProgress;
  50116. if (onProgress) {
  50117. onProgress(evt);
  50118. }
  50119. },
  50120. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  50121. var pendingRequest = this.pendingRequests[xhrId];
  50122. if (!pendingRequest) {
  50123. return;
  50124. }
  50125. var xhr = pendingRequest.xhr;
  50126. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  50127. pendingRequest.onHeadersReceived();
  50128. delete pendingRequest.onHeadersReceived;
  50129. }
  50130. if (xhr.readyState !== 4) {
  50131. return;
  50132. }
  50133. if (!(xhrId in this.pendingRequests)) {
  50134. return;
  50135. }
  50136. delete this.pendingRequests[xhrId];
  50137. if (xhr.status === 0 && this.isHttp) {
  50138. if (pendingRequest.onError) {
  50139. pendingRequest.onError(xhr.status);
  50140. }
  50141. return;
  50142. }
  50143. var xhrStatus = xhr.status || OK_RESPONSE;
  50144. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  50145. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  50146. if (pendingRequest.onError) {
  50147. pendingRequest.onError(xhr.status);
  50148. }
  50149. return;
  50150. }
  50151. this.loadedRequests[xhrId] = true;
  50152. var chunk = getArrayBuffer(xhr);
  50153. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  50154. var rangeHeader = xhr.getResponseHeader('Content-Range');
  50155. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  50156. var begin = parseInt(matches[1], 10);
  50157. pendingRequest.onDone({
  50158. begin: begin,
  50159. chunk: chunk
  50160. });
  50161. } else if (pendingRequest.onProgressiveData) {
  50162. pendingRequest.onDone(null);
  50163. } else if (chunk) {
  50164. pendingRequest.onDone({
  50165. begin: 0,
  50166. chunk: chunk
  50167. });
  50168. } else if (pendingRequest.onError) {
  50169. pendingRequest.onError(xhr.status);
  50170. }
  50171. },
  50172. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  50173. for (var xhrId in this.pendingRequests) {
  50174. return true;
  50175. }
  50176. return false;
  50177. },
  50178. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  50179. return this.pendingRequests[xhrId].xhr;
  50180. },
  50181. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  50182. return !!this.pendingRequests[xhrId].onProgressiveData;
  50183. },
  50184. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  50185. return xhrId in this.pendingRequests;
  50186. },
  50187. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  50188. return xhrId in this.loadedRequests;
  50189. },
  50190. abortAllRequests: function NetworkManager_abortAllRequests() {
  50191. for (var xhrId in this.pendingRequests) {
  50192. this.abortRequest(xhrId | 0);
  50193. }
  50194. },
  50195. abortRequest: function NetworkManager_abortRequest(xhrId) {
  50196. var xhr = this.pendingRequests[xhrId].xhr;
  50197. delete this.pendingRequests[xhrId];
  50198. xhr.abort();
  50199. }
  50200. };
  50201. var assert = sharedUtil.assert;
  50202. var createPromiseCapability = sharedUtil.createPromiseCapability;
  50203. var isInt = sharedUtil.isInt;
  50204. var MissingPDFException = sharedUtil.MissingPDFException;
  50205. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  50206. function PDFNetworkStream(options) {
  50207. this._options = options;
  50208. var source = options.source;
  50209. this._manager = new NetworkManager(source.url, {
  50210. httpHeaders: source.httpHeaders,
  50211. withCredentials: source.withCredentials
  50212. });
  50213. this._rangeChunkSize = source.rangeChunkSize;
  50214. this._fullRequestReader = null;
  50215. this._rangeRequestReaders = [];
  50216. }
  50217. PDFNetworkStream.prototype = {
  50218. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  50219. var i = this._rangeRequestReaders.indexOf(reader);
  50220. if (i >= 0) {
  50221. this._rangeRequestReaders.splice(i, 1);
  50222. }
  50223. },
  50224. getFullReader: function PDFNetworkStream_getFullReader() {
  50225. assert(!this._fullRequestReader);
  50226. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  50227. return this._fullRequestReader;
  50228. },
  50229. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  50230. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  50231. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  50232. this._rangeRequestReaders.push(reader);
  50233. return reader;
  50234. },
  50235. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  50236. if (this._fullRequestReader) {
  50237. this._fullRequestReader.cancel(reason);
  50238. }
  50239. var readers = this._rangeRequestReaders.slice(0);
  50240. readers.forEach(function (reader) {
  50241. reader.cancel(reason);
  50242. });
  50243. }
  50244. };
  50245. function PDFNetworkStreamFullRequestReader(manager, options) {
  50246. this._manager = manager;
  50247. var source = options.source;
  50248. var args = {
  50249. onHeadersReceived: this._onHeadersReceived.bind(this),
  50250. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  50251. onDone: this._onDone.bind(this),
  50252. onError: this._onError.bind(this),
  50253. onProgress: this._onProgress.bind(this)
  50254. };
  50255. this._url = source.url;
  50256. this._fullRequestId = manager.requestFull(args);
  50257. this._headersReceivedCapability = createPromiseCapability();
  50258. this._disableRange = options.disableRange || false;
  50259. this._contentLength = source.length;
  50260. this._rangeChunkSize = source.rangeChunkSize;
  50261. if (!this._rangeChunkSize && !this._disableRange) {
  50262. this._disableRange = true;
  50263. }
  50264. this._isStreamingSupported = false;
  50265. this._isRangeSupported = false;
  50266. this._cachedChunks = [];
  50267. this._requests = [];
  50268. this._done = false;
  50269. this._storedError = undefined;
  50270. this.onProgress = null;
  50271. }
  50272. PDFNetworkStreamFullRequestReader.prototype = {
  50273. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  50274. if (this._disableRange) {
  50275. return false;
  50276. }
  50277. var networkManager = this._manager;
  50278. if (!networkManager.isHttp) {
  50279. return false;
  50280. }
  50281. var fullRequestXhrId = this._fullRequestId;
  50282. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  50283. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  50284. return false;
  50285. }
  50286. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  50287. if (contentEncoding !== 'identity') {
  50288. return false;
  50289. }
  50290. var length = fullRequestXhr.getResponseHeader('Content-Length');
  50291. length = parseInt(length, 10);
  50292. if (!isInt(length)) {
  50293. return false;
  50294. }
  50295. this._contentLength = length;
  50296. if (length <= 2 * this._rangeChunkSize) {
  50297. return false;
  50298. }
  50299. return true;
  50300. },
  50301. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  50302. if (this._validateRangeRequestCapabilities()) {
  50303. this._isRangeSupported = true;
  50304. }
  50305. var networkManager = this._manager;
  50306. var fullRequestXhrId = this._fullRequestId;
  50307. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  50308. this._isStreamingSupported = true;
  50309. } else if (this._isRangeSupported) {
  50310. networkManager.abortRequest(fullRequestXhrId);
  50311. }
  50312. this._headersReceivedCapability.resolve();
  50313. },
  50314. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  50315. if (this._requests.length > 0) {
  50316. var requestCapability = this._requests.shift();
  50317. requestCapability.resolve({
  50318. value: chunk,
  50319. done: false
  50320. });
  50321. } else {
  50322. this._cachedChunks.push(chunk);
  50323. }
  50324. },
  50325. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  50326. if (args) {
  50327. this._onProgressiveData(args.chunk);
  50328. }
  50329. this._done = true;
  50330. if (this._cachedChunks.length > 0) {
  50331. return;
  50332. }
  50333. this._requests.forEach(function (requestCapability) {
  50334. requestCapability.resolve({
  50335. value: undefined,
  50336. done: true
  50337. });
  50338. });
  50339. this._requests = [];
  50340. },
  50341. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  50342. var url = this._url;
  50343. var exception;
  50344. if (status === 404 || status === 0 && /^file:/.test(url)) {
  50345. exception = new MissingPDFException('Missing PDF "' + url + '".');
  50346. } else {
  50347. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  50348. }
  50349. this._storedError = exception;
  50350. this._headersReceivedCapability.reject(exception);
  50351. this._requests.forEach(function (requestCapability) {
  50352. requestCapability.reject(exception);
  50353. });
  50354. this._requests = [];
  50355. this._cachedChunks = [];
  50356. },
  50357. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  50358. if (this.onProgress) {
  50359. this.onProgress({
  50360. loaded: data.loaded,
  50361. total: data.lengthComputable ? data.total : this._contentLength
  50362. });
  50363. }
  50364. },
  50365. get isRangeSupported() {
  50366. return this._isRangeSupported;
  50367. },
  50368. get isStreamingSupported() {
  50369. return this._isStreamingSupported;
  50370. },
  50371. get contentLength() {
  50372. return this._contentLength;
  50373. },
  50374. get headersReady() {
  50375. return this._headersReceivedCapability.promise;
  50376. },
  50377. read: function PDFNetworkStreamFullRequestReader_read() {
  50378. if (this._storedError) {
  50379. return Promise.reject(this._storedError);
  50380. }
  50381. if (this._cachedChunks.length > 0) {
  50382. var chunk = this._cachedChunks.shift();
  50383. return Promise.resolve(chunk);
  50384. }
  50385. if (this._done) {
  50386. return Promise.resolve({
  50387. value: undefined,
  50388. done: true
  50389. });
  50390. }
  50391. var requestCapability = createPromiseCapability();
  50392. this._requests.push(requestCapability);
  50393. return requestCapability.promise;
  50394. },
  50395. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  50396. this._done = true;
  50397. this._headersReceivedCapability.reject(reason);
  50398. this._requests.forEach(function (requestCapability) {
  50399. requestCapability.resolve({
  50400. value: undefined,
  50401. done: true
  50402. });
  50403. });
  50404. this._requests = [];
  50405. if (this._manager.isPendingRequest(this._fullRequestId)) {
  50406. this._manager.abortRequest(this._fullRequestId);
  50407. }
  50408. this._fullRequestReader = null;
  50409. }
  50410. };
  50411. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  50412. this._manager = manager;
  50413. var args = {
  50414. onDone: this._onDone.bind(this),
  50415. onProgress: this._onProgress.bind(this)
  50416. };
  50417. this._requestId = manager.requestRange(begin, end, args);
  50418. this._requests = [];
  50419. this._queuedChunk = null;
  50420. this._done = false;
  50421. this.onProgress = null;
  50422. this.onClosed = null;
  50423. }
  50424. PDFNetworkStreamRangeRequestReader.prototype = {
  50425. _close: function PDFNetworkStreamRangeRequestReader_close() {
  50426. if (this.onClosed) {
  50427. this.onClosed(this);
  50428. }
  50429. },
  50430. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  50431. var chunk = data.chunk;
  50432. if (this._requests.length > 0) {
  50433. var requestCapability = this._requests.shift();
  50434. requestCapability.resolve({
  50435. value: chunk,
  50436. done: false
  50437. });
  50438. } else {
  50439. this._queuedChunk = chunk;
  50440. }
  50441. this._done = true;
  50442. this._requests.forEach(function (requestCapability) {
  50443. requestCapability.resolve({
  50444. value: undefined,
  50445. done: true
  50446. });
  50447. });
  50448. this._requests = [];
  50449. this._close();
  50450. },
  50451. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  50452. if (!this.isStreamingSupported && this.onProgress) {
  50453. this.onProgress({ loaded: evt.loaded });
  50454. }
  50455. },
  50456. get isStreamingSupported() {
  50457. return false;
  50458. },
  50459. read: function PDFNetworkStreamRangeRequestReader_read() {
  50460. if (this._queuedChunk !== null) {
  50461. var chunk = this._queuedChunk;
  50462. this._queuedChunk = null;
  50463. return Promise.resolve({
  50464. value: chunk,
  50465. done: false
  50466. });
  50467. }
  50468. if (this._done) {
  50469. return Promise.resolve({
  50470. value: undefined,
  50471. done: true
  50472. });
  50473. }
  50474. var requestCapability = createPromiseCapability();
  50475. this._requests.push(requestCapability);
  50476. return requestCapability.promise;
  50477. },
  50478. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  50479. this._done = true;
  50480. this._requests.forEach(function (requestCapability) {
  50481. requestCapability.resolve({
  50482. value: undefined,
  50483. done: true
  50484. });
  50485. });
  50486. this._requests = [];
  50487. if (this._manager.isPendingRequest(this._requestId)) {
  50488. this._manager.abortRequest(this._requestId);
  50489. }
  50490. this._close();
  50491. }
  50492. };
  50493. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  50494. exports.PDFNetworkStream = PDFNetworkStream;
  50495. exports.NetworkManager = NetworkManager;
  50496. }));
  50497. }.call(pdfjsLibs));
  50498. exports.WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  50499. }));