pdf.combined.js 1.5 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961
  1. /* Copyright 2012 Mozilla Foundation
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. (function (root, factory) {
  16. 'use strict';
  17. if (typeof define === 'function' && define.amd) {
  18. define('pdfjs-dist/build/pdf.combined', ['exports'], factory);
  19. } else if (typeof exports !== 'undefined') {
  20. factory(exports);
  21. } else {
  22. factory(root['pdfjsDistBuildPdfCombined'] = {});
  23. }
  24. }(this, function (exports) {
  25. 'use strict';
  26. var pdfjsVersion = '1.6.377';
  27. var pdfjsBuild = '47f03b6';
  28. var pdfjsFilePath = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : null;
  29. var pdfjsLibs = {};
  30. (function pdfjsWrapper() {
  31. (function (root, factory) {
  32. factory(root.pdfjsCoreArithmeticDecoder = {});
  33. }(this, function (exports) {
  34. var ArithmeticDecoder = function ArithmeticDecoderClosure() {
  35. var QeTable = [
  36. {
  37. qe: 0x5601,
  38. nmps: 1,
  39. nlps: 1,
  40. switchFlag: 1
  41. },
  42. {
  43. qe: 0x3401,
  44. nmps: 2,
  45. nlps: 6,
  46. switchFlag: 0
  47. },
  48. {
  49. qe: 0x1801,
  50. nmps: 3,
  51. nlps: 9,
  52. switchFlag: 0
  53. },
  54. {
  55. qe: 0x0AC1,
  56. nmps: 4,
  57. nlps: 12,
  58. switchFlag: 0
  59. },
  60. {
  61. qe: 0x0521,
  62. nmps: 5,
  63. nlps: 29,
  64. switchFlag: 0
  65. },
  66. {
  67. qe: 0x0221,
  68. nmps: 38,
  69. nlps: 33,
  70. switchFlag: 0
  71. },
  72. {
  73. qe: 0x5601,
  74. nmps: 7,
  75. nlps: 6,
  76. switchFlag: 1
  77. },
  78. {
  79. qe: 0x5401,
  80. nmps: 8,
  81. nlps: 14,
  82. switchFlag: 0
  83. },
  84. {
  85. qe: 0x4801,
  86. nmps: 9,
  87. nlps: 14,
  88. switchFlag: 0
  89. },
  90. {
  91. qe: 0x3801,
  92. nmps: 10,
  93. nlps: 14,
  94. switchFlag: 0
  95. },
  96. {
  97. qe: 0x3001,
  98. nmps: 11,
  99. nlps: 17,
  100. switchFlag: 0
  101. },
  102. {
  103. qe: 0x2401,
  104. nmps: 12,
  105. nlps: 18,
  106. switchFlag: 0
  107. },
  108. {
  109. qe: 0x1C01,
  110. nmps: 13,
  111. nlps: 20,
  112. switchFlag: 0
  113. },
  114. {
  115. qe: 0x1601,
  116. nmps: 29,
  117. nlps: 21,
  118. switchFlag: 0
  119. },
  120. {
  121. qe: 0x5601,
  122. nmps: 15,
  123. nlps: 14,
  124. switchFlag: 1
  125. },
  126. {
  127. qe: 0x5401,
  128. nmps: 16,
  129. nlps: 14,
  130. switchFlag: 0
  131. },
  132. {
  133. qe: 0x5101,
  134. nmps: 17,
  135. nlps: 15,
  136. switchFlag: 0
  137. },
  138. {
  139. qe: 0x4801,
  140. nmps: 18,
  141. nlps: 16,
  142. switchFlag: 0
  143. },
  144. {
  145. qe: 0x3801,
  146. nmps: 19,
  147. nlps: 17,
  148. switchFlag: 0
  149. },
  150. {
  151. qe: 0x3401,
  152. nmps: 20,
  153. nlps: 18,
  154. switchFlag: 0
  155. },
  156. {
  157. qe: 0x3001,
  158. nmps: 21,
  159. nlps: 19,
  160. switchFlag: 0
  161. },
  162. {
  163. qe: 0x2801,
  164. nmps: 22,
  165. nlps: 19,
  166. switchFlag: 0
  167. },
  168. {
  169. qe: 0x2401,
  170. nmps: 23,
  171. nlps: 20,
  172. switchFlag: 0
  173. },
  174. {
  175. qe: 0x2201,
  176. nmps: 24,
  177. nlps: 21,
  178. switchFlag: 0
  179. },
  180. {
  181. qe: 0x1C01,
  182. nmps: 25,
  183. nlps: 22,
  184. switchFlag: 0
  185. },
  186. {
  187. qe: 0x1801,
  188. nmps: 26,
  189. nlps: 23,
  190. switchFlag: 0
  191. },
  192. {
  193. qe: 0x1601,
  194. nmps: 27,
  195. nlps: 24,
  196. switchFlag: 0
  197. },
  198. {
  199. qe: 0x1401,
  200. nmps: 28,
  201. nlps: 25,
  202. switchFlag: 0
  203. },
  204. {
  205. qe: 0x1201,
  206. nmps: 29,
  207. nlps: 26,
  208. switchFlag: 0
  209. },
  210. {
  211. qe: 0x1101,
  212. nmps: 30,
  213. nlps: 27,
  214. switchFlag: 0
  215. },
  216. {
  217. qe: 0x0AC1,
  218. nmps: 31,
  219. nlps: 28,
  220. switchFlag: 0
  221. },
  222. {
  223. qe: 0x09C1,
  224. nmps: 32,
  225. nlps: 29,
  226. switchFlag: 0
  227. },
  228. {
  229. qe: 0x08A1,
  230. nmps: 33,
  231. nlps: 30,
  232. switchFlag: 0
  233. },
  234. {
  235. qe: 0x0521,
  236. nmps: 34,
  237. nlps: 31,
  238. switchFlag: 0
  239. },
  240. {
  241. qe: 0x0441,
  242. nmps: 35,
  243. nlps: 32,
  244. switchFlag: 0
  245. },
  246. {
  247. qe: 0x02A1,
  248. nmps: 36,
  249. nlps: 33,
  250. switchFlag: 0
  251. },
  252. {
  253. qe: 0x0221,
  254. nmps: 37,
  255. nlps: 34,
  256. switchFlag: 0
  257. },
  258. {
  259. qe: 0x0141,
  260. nmps: 38,
  261. nlps: 35,
  262. switchFlag: 0
  263. },
  264. {
  265. qe: 0x0111,
  266. nmps: 39,
  267. nlps: 36,
  268. switchFlag: 0
  269. },
  270. {
  271. qe: 0x0085,
  272. nmps: 40,
  273. nlps: 37,
  274. switchFlag: 0
  275. },
  276. {
  277. qe: 0x0049,
  278. nmps: 41,
  279. nlps: 38,
  280. switchFlag: 0
  281. },
  282. {
  283. qe: 0x0025,
  284. nmps: 42,
  285. nlps: 39,
  286. switchFlag: 0
  287. },
  288. {
  289. qe: 0x0015,
  290. nmps: 43,
  291. nlps: 40,
  292. switchFlag: 0
  293. },
  294. {
  295. qe: 0x0009,
  296. nmps: 44,
  297. nlps: 41,
  298. switchFlag: 0
  299. },
  300. {
  301. qe: 0x0005,
  302. nmps: 45,
  303. nlps: 42,
  304. switchFlag: 0
  305. },
  306. {
  307. qe: 0x0001,
  308. nmps: 45,
  309. nlps: 43,
  310. switchFlag: 0
  311. },
  312. {
  313. qe: 0x5601,
  314. nmps: 46,
  315. nlps: 46,
  316. switchFlag: 0
  317. }
  318. ];
  319. function ArithmeticDecoder(data, start, end) {
  320. this.data = data;
  321. this.bp = start;
  322. this.dataEnd = end;
  323. this.chigh = data[start];
  324. this.clow = 0;
  325. this.byteIn();
  326. this.chigh = this.chigh << 7 & 0xFFFF | this.clow >> 9 & 0x7F;
  327. this.clow = this.clow << 7 & 0xFFFF;
  328. this.ct -= 7;
  329. this.a = 0x8000;
  330. }
  331. ArithmeticDecoder.prototype = {
  332. byteIn: function ArithmeticDecoder_byteIn() {
  333. var data = this.data;
  334. var bp = this.bp;
  335. if (data[bp] === 0xFF) {
  336. var b1 = data[bp + 1];
  337. if (b1 > 0x8F) {
  338. this.clow += 0xFF00;
  339. this.ct = 8;
  340. } else {
  341. bp++;
  342. this.clow += data[bp] << 9;
  343. this.ct = 7;
  344. this.bp = bp;
  345. }
  346. } else {
  347. bp++;
  348. this.clow += bp < this.dataEnd ? data[bp] << 8 : 0xFF00;
  349. this.ct = 8;
  350. this.bp = bp;
  351. }
  352. if (this.clow > 0xFFFF) {
  353. this.chigh += this.clow >> 16;
  354. this.clow &= 0xFFFF;
  355. }
  356. },
  357. readBit: function ArithmeticDecoder_readBit(contexts, pos) {
  358. var cx_index = contexts[pos] >> 1, cx_mps = contexts[pos] & 1;
  359. var qeTableIcx = QeTable[cx_index];
  360. var qeIcx = qeTableIcx.qe;
  361. var d;
  362. var a = this.a - qeIcx;
  363. if (this.chigh < qeIcx) {
  364. if (a < qeIcx) {
  365. a = qeIcx;
  366. d = cx_mps;
  367. cx_index = qeTableIcx.nmps;
  368. } else {
  369. a = qeIcx;
  370. d = 1 ^ cx_mps;
  371. if (qeTableIcx.switchFlag === 1) {
  372. cx_mps = d;
  373. }
  374. cx_index = qeTableIcx.nlps;
  375. }
  376. } else {
  377. this.chigh -= qeIcx;
  378. if ((a & 0x8000) !== 0) {
  379. this.a = a;
  380. return cx_mps;
  381. }
  382. if (a < qeIcx) {
  383. d = 1 ^ cx_mps;
  384. if (qeTableIcx.switchFlag === 1) {
  385. cx_mps = d;
  386. }
  387. cx_index = qeTableIcx.nlps;
  388. } else {
  389. d = cx_mps;
  390. cx_index = qeTableIcx.nmps;
  391. }
  392. }
  393. do {
  394. if (this.ct === 0) {
  395. this.byteIn();
  396. }
  397. a <<= 1;
  398. this.chigh = this.chigh << 1 & 0xFFFF | this.clow >> 15 & 1;
  399. this.clow = this.clow << 1 & 0xFFFF;
  400. this.ct--;
  401. } while ((a & 0x8000) === 0);
  402. this.a = a;
  403. contexts[pos] = cx_index << 1 | cx_mps;
  404. return d;
  405. }
  406. };
  407. return ArithmeticDecoder;
  408. }();
  409. exports.ArithmeticDecoder = ArithmeticDecoder;
  410. }));
  411. (function (root, factory) {
  412. factory(root.pdfjsCoreCharsets = {});
  413. }(this, function (exports) {
  414. var ISOAdobeCharset = [
  415. '.notdef',
  416. 'space',
  417. 'exclam',
  418. 'quotedbl',
  419. 'numbersign',
  420. 'dollar',
  421. 'percent',
  422. 'ampersand',
  423. 'quoteright',
  424. 'parenleft',
  425. 'parenright',
  426. 'asterisk',
  427. 'plus',
  428. 'comma',
  429. 'hyphen',
  430. 'period',
  431. 'slash',
  432. 'zero',
  433. 'one',
  434. 'two',
  435. 'three',
  436. 'four',
  437. 'five',
  438. 'six',
  439. 'seven',
  440. 'eight',
  441. 'nine',
  442. 'colon',
  443. 'semicolon',
  444. 'less',
  445. 'equal',
  446. 'greater',
  447. 'question',
  448. 'at',
  449. 'A',
  450. 'B',
  451. 'C',
  452. 'D',
  453. 'E',
  454. 'F',
  455. 'G',
  456. 'H',
  457. 'I',
  458. 'J',
  459. 'K',
  460. 'L',
  461. 'M',
  462. 'N',
  463. 'O',
  464. 'P',
  465. 'Q',
  466. 'R',
  467. 'S',
  468. 'T',
  469. 'U',
  470. 'V',
  471. 'W',
  472. 'X',
  473. 'Y',
  474. 'Z',
  475. 'bracketleft',
  476. 'backslash',
  477. 'bracketright',
  478. 'asciicircum',
  479. 'underscore',
  480. 'quoteleft',
  481. 'a',
  482. 'b',
  483. 'c',
  484. 'd',
  485. 'e',
  486. 'f',
  487. 'g',
  488. 'h',
  489. 'i',
  490. 'j',
  491. 'k',
  492. 'l',
  493. 'm',
  494. 'n',
  495. 'o',
  496. 'p',
  497. 'q',
  498. 'r',
  499. 's',
  500. 't',
  501. 'u',
  502. 'v',
  503. 'w',
  504. 'x',
  505. 'y',
  506. 'z',
  507. 'braceleft',
  508. 'bar',
  509. 'braceright',
  510. 'asciitilde',
  511. 'exclamdown',
  512. 'cent',
  513. 'sterling',
  514. 'fraction',
  515. 'yen',
  516. 'florin',
  517. 'section',
  518. 'currency',
  519. 'quotesingle',
  520. 'quotedblleft',
  521. 'guillemotleft',
  522. 'guilsinglleft',
  523. 'guilsinglright',
  524. 'fi',
  525. 'fl',
  526. 'endash',
  527. 'dagger',
  528. 'daggerdbl',
  529. 'periodcentered',
  530. 'paragraph',
  531. 'bullet',
  532. 'quotesinglbase',
  533. 'quotedblbase',
  534. 'quotedblright',
  535. 'guillemotright',
  536. 'ellipsis',
  537. 'perthousand',
  538. 'questiondown',
  539. 'grave',
  540. 'acute',
  541. 'circumflex',
  542. 'tilde',
  543. 'macron',
  544. 'breve',
  545. 'dotaccent',
  546. 'dieresis',
  547. 'ring',
  548. 'cedilla',
  549. 'hungarumlaut',
  550. 'ogonek',
  551. 'caron',
  552. 'emdash',
  553. 'AE',
  554. 'ordfeminine',
  555. 'Lslash',
  556. 'Oslash',
  557. 'OE',
  558. 'ordmasculine',
  559. 'ae',
  560. 'dotlessi',
  561. 'lslash',
  562. 'oslash',
  563. 'oe',
  564. 'germandbls',
  565. 'onesuperior',
  566. 'logicalnot',
  567. 'mu',
  568. 'trademark',
  569. 'Eth',
  570. 'onehalf',
  571. 'plusminus',
  572. 'Thorn',
  573. 'onequarter',
  574. 'divide',
  575. 'brokenbar',
  576. 'degree',
  577. 'thorn',
  578. 'threequarters',
  579. 'twosuperior',
  580. 'registered',
  581. 'minus',
  582. 'eth',
  583. 'multiply',
  584. 'threesuperior',
  585. 'copyright',
  586. 'Aacute',
  587. 'Acircumflex',
  588. 'Adieresis',
  589. 'Agrave',
  590. 'Aring',
  591. 'Atilde',
  592. 'Ccedilla',
  593. 'Eacute',
  594. 'Ecircumflex',
  595. 'Edieresis',
  596. 'Egrave',
  597. 'Iacute',
  598. 'Icircumflex',
  599. 'Idieresis',
  600. 'Igrave',
  601. 'Ntilde',
  602. 'Oacute',
  603. 'Ocircumflex',
  604. 'Odieresis',
  605. 'Ograve',
  606. 'Otilde',
  607. 'Scaron',
  608. 'Uacute',
  609. 'Ucircumflex',
  610. 'Udieresis',
  611. 'Ugrave',
  612. 'Yacute',
  613. 'Ydieresis',
  614. 'Zcaron',
  615. 'aacute',
  616. 'acircumflex',
  617. 'adieresis',
  618. 'agrave',
  619. 'aring',
  620. 'atilde',
  621. 'ccedilla',
  622. 'eacute',
  623. 'ecircumflex',
  624. 'edieresis',
  625. 'egrave',
  626. 'iacute',
  627. 'icircumflex',
  628. 'idieresis',
  629. 'igrave',
  630. 'ntilde',
  631. 'oacute',
  632. 'ocircumflex',
  633. 'odieresis',
  634. 'ograve',
  635. 'otilde',
  636. 'scaron',
  637. 'uacute',
  638. 'ucircumflex',
  639. 'udieresis',
  640. 'ugrave',
  641. 'yacute',
  642. 'ydieresis',
  643. 'zcaron'
  644. ];
  645. var ExpertCharset = [
  646. '.notdef',
  647. 'space',
  648. 'exclamsmall',
  649. 'Hungarumlautsmall',
  650. 'dollaroldstyle',
  651. 'dollarsuperior',
  652. 'ampersandsmall',
  653. 'Acutesmall',
  654. 'parenleftsuperior',
  655. 'parenrightsuperior',
  656. 'twodotenleader',
  657. 'onedotenleader',
  658. 'comma',
  659. 'hyphen',
  660. 'period',
  661. 'fraction',
  662. 'zerooldstyle',
  663. 'oneoldstyle',
  664. 'twooldstyle',
  665. 'threeoldstyle',
  666. 'fouroldstyle',
  667. 'fiveoldstyle',
  668. 'sixoldstyle',
  669. 'sevenoldstyle',
  670. 'eightoldstyle',
  671. 'nineoldstyle',
  672. 'colon',
  673. 'semicolon',
  674. 'commasuperior',
  675. 'threequartersemdash',
  676. 'periodsuperior',
  677. 'questionsmall',
  678. 'asuperior',
  679. 'bsuperior',
  680. 'centsuperior',
  681. 'dsuperior',
  682. 'esuperior',
  683. 'isuperior',
  684. 'lsuperior',
  685. 'msuperior',
  686. 'nsuperior',
  687. 'osuperior',
  688. 'rsuperior',
  689. 'ssuperior',
  690. 'tsuperior',
  691. 'ff',
  692. 'fi',
  693. 'fl',
  694. 'ffi',
  695. 'ffl',
  696. 'parenleftinferior',
  697. 'parenrightinferior',
  698. 'Circumflexsmall',
  699. 'hyphensuperior',
  700. 'Gravesmall',
  701. 'Asmall',
  702. 'Bsmall',
  703. 'Csmall',
  704. 'Dsmall',
  705. 'Esmall',
  706. 'Fsmall',
  707. 'Gsmall',
  708. 'Hsmall',
  709. 'Ismall',
  710. 'Jsmall',
  711. 'Ksmall',
  712. 'Lsmall',
  713. 'Msmall',
  714. 'Nsmall',
  715. 'Osmall',
  716. 'Psmall',
  717. 'Qsmall',
  718. 'Rsmall',
  719. 'Ssmall',
  720. 'Tsmall',
  721. 'Usmall',
  722. 'Vsmall',
  723. 'Wsmall',
  724. 'Xsmall',
  725. 'Ysmall',
  726. 'Zsmall',
  727. 'colonmonetary',
  728. 'onefitted',
  729. 'rupiah',
  730. 'Tildesmall',
  731. 'exclamdownsmall',
  732. 'centoldstyle',
  733. 'Lslashsmall',
  734. 'Scaronsmall',
  735. 'Zcaronsmall',
  736. 'Dieresissmall',
  737. 'Brevesmall',
  738. 'Caronsmall',
  739. 'Dotaccentsmall',
  740. 'Macronsmall',
  741. 'figuredash',
  742. 'hypheninferior',
  743. 'Ogoneksmall',
  744. 'Ringsmall',
  745. 'Cedillasmall',
  746. 'onequarter',
  747. 'onehalf',
  748. 'threequarters',
  749. 'questiondownsmall',
  750. 'oneeighth',
  751. 'threeeighths',
  752. 'fiveeighths',
  753. 'seveneighths',
  754. 'onethird',
  755. 'twothirds',
  756. 'zerosuperior',
  757. 'onesuperior',
  758. 'twosuperior',
  759. 'threesuperior',
  760. 'foursuperior',
  761. 'fivesuperior',
  762. 'sixsuperior',
  763. 'sevensuperior',
  764. 'eightsuperior',
  765. 'ninesuperior',
  766. 'zeroinferior',
  767. 'oneinferior',
  768. 'twoinferior',
  769. 'threeinferior',
  770. 'fourinferior',
  771. 'fiveinferior',
  772. 'sixinferior',
  773. 'seveninferior',
  774. 'eightinferior',
  775. 'nineinferior',
  776. 'centinferior',
  777. 'dollarinferior',
  778. 'periodinferior',
  779. 'commainferior',
  780. 'Agravesmall',
  781. 'Aacutesmall',
  782. 'Acircumflexsmall',
  783. 'Atildesmall',
  784. 'Adieresissmall',
  785. 'Aringsmall',
  786. 'AEsmall',
  787. 'Ccedillasmall',
  788. 'Egravesmall',
  789. 'Eacutesmall',
  790. 'Ecircumflexsmall',
  791. 'Edieresissmall',
  792. 'Igravesmall',
  793. 'Iacutesmall',
  794. 'Icircumflexsmall',
  795. 'Idieresissmall',
  796. 'Ethsmall',
  797. 'Ntildesmall',
  798. 'Ogravesmall',
  799. 'Oacutesmall',
  800. 'Ocircumflexsmall',
  801. 'Otildesmall',
  802. 'Odieresissmall',
  803. 'OEsmall',
  804. 'Oslashsmall',
  805. 'Ugravesmall',
  806. 'Uacutesmall',
  807. 'Ucircumflexsmall',
  808. 'Udieresissmall',
  809. 'Yacutesmall',
  810. 'Thornsmall',
  811. 'Ydieresissmall'
  812. ];
  813. var ExpertSubsetCharset = [
  814. '.notdef',
  815. 'space',
  816. 'dollaroldstyle',
  817. 'dollarsuperior',
  818. 'parenleftsuperior',
  819. 'parenrightsuperior',
  820. 'twodotenleader',
  821. 'onedotenleader',
  822. 'comma',
  823. 'hyphen',
  824. 'period',
  825. 'fraction',
  826. 'zerooldstyle',
  827. 'oneoldstyle',
  828. 'twooldstyle',
  829. 'threeoldstyle',
  830. 'fouroldstyle',
  831. 'fiveoldstyle',
  832. 'sixoldstyle',
  833. 'sevenoldstyle',
  834. 'eightoldstyle',
  835. 'nineoldstyle',
  836. 'colon',
  837. 'semicolon',
  838. 'commasuperior',
  839. 'threequartersemdash',
  840. 'periodsuperior',
  841. 'asuperior',
  842. 'bsuperior',
  843. 'centsuperior',
  844. 'dsuperior',
  845. 'esuperior',
  846. 'isuperior',
  847. 'lsuperior',
  848. 'msuperior',
  849. 'nsuperior',
  850. 'osuperior',
  851. 'rsuperior',
  852. 'ssuperior',
  853. 'tsuperior',
  854. 'ff',
  855. 'fi',
  856. 'fl',
  857. 'ffi',
  858. 'ffl',
  859. 'parenleftinferior',
  860. 'parenrightinferior',
  861. 'hyphensuperior',
  862. 'colonmonetary',
  863. 'onefitted',
  864. 'rupiah',
  865. 'centoldstyle',
  866. 'figuredash',
  867. 'hypheninferior',
  868. 'onequarter',
  869. 'onehalf',
  870. 'threequarters',
  871. 'oneeighth',
  872. 'threeeighths',
  873. 'fiveeighths',
  874. 'seveneighths',
  875. 'onethird',
  876. 'twothirds',
  877. 'zerosuperior',
  878. 'onesuperior',
  879. 'twosuperior',
  880. 'threesuperior',
  881. 'foursuperior',
  882. 'fivesuperior',
  883. 'sixsuperior',
  884. 'sevensuperior',
  885. 'eightsuperior',
  886. 'ninesuperior',
  887. 'zeroinferior',
  888. 'oneinferior',
  889. 'twoinferior',
  890. 'threeinferior',
  891. 'fourinferior',
  892. 'fiveinferior',
  893. 'sixinferior',
  894. 'seveninferior',
  895. 'eightinferior',
  896. 'nineinferior',
  897. 'centinferior',
  898. 'dollarinferior',
  899. 'periodinferior',
  900. 'commainferior'
  901. ];
  902. exports.ISOAdobeCharset = ISOAdobeCharset;
  903. exports.ExpertCharset = ExpertCharset;
  904. exports.ExpertSubsetCharset = ExpertSubsetCharset;
  905. }));
  906. (function (root, factory) {
  907. factory(root.pdfjsCoreEncodings = {});
  908. }(this, function (exports) {
  909. var ExpertEncoding = [
  910. '',
  911. '',
  912. '',
  913. '',
  914. '',
  915. '',
  916. '',
  917. '',
  918. '',
  919. '',
  920. '',
  921. '',
  922. '',
  923. '',
  924. '',
  925. '',
  926. '',
  927. '',
  928. '',
  929. '',
  930. '',
  931. '',
  932. '',
  933. '',
  934. '',
  935. '',
  936. '',
  937. '',
  938. '',
  939. '',
  940. '',
  941. '',
  942. 'space',
  943. 'exclamsmall',
  944. 'Hungarumlautsmall',
  945. '',
  946. 'dollaroldstyle',
  947. 'dollarsuperior',
  948. 'ampersandsmall',
  949. 'Acutesmall',
  950. 'parenleftsuperior',
  951. 'parenrightsuperior',
  952. 'twodotenleader',
  953. 'onedotenleader',
  954. 'comma',
  955. 'hyphen',
  956. 'period',
  957. 'fraction',
  958. 'zerooldstyle',
  959. 'oneoldstyle',
  960. 'twooldstyle',
  961. 'threeoldstyle',
  962. 'fouroldstyle',
  963. 'fiveoldstyle',
  964. 'sixoldstyle',
  965. 'sevenoldstyle',
  966. 'eightoldstyle',
  967. 'nineoldstyle',
  968. 'colon',
  969. 'semicolon',
  970. 'commasuperior',
  971. 'threequartersemdash',
  972. 'periodsuperior',
  973. 'questionsmall',
  974. '',
  975. 'asuperior',
  976. 'bsuperior',
  977. 'centsuperior',
  978. 'dsuperior',
  979. 'esuperior',
  980. '',
  981. '',
  982. 'isuperior',
  983. '',
  984. '',
  985. 'lsuperior',
  986. 'msuperior',
  987. 'nsuperior',
  988. 'osuperior',
  989. '',
  990. '',
  991. 'rsuperior',
  992. 'ssuperior',
  993. 'tsuperior',
  994. '',
  995. 'ff',
  996. 'fi',
  997. 'fl',
  998. 'ffi',
  999. 'ffl',
  1000. 'parenleftinferior',
  1001. '',
  1002. 'parenrightinferior',
  1003. 'Circumflexsmall',
  1004. 'hyphensuperior',
  1005. 'Gravesmall',
  1006. 'Asmall',
  1007. 'Bsmall',
  1008. 'Csmall',
  1009. 'Dsmall',
  1010. 'Esmall',
  1011. 'Fsmall',
  1012. 'Gsmall',
  1013. 'Hsmall',
  1014. 'Ismall',
  1015. 'Jsmall',
  1016. 'Ksmall',
  1017. 'Lsmall',
  1018. 'Msmall',
  1019. 'Nsmall',
  1020. 'Osmall',
  1021. 'Psmall',
  1022. 'Qsmall',
  1023. 'Rsmall',
  1024. 'Ssmall',
  1025. 'Tsmall',
  1026. 'Usmall',
  1027. 'Vsmall',
  1028. 'Wsmall',
  1029. 'Xsmall',
  1030. 'Ysmall',
  1031. 'Zsmall',
  1032. 'colonmonetary',
  1033. 'onefitted',
  1034. 'rupiah',
  1035. 'Tildesmall',
  1036. '',
  1037. '',
  1038. '',
  1039. '',
  1040. '',
  1041. '',
  1042. '',
  1043. '',
  1044. '',
  1045. '',
  1046. '',
  1047. '',
  1048. '',
  1049. '',
  1050. '',
  1051. '',
  1052. '',
  1053. '',
  1054. '',
  1055. '',
  1056. '',
  1057. '',
  1058. '',
  1059. '',
  1060. '',
  1061. '',
  1062. '',
  1063. '',
  1064. '',
  1065. '',
  1066. '',
  1067. '',
  1068. '',
  1069. '',
  1070. 'exclamdownsmall',
  1071. 'centoldstyle',
  1072. 'Lslashsmall',
  1073. '',
  1074. '',
  1075. 'Scaronsmall',
  1076. 'Zcaronsmall',
  1077. 'Dieresissmall',
  1078. 'Brevesmall',
  1079. 'Caronsmall',
  1080. '',
  1081. 'Dotaccentsmall',
  1082. '',
  1083. '',
  1084. 'Macronsmall',
  1085. '',
  1086. '',
  1087. 'figuredash',
  1088. 'hypheninferior',
  1089. '',
  1090. '',
  1091. 'Ogoneksmall',
  1092. 'Ringsmall',
  1093. 'Cedillasmall',
  1094. '',
  1095. '',
  1096. '',
  1097. 'onequarter',
  1098. 'onehalf',
  1099. 'threequarters',
  1100. 'questiondownsmall',
  1101. 'oneeighth',
  1102. 'threeeighths',
  1103. 'fiveeighths',
  1104. 'seveneighths',
  1105. 'onethird',
  1106. 'twothirds',
  1107. '',
  1108. '',
  1109. 'zerosuperior',
  1110. 'onesuperior',
  1111. 'twosuperior',
  1112. 'threesuperior',
  1113. 'foursuperior',
  1114. 'fivesuperior',
  1115. 'sixsuperior',
  1116. 'sevensuperior',
  1117. 'eightsuperior',
  1118. 'ninesuperior',
  1119. 'zeroinferior',
  1120. 'oneinferior',
  1121. 'twoinferior',
  1122. 'threeinferior',
  1123. 'fourinferior',
  1124. 'fiveinferior',
  1125. 'sixinferior',
  1126. 'seveninferior',
  1127. 'eightinferior',
  1128. 'nineinferior',
  1129. 'centinferior',
  1130. 'dollarinferior',
  1131. 'periodinferior',
  1132. 'commainferior',
  1133. 'Agravesmall',
  1134. 'Aacutesmall',
  1135. 'Acircumflexsmall',
  1136. 'Atildesmall',
  1137. 'Adieresissmall',
  1138. 'Aringsmall',
  1139. 'AEsmall',
  1140. 'Ccedillasmall',
  1141. 'Egravesmall',
  1142. 'Eacutesmall',
  1143. 'Ecircumflexsmall',
  1144. 'Edieresissmall',
  1145. 'Igravesmall',
  1146. 'Iacutesmall',
  1147. 'Icircumflexsmall',
  1148. 'Idieresissmall',
  1149. 'Ethsmall',
  1150. 'Ntildesmall',
  1151. 'Ogravesmall',
  1152. 'Oacutesmall',
  1153. 'Ocircumflexsmall',
  1154. 'Otildesmall',
  1155. 'Odieresissmall',
  1156. 'OEsmall',
  1157. 'Oslashsmall',
  1158. 'Ugravesmall',
  1159. 'Uacutesmall',
  1160. 'Ucircumflexsmall',
  1161. 'Udieresissmall',
  1162. 'Yacutesmall',
  1163. 'Thornsmall',
  1164. 'Ydieresissmall'
  1165. ];
  1166. var MacExpertEncoding = [
  1167. '',
  1168. '',
  1169. '',
  1170. '',
  1171. '',
  1172. '',
  1173. '',
  1174. '',
  1175. '',
  1176. '',
  1177. '',
  1178. '',
  1179. '',
  1180. '',
  1181. '',
  1182. '',
  1183. '',
  1184. '',
  1185. '',
  1186. '',
  1187. '',
  1188. '',
  1189. '',
  1190. '',
  1191. '',
  1192. '',
  1193. '',
  1194. '',
  1195. '',
  1196. '',
  1197. '',
  1198. '',
  1199. 'space',
  1200. 'exclamsmall',
  1201. 'Hungarumlautsmall',
  1202. 'centoldstyle',
  1203. 'dollaroldstyle',
  1204. 'dollarsuperior',
  1205. 'ampersandsmall',
  1206. 'Acutesmall',
  1207. 'parenleftsuperior',
  1208. 'parenrightsuperior',
  1209. 'twodotenleader',
  1210. 'onedotenleader',
  1211. 'comma',
  1212. 'hyphen',
  1213. 'period',
  1214. 'fraction',
  1215. 'zerooldstyle',
  1216. 'oneoldstyle',
  1217. 'twooldstyle',
  1218. 'threeoldstyle',
  1219. 'fouroldstyle',
  1220. 'fiveoldstyle',
  1221. 'sixoldstyle',
  1222. 'sevenoldstyle',
  1223. 'eightoldstyle',
  1224. 'nineoldstyle',
  1225. 'colon',
  1226. 'semicolon',
  1227. '',
  1228. 'threequartersemdash',
  1229. '',
  1230. 'questionsmall',
  1231. '',
  1232. '',
  1233. '',
  1234. '',
  1235. 'Ethsmall',
  1236. '',
  1237. '',
  1238. 'onequarter',
  1239. 'onehalf',
  1240. 'threequarters',
  1241. 'oneeighth',
  1242. 'threeeighths',
  1243. 'fiveeighths',
  1244. 'seveneighths',
  1245. 'onethird',
  1246. 'twothirds',
  1247. '',
  1248. '',
  1249. '',
  1250. '',
  1251. '',
  1252. '',
  1253. 'ff',
  1254. 'fi',
  1255. 'fl',
  1256. 'ffi',
  1257. 'ffl',
  1258. 'parenleftinferior',
  1259. '',
  1260. 'parenrightinferior',
  1261. 'Circumflexsmall',
  1262. 'hypheninferior',
  1263. 'Gravesmall',
  1264. 'Asmall',
  1265. 'Bsmall',
  1266. 'Csmall',
  1267. 'Dsmall',
  1268. 'Esmall',
  1269. 'Fsmall',
  1270. 'Gsmall',
  1271. 'Hsmall',
  1272. 'Ismall',
  1273. 'Jsmall',
  1274. 'Ksmall',
  1275. 'Lsmall',
  1276. 'Msmall',
  1277. 'Nsmall',
  1278. 'Osmall',
  1279. 'Psmall',
  1280. 'Qsmall',
  1281. 'Rsmall',
  1282. 'Ssmall',
  1283. 'Tsmall',
  1284. 'Usmall',
  1285. 'Vsmall',
  1286. 'Wsmall',
  1287. 'Xsmall',
  1288. 'Ysmall',
  1289. 'Zsmall',
  1290. 'colonmonetary',
  1291. 'onefitted',
  1292. 'rupiah',
  1293. 'Tildesmall',
  1294. '',
  1295. '',
  1296. 'asuperior',
  1297. 'centsuperior',
  1298. '',
  1299. '',
  1300. '',
  1301. '',
  1302. 'Aacutesmall',
  1303. 'Agravesmall',
  1304. 'Acircumflexsmall',
  1305. 'Adieresissmall',
  1306. 'Atildesmall',
  1307. 'Aringsmall',
  1308. 'Ccedillasmall',
  1309. 'Eacutesmall',
  1310. 'Egravesmall',
  1311. 'Ecircumflexsmall',
  1312. 'Edieresissmall',
  1313. 'Iacutesmall',
  1314. 'Igravesmall',
  1315. 'Icircumflexsmall',
  1316. 'Idieresissmall',
  1317. 'Ntildesmall',
  1318. 'Oacutesmall',
  1319. 'Ogravesmall',
  1320. 'Ocircumflexsmall',
  1321. 'Odieresissmall',
  1322. 'Otildesmall',
  1323. 'Uacutesmall',
  1324. 'Ugravesmall',
  1325. 'Ucircumflexsmall',
  1326. 'Udieresissmall',
  1327. '',
  1328. 'eightsuperior',
  1329. 'fourinferior',
  1330. 'threeinferior',
  1331. 'sixinferior',
  1332. 'eightinferior',
  1333. 'seveninferior',
  1334. 'Scaronsmall',
  1335. '',
  1336. 'centinferior',
  1337. 'twoinferior',
  1338. '',
  1339. 'Dieresissmall',
  1340. '',
  1341. 'Caronsmall',
  1342. 'osuperior',
  1343. 'fiveinferior',
  1344. '',
  1345. 'commainferior',
  1346. 'periodinferior',
  1347. 'Yacutesmall',
  1348. '',
  1349. 'dollarinferior',
  1350. '',
  1351. 'Thornsmall',
  1352. '',
  1353. 'nineinferior',
  1354. 'zeroinferior',
  1355. 'Zcaronsmall',
  1356. 'AEsmall',
  1357. 'Oslashsmall',
  1358. 'questiondownsmall',
  1359. 'oneinferior',
  1360. 'Lslashsmall',
  1361. '',
  1362. '',
  1363. '',
  1364. '',
  1365. '',
  1366. '',
  1367. 'Cedillasmall',
  1368. '',
  1369. '',
  1370. '',
  1371. '',
  1372. '',
  1373. 'OEsmall',
  1374. 'figuredash',
  1375. 'hyphensuperior',
  1376. '',
  1377. '',
  1378. '',
  1379. '',
  1380. 'exclamdownsmall',
  1381. '',
  1382. 'Ydieresissmall',
  1383. '',
  1384. 'onesuperior',
  1385. 'twosuperior',
  1386. 'threesuperior',
  1387. 'foursuperior',
  1388. 'fivesuperior',
  1389. 'sixsuperior',
  1390. 'sevensuperior',
  1391. 'ninesuperior',
  1392. 'zerosuperior',
  1393. '',
  1394. 'esuperior',
  1395. 'rsuperior',
  1396. 'tsuperior',
  1397. '',
  1398. '',
  1399. 'isuperior',
  1400. 'ssuperior',
  1401. 'dsuperior',
  1402. '',
  1403. '',
  1404. '',
  1405. '',
  1406. '',
  1407. 'lsuperior',
  1408. 'Ogoneksmall',
  1409. 'Brevesmall',
  1410. 'Macronsmall',
  1411. 'bsuperior',
  1412. 'nsuperior',
  1413. 'msuperior',
  1414. 'commasuperior',
  1415. 'periodsuperior',
  1416. 'Dotaccentsmall',
  1417. 'Ringsmall'
  1418. ];
  1419. var MacRomanEncoding = [
  1420. '',
  1421. '',
  1422. '',
  1423. '',
  1424. '',
  1425. '',
  1426. '',
  1427. '',
  1428. '',
  1429. '',
  1430. '',
  1431. '',
  1432. '',
  1433. '',
  1434. '',
  1435. '',
  1436. '',
  1437. '',
  1438. '',
  1439. '',
  1440. '',
  1441. '',
  1442. '',
  1443. '',
  1444. '',
  1445. '',
  1446. '',
  1447. '',
  1448. '',
  1449. '',
  1450. '',
  1451. '',
  1452. 'space',
  1453. 'exclam',
  1454. 'quotedbl',
  1455. 'numbersign',
  1456. 'dollar',
  1457. 'percent',
  1458. 'ampersand',
  1459. 'quotesingle',
  1460. 'parenleft',
  1461. 'parenright',
  1462. 'asterisk',
  1463. 'plus',
  1464. 'comma',
  1465. 'hyphen',
  1466. 'period',
  1467. 'slash',
  1468. 'zero',
  1469. 'one',
  1470. 'two',
  1471. 'three',
  1472. 'four',
  1473. 'five',
  1474. 'six',
  1475. 'seven',
  1476. 'eight',
  1477. 'nine',
  1478. 'colon',
  1479. 'semicolon',
  1480. 'less',
  1481. 'equal',
  1482. 'greater',
  1483. 'question',
  1484. 'at',
  1485. 'A',
  1486. 'B',
  1487. 'C',
  1488. 'D',
  1489. 'E',
  1490. 'F',
  1491. 'G',
  1492. 'H',
  1493. 'I',
  1494. 'J',
  1495. 'K',
  1496. 'L',
  1497. 'M',
  1498. 'N',
  1499. 'O',
  1500. 'P',
  1501. 'Q',
  1502. 'R',
  1503. 'S',
  1504. 'T',
  1505. 'U',
  1506. 'V',
  1507. 'W',
  1508. 'X',
  1509. 'Y',
  1510. 'Z',
  1511. 'bracketleft',
  1512. 'backslash',
  1513. 'bracketright',
  1514. 'asciicircum',
  1515. 'underscore',
  1516. 'grave',
  1517. 'a',
  1518. 'b',
  1519. 'c',
  1520. 'd',
  1521. 'e',
  1522. 'f',
  1523. 'g',
  1524. 'h',
  1525. 'i',
  1526. 'j',
  1527. 'k',
  1528. 'l',
  1529. 'm',
  1530. 'n',
  1531. 'o',
  1532. 'p',
  1533. 'q',
  1534. 'r',
  1535. 's',
  1536. 't',
  1537. 'u',
  1538. 'v',
  1539. 'w',
  1540. 'x',
  1541. 'y',
  1542. 'z',
  1543. 'braceleft',
  1544. 'bar',
  1545. 'braceright',
  1546. 'asciitilde',
  1547. '',
  1548. 'Adieresis',
  1549. 'Aring',
  1550. 'Ccedilla',
  1551. 'Eacute',
  1552. 'Ntilde',
  1553. 'Odieresis',
  1554. 'Udieresis',
  1555. 'aacute',
  1556. 'agrave',
  1557. 'acircumflex',
  1558. 'adieresis',
  1559. 'atilde',
  1560. 'aring',
  1561. 'ccedilla',
  1562. 'eacute',
  1563. 'egrave',
  1564. 'ecircumflex',
  1565. 'edieresis',
  1566. 'iacute',
  1567. 'igrave',
  1568. 'icircumflex',
  1569. 'idieresis',
  1570. 'ntilde',
  1571. 'oacute',
  1572. 'ograve',
  1573. 'ocircumflex',
  1574. 'odieresis',
  1575. 'otilde',
  1576. 'uacute',
  1577. 'ugrave',
  1578. 'ucircumflex',
  1579. 'udieresis',
  1580. 'dagger',
  1581. 'degree',
  1582. 'cent',
  1583. 'sterling',
  1584. 'section',
  1585. 'bullet',
  1586. 'paragraph',
  1587. 'germandbls',
  1588. 'registered',
  1589. 'copyright',
  1590. 'trademark',
  1591. 'acute',
  1592. 'dieresis',
  1593. 'notequal',
  1594. 'AE',
  1595. 'Oslash',
  1596. 'infinity',
  1597. 'plusminus',
  1598. 'lessequal',
  1599. 'greaterequal',
  1600. 'yen',
  1601. 'mu',
  1602. 'partialdiff',
  1603. 'summation',
  1604. 'product',
  1605. 'pi',
  1606. 'integral',
  1607. 'ordfeminine',
  1608. 'ordmasculine',
  1609. 'Omega',
  1610. 'ae',
  1611. 'oslash',
  1612. 'questiondown',
  1613. 'exclamdown',
  1614. 'logicalnot',
  1615. 'radical',
  1616. 'florin',
  1617. 'approxequal',
  1618. 'Delta',
  1619. 'guillemotleft',
  1620. 'guillemotright',
  1621. 'ellipsis',
  1622. 'space',
  1623. 'Agrave',
  1624. 'Atilde',
  1625. 'Otilde',
  1626. 'OE',
  1627. 'oe',
  1628. 'endash',
  1629. 'emdash',
  1630. 'quotedblleft',
  1631. 'quotedblright',
  1632. 'quoteleft',
  1633. 'quoteright',
  1634. 'divide',
  1635. 'lozenge',
  1636. 'ydieresis',
  1637. 'Ydieresis',
  1638. 'fraction',
  1639. 'currency',
  1640. 'guilsinglleft',
  1641. 'guilsinglright',
  1642. 'fi',
  1643. 'fl',
  1644. 'daggerdbl',
  1645. 'periodcentered',
  1646. 'quotesinglbase',
  1647. 'quotedblbase',
  1648. 'perthousand',
  1649. 'Acircumflex',
  1650. 'Ecircumflex',
  1651. 'Aacute',
  1652. 'Edieresis',
  1653. 'Egrave',
  1654. 'Iacute',
  1655. 'Icircumflex',
  1656. 'Idieresis',
  1657. 'Igrave',
  1658. 'Oacute',
  1659. 'Ocircumflex',
  1660. 'apple',
  1661. 'Ograve',
  1662. 'Uacute',
  1663. 'Ucircumflex',
  1664. 'Ugrave',
  1665. 'dotlessi',
  1666. 'circumflex',
  1667. 'tilde',
  1668. 'macron',
  1669. 'breve',
  1670. 'dotaccent',
  1671. 'ring',
  1672. 'cedilla',
  1673. 'hungarumlaut',
  1674. 'ogonek',
  1675. 'caron'
  1676. ];
  1677. var StandardEncoding = [
  1678. '',
  1679. '',
  1680. '',
  1681. '',
  1682. '',
  1683. '',
  1684. '',
  1685. '',
  1686. '',
  1687. '',
  1688. '',
  1689. '',
  1690. '',
  1691. '',
  1692. '',
  1693. '',
  1694. '',
  1695. '',
  1696. '',
  1697. '',
  1698. '',
  1699. '',
  1700. '',
  1701. '',
  1702. '',
  1703. '',
  1704. '',
  1705. '',
  1706. '',
  1707. '',
  1708. '',
  1709. '',
  1710. 'space',
  1711. 'exclam',
  1712. 'quotedbl',
  1713. 'numbersign',
  1714. 'dollar',
  1715. 'percent',
  1716. 'ampersand',
  1717. 'quoteright',
  1718. 'parenleft',
  1719. 'parenright',
  1720. 'asterisk',
  1721. 'plus',
  1722. 'comma',
  1723. 'hyphen',
  1724. 'period',
  1725. 'slash',
  1726. 'zero',
  1727. 'one',
  1728. 'two',
  1729. 'three',
  1730. 'four',
  1731. 'five',
  1732. 'six',
  1733. 'seven',
  1734. 'eight',
  1735. 'nine',
  1736. 'colon',
  1737. 'semicolon',
  1738. 'less',
  1739. 'equal',
  1740. 'greater',
  1741. 'question',
  1742. 'at',
  1743. 'A',
  1744. 'B',
  1745. 'C',
  1746. 'D',
  1747. 'E',
  1748. 'F',
  1749. 'G',
  1750. 'H',
  1751. 'I',
  1752. 'J',
  1753. 'K',
  1754. 'L',
  1755. 'M',
  1756. 'N',
  1757. 'O',
  1758. 'P',
  1759. 'Q',
  1760. 'R',
  1761. 'S',
  1762. 'T',
  1763. 'U',
  1764. 'V',
  1765. 'W',
  1766. 'X',
  1767. 'Y',
  1768. 'Z',
  1769. 'bracketleft',
  1770. 'backslash',
  1771. 'bracketright',
  1772. 'asciicircum',
  1773. 'underscore',
  1774. 'quoteleft',
  1775. 'a',
  1776. 'b',
  1777. 'c',
  1778. 'd',
  1779. 'e',
  1780. 'f',
  1781. 'g',
  1782. 'h',
  1783. 'i',
  1784. 'j',
  1785. 'k',
  1786. 'l',
  1787. 'm',
  1788. 'n',
  1789. 'o',
  1790. 'p',
  1791. 'q',
  1792. 'r',
  1793. 's',
  1794. 't',
  1795. 'u',
  1796. 'v',
  1797. 'w',
  1798. 'x',
  1799. 'y',
  1800. 'z',
  1801. 'braceleft',
  1802. 'bar',
  1803. 'braceright',
  1804. 'asciitilde',
  1805. '',
  1806. '',
  1807. '',
  1808. '',
  1809. '',
  1810. '',
  1811. '',
  1812. '',
  1813. '',
  1814. '',
  1815. '',
  1816. '',
  1817. '',
  1818. '',
  1819. '',
  1820. '',
  1821. '',
  1822. '',
  1823. '',
  1824. '',
  1825. '',
  1826. '',
  1827. '',
  1828. '',
  1829. '',
  1830. '',
  1831. '',
  1832. '',
  1833. '',
  1834. '',
  1835. '',
  1836. '',
  1837. '',
  1838. '',
  1839. 'exclamdown',
  1840. 'cent',
  1841. 'sterling',
  1842. 'fraction',
  1843. 'yen',
  1844. 'florin',
  1845. 'section',
  1846. 'currency',
  1847. 'quotesingle',
  1848. 'quotedblleft',
  1849. 'guillemotleft',
  1850. 'guilsinglleft',
  1851. 'guilsinglright',
  1852. 'fi',
  1853. 'fl',
  1854. '',
  1855. 'endash',
  1856. 'dagger',
  1857. 'daggerdbl',
  1858. 'periodcentered',
  1859. '',
  1860. 'paragraph',
  1861. 'bullet',
  1862. 'quotesinglbase',
  1863. 'quotedblbase',
  1864. 'quotedblright',
  1865. 'guillemotright',
  1866. 'ellipsis',
  1867. 'perthousand',
  1868. '',
  1869. 'questiondown',
  1870. '',
  1871. 'grave',
  1872. 'acute',
  1873. 'circumflex',
  1874. 'tilde',
  1875. 'macron',
  1876. 'breve',
  1877. 'dotaccent',
  1878. 'dieresis',
  1879. '',
  1880. 'ring',
  1881. 'cedilla',
  1882. '',
  1883. 'hungarumlaut',
  1884. 'ogonek',
  1885. 'caron',
  1886. 'emdash',
  1887. '',
  1888. '',
  1889. '',
  1890. '',
  1891. '',
  1892. '',
  1893. '',
  1894. '',
  1895. '',
  1896. '',
  1897. '',
  1898. '',
  1899. '',
  1900. '',
  1901. '',
  1902. '',
  1903. 'AE',
  1904. '',
  1905. 'ordfeminine',
  1906. '',
  1907. '',
  1908. '',
  1909. '',
  1910. 'Lslash',
  1911. 'Oslash',
  1912. 'OE',
  1913. 'ordmasculine',
  1914. '',
  1915. '',
  1916. '',
  1917. '',
  1918. '',
  1919. 'ae',
  1920. '',
  1921. '',
  1922. '',
  1923. 'dotlessi',
  1924. '',
  1925. '',
  1926. 'lslash',
  1927. 'oslash',
  1928. 'oe',
  1929. 'germandbls'
  1930. ];
  1931. var WinAnsiEncoding = [
  1932. '',
  1933. '',
  1934. '',
  1935. '',
  1936. '',
  1937. '',
  1938. '',
  1939. '',
  1940. '',
  1941. '',
  1942. '',
  1943. '',
  1944. '',
  1945. '',
  1946. '',
  1947. '',
  1948. '',
  1949. '',
  1950. '',
  1951. '',
  1952. '',
  1953. '',
  1954. '',
  1955. '',
  1956. '',
  1957. '',
  1958. '',
  1959. '',
  1960. '',
  1961. '',
  1962. '',
  1963. '',
  1964. 'space',
  1965. 'exclam',
  1966. 'quotedbl',
  1967. 'numbersign',
  1968. 'dollar',
  1969. 'percent',
  1970. 'ampersand',
  1971. 'quotesingle',
  1972. 'parenleft',
  1973. 'parenright',
  1974. 'asterisk',
  1975. 'plus',
  1976. 'comma',
  1977. 'hyphen',
  1978. 'period',
  1979. 'slash',
  1980. 'zero',
  1981. 'one',
  1982. 'two',
  1983. 'three',
  1984. 'four',
  1985. 'five',
  1986. 'six',
  1987. 'seven',
  1988. 'eight',
  1989. 'nine',
  1990. 'colon',
  1991. 'semicolon',
  1992. 'less',
  1993. 'equal',
  1994. 'greater',
  1995. 'question',
  1996. 'at',
  1997. 'A',
  1998. 'B',
  1999. 'C',
  2000. 'D',
  2001. 'E',
  2002. 'F',
  2003. 'G',
  2004. 'H',
  2005. 'I',
  2006. 'J',
  2007. 'K',
  2008. 'L',
  2009. 'M',
  2010. 'N',
  2011. 'O',
  2012. 'P',
  2013. 'Q',
  2014. 'R',
  2015. 'S',
  2016. 'T',
  2017. 'U',
  2018. 'V',
  2019. 'W',
  2020. 'X',
  2021. 'Y',
  2022. 'Z',
  2023. 'bracketleft',
  2024. 'backslash',
  2025. 'bracketright',
  2026. 'asciicircum',
  2027. 'underscore',
  2028. 'grave',
  2029. 'a',
  2030. 'b',
  2031. 'c',
  2032. 'd',
  2033. 'e',
  2034. 'f',
  2035. 'g',
  2036. 'h',
  2037. 'i',
  2038. 'j',
  2039. 'k',
  2040. 'l',
  2041. 'm',
  2042. 'n',
  2043. 'o',
  2044. 'p',
  2045. 'q',
  2046. 'r',
  2047. 's',
  2048. 't',
  2049. 'u',
  2050. 'v',
  2051. 'w',
  2052. 'x',
  2053. 'y',
  2054. 'z',
  2055. 'braceleft',
  2056. 'bar',
  2057. 'braceright',
  2058. 'asciitilde',
  2059. 'bullet',
  2060. 'Euro',
  2061. 'bullet',
  2062. 'quotesinglbase',
  2063. 'florin',
  2064. 'quotedblbase',
  2065. 'ellipsis',
  2066. 'dagger',
  2067. 'daggerdbl',
  2068. 'circumflex',
  2069. 'perthousand',
  2070. 'Scaron',
  2071. 'guilsinglleft',
  2072. 'OE',
  2073. 'bullet',
  2074. 'Zcaron',
  2075. 'bullet',
  2076. 'bullet',
  2077. 'quoteleft',
  2078. 'quoteright',
  2079. 'quotedblleft',
  2080. 'quotedblright',
  2081. 'bullet',
  2082. 'endash',
  2083. 'emdash',
  2084. 'tilde',
  2085. 'trademark',
  2086. 'scaron',
  2087. 'guilsinglright',
  2088. 'oe',
  2089. 'bullet',
  2090. 'zcaron',
  2091. 'Ydieresis',
  2092. 'space',
  2093. 'exclamdown',
  2094. 'cent',
  2095. 'sterling',
  2096. 'currency',
  2097. 'yen',
  2098. 'brokenbar',
  2099. 'section',
  2100. 'dieresis',
  2101. 'copyright',
  2102. 'ordfeminine',
  2103. 'guillemotleft',
  2104. 'logicalnot',
  2105. 'hyphen',
  2106. 'registered',
  2107. 'macron',
  2108. 'degree',
  2109. 'plusminus',
  2110. 'twosuperior',
  2111. 'threesuperior',
  2112. 'acute',
  2113. 'mu',
  2114. 'paragraph',
  2115. 'periodcentered',
  2116. 'cedilla',
  2117. 'onesuperior',
  2118. 'ordmasculine',
  2119. 'guillemotright',
  2120. 'onequarter',
  2121. 'onehalf',
  2122. 'threequarters',
  2123. 'questiondown',
  2124. 'Agrave',
  2125. 'Aacute',
  2126. 'Acircumflex',
  2127. 'Atilde',
  2128. 'Adieresis',
  2129. 'Aring',
  2130. 'AE',
  2131. 'Ccedilla',
  2132. 'Egrave',
  2133. 'Eacute',
  2134. 'Ecircumflex',
  2135. 'Edieresis',
  2136. 'Igrave',
  2137. 'Iacute',
  2138. 'Icircumflex',
  2139. 'Idieresis',
  2140. 'Eth',
  2141. 'Ntilde',
  2142. 'Ograve',
  2143. 'Oacute',
  2144. 'Ocircumflex',
  2145. 'Otilde',
  2146. 'Odieresis',
  2147. 'multiply',
  2148. 'Oslash',
  2149. 'Ugrave',
  2150. 'Uacute',
  2151. 'Ucircumflex',
  2152. 'Udieresis',
  2153. 'Yacute',
  2154. 'Thorn',
  2155. 'germandbls',
  2156. 'agrave',
  2157. 'aacute',
  2158. 'acircumflex',
  2159. 'atilde',
  2160. 'adieresis',
  2161. 'aring',
  2162. 'ae',
  2163. 'ccedilla',
  2164. 'egrave',
  2165. 'eacute',
  2166. 'ecircumflex',
  2167. 'edieresis',
  2168. 'igrave',
  2169. 'iacute',
  2170. 'icircumflex',
  2171. 'idieresis',
  2172. 'eth',
  2173. 'ntilde',
  2174. 'ograve',
  2175. 'oacute',
  2176. 'ocircumflex',
  2177. 'otilde',
  2178. 'odieresis',
  2179. 'divide',
  2180. 'oslash',
  2181. 'ugrave',
  2182. 'uacute',
  2183. 'ucircumflex',
  2184. 'udieresis',
  2185. 'yacute',
  2186. 'thorn',
  2187. 'ydieresis'
  2188. ];
  2189. var SymbolSetEncoding = [
  2190. '',
  2191. '',
  2192. '',
  2193. '',
  2194. '',
  2195. '',
  2196. '',
  2197. '',
  2198. '',
  2199. '',
  2200. '',
  2201. '',
  2202. '',
  2203. '',
  2204. '',
  2205. '',
  2206. '',
  2207. '',
  2208. '',
  2209. '',
  2210. '',
  2211. '',
  2212. '',
  2213. '',
  2214. '',
  2215. '',
  2216. '',
  2217. '',
  2218. '',
  2219. '',
  2220. '',
  2221. '',
  2222. 'space',
  2223. 'exclam',
  2224. 'universal',
  2225. 'numbersign',
  2226. 'existential',
  2227. 'percent',
  2228. 'ampersand',
  2229. 'suchthat',
  2230. 'parenleft',
  2231. 'parenright',
  2232. 'asteriskmath',
  2233. 'plus',
  2234. 'comma',
  2235. 'minus',
  2236. 'period',
  2237. 'slash',
  2238. 'zero',
  2239. 'one',
  2240. 'two',
  2241. 'three',
  2242. 'four',
  2243. 'five',
  2244. 'six',
  2245. 'seven',
  2246. 'eight',
  2247. 'nine',
  2248. 'colon',
  2249. 'semicolon',
  2250. 'less',
  2251. 'equal',
  2252. 'greater',
  2253. 'question',
  2254. 'congruent',
  2255. 'Alpha',
  2256. 'Beta',
  2257. 'Chi',
  2258. 'Delta',
  2259. 'Epsilon',
  2260. 'Phi',
  2261. 'Gamma',
  2262. 'Eta',
  2263. 'Iota',
  2264. 'theta1',
  2265. 'Kappa',
  2266. 'Lambda',
  2267. 'Mu',
  2268. 'Nu',
  2269. 'Omicron',
  2270. 'Pi',
  2271. 'Theta',
  2272. 'Rho',
  2273. 'Sigma',
  2274. 'Tau',
  2275. 'Upsilon',
  2276. 'sigma1',
  2277. 'Omega',
  2278. 'Xi',
  2279. 'Psi',
  2280. 'Zeta',
  2281. 'bracketleft',
  2282. 'therefore',
  2283. 'bracketright',
  2284. 'perpendicular',
  2285. 'underscore',
  2286. 'radicalex',
  2287. 'alpha',
  2288. 'beta',
  2289. 'chi',
  2290. 'delta',
  2291. 'epsilon',
  2292. 'phi',
  2293. 'gamma',
  2294. 'eta',
  2295. 'iota',
  2296. 'phi1',
  2297. 'kappa',
  2298. 'lambda',
  2299. 'mu',
  2300. 'nu',
  2301. 'omicron',
  2302. 'pi',
  2303. 'theta',
  2304. 'rho',
  2305. 'sigma',
  2306. 'tau',
  2307. 'upsilon',
  2308. 'omega1',
  2309. 'omega',
  2310. 'xi',
  2311. 'psi',
  2312. 'zeta',
  2313. 'braceleft',
  2314. 'bar',
  2315. 'braceright',
  2316. 'similar',
  2317. '',
  2318. '',
  2319. '',
  2320. '',
  2321. '',
  2322. '',
  2323. '',
  2324. '',
  2325. '',
  2326. '',
  2327. '',
  2328. '',
  2329. '',
  2330. '',
  2331. '',
  2332. '',
  2333. '',
  2334. '',
  2335. '',
  2336. '',
  2337. '',
  2338. '',
  2339. '',
  2340. '',
  2341. '',
  2342. '',
  2343. '',
  2344. '',
  2345. '',
  2346. '',
  2347. '',
  2348. '',
  2349. '',
  2350. 'Euro',
  2351. 'Upsilon1',
  2352. 'minute',
  2353. 'lessequal',
  2354. 'fraction',
  2355. 'infinity',
  2356. 'florin',
  2357. 'club',
  2358. 'diamond',
  2359. 'heart',
  2360. 'spade',
  2361. 'arrowboth',
  2362. 'arrowleft',
  2363. 'arrowup',
  2364. 'arrowright',
  2365. 'arrowdown',
  2366. 'degree',
  2367. 'plusminus',
  2368. 'second',
  2369. 'greaterequal',
  2370. 'multiply',
  2371. 'proportional',
  2372. 'partialdiff',
  2373. 'bullet',
  2374. 'divide',
  2375. 'notequal',
  2376. 'equivalence',
  2377. 'approxequal',
  2378. 'ellipsis',
  2379. 'arrowvertex',
  2380. 'arrowhorizex',
  2381. 'carriagereturn',
  2382. 'aleph',
  2383. 'Ifraktur',
  2384. 'Rfraktur',
  2385. 'weierstrass',
  2386. 'circlemultiply',
  2387. 'circleplus',
  2388. 'emptyset',
  2389. 'intersection',
  2390. 'union',
  2391. 'propersuperset',
  2392. 'reflexsuperset',
  2393. 'notsubset',
  2394. 'propersubset',
  2395. 'reflexsubset',
  2396. 'element',
  2397. 'notelement',
  2398. 'angle',
  2399. 'gradient',
  2400. 'registerserif',
  2401. 'copyrightserif',
  2402. 'trademarkserif',
  2403. 'product',
  2404. 'radical',
  2405. 'dotmath',
  2406. 'logicalnot',
  2407. 'logicaland',
  2408. 'logicalor',
  2409. 'arrowdblboth',
  2410. 'arrowdblleft',
  2411. 'arrowdblup',
  2412. 'arrowdblright',
  2413. 'arrowdbldown',
  2414. 'lozenge',
  2415. 'angleleft',
  2416. 'registersans',
  2417. 'copyrightsans',
  2418. 'trademarksans',
  2419. 'summation',
  2420. 'parenlefttp',
  2421. 'parenleftex',
  2422. 'parenleftbt',
  2423. 'bracketlefttp',
  2424. 'bracketleftex',
  2425. 'bracketleftbt',
  2426. 'bracelefttp',
  2427. 'braceleftmid',
  2428. 'braceleftbt',
  2429. 'braceex',
  2430. '',
  2431. 'angleright',
  2432. 'integral',
  2433. 'integraltp',
  2434. 'integralex',
  2435. 'integralbt',
  2436. 'parenrighttp',
  2437. 'parenrightex',
  2438. 'parenrightbt',
  2439. 'bracketrighttp',
  2440. 'bracketrightex',
  2441. 'bracketrightbt',
  2442. 'bracerighttp',
  2443. 'bracerightmid',
  2444. 'bracerightbt'
  2445. ];
  2446. var ZapfDingbatsEncoding = [
  2447. '',
  2448. '',
  2449. '',
  2450. '',
  2451. '',
  2452. '',
  2453. '',
  2454. '',
  2455. '',
  2456. '',
  2457. '',
  2458. '',
  2459. '',
  2460. '',
  2461. '',
  2462. '',
  2463. '',
  2464. '',
  2465. '',
  2466. '',
  2467. '',
  2468. '',
  2469. '',
  2470. '',
  2471. '',
  2472. '',
  2473. '',
  2474. '',
  2475. '',
  2476. '',
  2477. '',
  2478. '',
  2479. 'space',
  2480. 'a1',
  2481. 'a2',
  2482. 'a202',
  2483. 'a3',
  2484. 'a4',
  2485. 'a5',
  2486. 'a119',
  2487. 'a118',
  2488. 'a117',
  2489. 'a11',
  2490. 'a12',
  2491. 'a13',
  2492. 'a14',
  2493. 'a15',
  2494. 'a16',
  2495. 'a105',
  2496. 'a17',
  2497. 'a18',
  2498. 'a19',
  2499. 'a20',
  2500. 'a21',
  2501. 'a22',
  2502. 'a23',
  2503. 'a24',
  2504. 'a25',
  2505. 'a26',
  2506. 'a27',
  2507. 'a28',
  2508. 'a6',
  2509. 'a7',
  2510. 'a8',
  2511. 'a9',
  2512. 'a10',
  2513. 'a29',
  2514. 'a30',
  2515. 'a31',
  2516. 'a32',
  2517. 'a33',
  2518. 'a34',
  2519. 'a35',
  2520. 'a36',
  2521. 'a37',
  2522. 'a38',
  2523. 'a39',
  2524. 'a40',
  2525. 'a41',
  2526. 'a42',
  2527. 'a43',
  2528. 'a44',
  2529. 'a45',
  2530. 'a46',
  2531. 'a47',
  2532. 'a48',
  2533. 'a49',
  2534. 'a50',
  2535. 'a51',
  2536. 'a52',
  2537. 'a53',
  2538. 'a54',
  2539. 'a55',
  2540. 'a56',
  2541. 'a57',
  2542. 'a58',
  2543. 'a59',
  2544. 'a60',
  2545. 'a61',
  2546. 'a62',
  2547. 'a63',
  2548. 'a64',
  2549. 'a65',
  2550. 'a66',
  2551. 'a67',
  2552. 'a68',
  2553. 'a69',
  2554. 'a70',
  2555. 'a71',
  2556. 'a72',
  2557. 'a73',
  2558. 'a74',
  2559. 'a203',
  2560. 'a75',
  2561. 'a204',
  2562. 'a76',
  2563. 'a77',
  2564. 'a78',
  2565. 'a79',
  2566. 'a81',
  2567. 'a82',
  2568. 'a83',
  2569. 'a84',
  2570. 'a97',
  2571. 'a98',
  2572. 'a99',
  2573. 'a100',
  2574. '',
  2575. 'a89',
  2576. 'a90',
  2577. 'a93',
  2578. 'a94',
  2579. 'a91',
  2580. 'a92',
  2581. 'a205',
  2582. 'a85',
  2583. 'a206',
  2584. 'a86',
  2585. 'a87',
  2586. 'a88',
  2587. 'a95',
  2588. 'a96',
  2589. '',
  2590. '',
  2591. '',
  2592. '',
  2593. '',
  2594. '',
  2595. '',
  2596. '',
  2597. '',
  2598. '',
  2599. '',
  2600. '',
  2601. '',
  2602. '',
  2603. '',
  2604. '',
  2605. '',
  2606. '',
  2607. '',
  2608. 'a101',
  2609. 'a102',
  2610. 'a103',
  2611. 'a104',
  2612. 'a106',
  2613. 'a107',
  2614. 'a108',
  2615. 'a112',
  2616. 'a111',
  2617. 'a110',
  2618. 'a109',
  2619. 'a120',
  2620. 'a121',
  2621. 'a122',
  2622. 'a123',
  2623. 'a124',
  2624. 'a125',
  2625. 'a126',
  2626. 'a127',
  2627. 'a128',
  2628. 'a129',
  2629. 'a130',
  2630. 'a131',
  2631. 'a132',
  2632. 'a133',
  2633. 'a134',
  2634. 'a135',
  2635. 'a136',
  2636. 'a137',
  2637. 'a138',
  2638. 'a139',
  2639. 'a140',
  2640. 'a141',
  2641. 'a142',
  2642. 'a143',
  2643. 'a144',
  2644. 'a145',
  2645. 'a146',
  2646. 'a147',
  2647. 'a148',
  2648. 'a149',
  2649. 'a150',
  2650. 'a151',
  2651. 'a152',
  2652. 'a153',
  2653. 'a154',
  2654. 'a155',
  2655. 'a156',
  2656. 'a157',
  2657. 'a158',
  2658. 'a159',
  2659. 'a160',
  2660. 'a161',
  2661. 'a163',
  2662. 'a164',
  2663. 'a196',
  2664. 'a165',
  2665. 'a192',
  2666. 'a166',
  2667. 'a167',
  2668. 'a168',
  2669. 'a169',
  2670. 'a170',
  2671. 'a171',
  2672. 'a172',
  2673. 'a173',
  2674. 'a162',
  2675. 'a174',
  2676. 'a175',
  2677. 'a176',
  2678. 'a177',
  2679. 'a178',
  2680. 'a179',
  2681. 'a193',
  2682. 'a180',
  2683. 'a199',
  2684. 'a181',
  2685. 'a200',
  2686. 'a182',
  2687. '',
  2688. 'a201',
  2689. 'a183',
  2690. 'a184',
  2691. 'a197',
  2692. 'a185',
  2693. 'a194',
  2694. 'a198',
  2695. 'a186',
  2696. 'a195',
  2697. 'a187',
  2698. 'a188',
  2699. 'a189',
  2700. 'a190',
  2701. 'a191'
  2702. ];
  2703. function getEncoding(encodingName) {
  2704. switch (encodingName) {
  2705. case 'WinAnsiEncoding':
  2706. return WinAnsiEncoding;
  2707. case 'StandardEncoding':
  2708. return StandardEncoding;
  2709. case 'MacRomanEncoding':
  2710. return MacRomanEncoding;
  2711. case 'SymbolSetEncoding':
  2712. return SymbolSetEncoding;
  2713. case 'ZapfDingbatsEncoding':
  2714. return ZapfDingbatsEncoding;
  2715. case 'ExpertEncoding':
  2716. return ExpertEncoding;
  2717. case 'MacExpertEncoding':
  2718. return MacExpertEncoding;
  2719. default:
  2720. return null;
  2721. }
  2722. }
  2723. exports.WinAnsiEncoding = WinAnsiEncoding;
  2724. exports.StandardEncoding = StandardEncoding;
  2725. exports.MacRomanEncoding = MacRomanEncoding;
  2726. exports.SymbolSetEncoding = SymbolSetEncoding;
  2727. exports.ZapfDingbatsEncoding = ZapfDingbatsEncoding;
  2728. exports.ExpertEncoding = ExpertEncoding;
  2729. exports.getEncoding = getEncoding;
  2730. }));
  2731. (function (root, factory) {
  2732. factory(root.pdfjsSharedUtil = {});
  2733. }(this, function (exports) {
  2734. var globalScope = typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : this;
  2735. var FONT_IDENTITY_MATRIX = [
  2736. 0.001,
  2737. 0,
  2738. 0,
  2739. 0.001,
  2740. 0,
  2741. 0
  2742. ];
  2743. var TextRenderingMode = {
  2744. FILL: 0,
  2745. STROKE: 1,
  2746. FILL_STROKE: 2,
  2747. INVISIBLE: 3,
  2748. FILL_ADD_TO_PATH: 4,
  2749. STROKE_ADD_TO_PATH: 5,
  2750. FILL_STROKE_ADD_TO_PATH: 6,
  2751. ADD_TO_PATH: 7,
  2752. FILL_STROKE_MASK: 3,
  2753. ADD_TO_PATH_FLAG: 4
  2754. };
  2755. var ImageKind = {
  2756. GRAYSCALE_1BPP: 1,
  2757. RGB_24BPP: 2,
  2758. RGBA_32BPP: 3
  2759. };
  2760. var AnnotationType = {
  2761. TEXT: 1,
  2762. LINK: 2,
  2763. FREETEXT: 3,
  2764. LINE: 4,
  2765. SQUARE: 5,
  2766. CIRCLE: 6,
  2767. POLYGON: 7,
  2768. POLYLINE: 8,
  2769. HIGHLIGHT: 9,
  2770. UNDERLINE: 10,
  2771. SQUIGGLY: 11,
  2772. STRIKEOUT: 12,
  2773. STAMP: 13,
  2774. CARET: 14,
  2775. INK: 15,
  2776. POPUP: 16,
  2777. FILEATTACHMENT: 17,
  2778. SOUND: 18,
  2779. MOVIE: 19,
  2780. WIDGET: 20,
  2781. SCREEN: 21,
  2782. PRINTERMARK: 22,
  2783. TRAPNET: 23,
  2784. WATERMARK: 24,
  2785. THREED: 25,
  2786. REDACT: 26
  2787. };
  2788. var AnnotationFlag = {
  2789. INVISIBLE: 0x01,
  2790. HIDDEN: 0x02,
  2791. PRINT: 0x04,
  2792. NOZOOM: 0x08,
  2793. NOROTATE: 0x10,
  2794. NOVIEW: 0x20,
  2795. READONLY: 0x40,
  2796. LOCKED: 0x80,
  2797. TOGGLENOVIEW: 0x100,
  2798. LOCKEDCONTENTS: 0x200
  2799. };
  2800. var AnnotationFieldFlag = {
  2801. READONLY: 0x0000001,
  2802. REQUIRED: 0x0000002,
  2803. NOEXPORT: 0x0000004,
  2804. MULTILINE: 0x0001000,
  2805. PASSWORD: 0x0002000,
  2806. NOTOGGLETOOFF: 0x0004000,
  2807. RADIO: 0x0008000,
  2808. PUSHBUTTON: 0x0010000,
  2809. COMBO: 0x0020000,
  2810. EDIT: 0x0040000,
  2811. SORT: 0x0080000,
  2812. FILESELECT: 0x0100000,
  2813. MULTISELECT: 0x0200000,
  2814. DONOTSPELLCHECK: 0x0400000,
  2815. DONOTSCROLL: 0x0800000,
  2816. COMB: 0x1000000,
  2817. RICHTEXT: 0x2000000,
  2818. RADIOSINUNISON: 0x2000000,
  2819. COMMITONSELCHANGE: 0x4000000
  2820. };
  2821. var AnnotationBorderStyleType = {
  2822. SOLID: 1,
  2823. DASHED: 2,
  2824. BEVELED: 3,
  2825. INSET: 4,
  2826. UNDERLINE: 5
  2827. };
  2828. var StreamType = {
  2829. UNKNOWN: 0,
  2830. FLATE: 1,
  2831. LZW: 2,
  2832. DCT: 3,
  2833. JPX: 4,
  2834. JBIG: 5,
  2835. A85: 6,
  2836. AHX: 7,
  2837. CCF: 8,
  2838. RL: 9
  2839. };
  2840. var FontType = {
  2841. UNKNOWN: 0,
  2842. TYPE1: 1,
  2843. TYPE1C: 2,
  2844. CIDFONTTYPE0: 3,
  2845. CIDFONTTYPE0C: 4,
  2846. TRUETYPE: 5,
  2847. CIDFONTTYPE2: 6,
  2848. TYPE3: 7,
  2849. OPENTYPE: 8,
  2850. TYPE0: 9,
  2851. MMTYPE1: 10
  2852. };
  2853. var VERBOSITY_LEVELS = {
  2854. errors: 0,
  2855. warnings: 1,
  2856. infos: 5
  2857. };
  2858. var OPS = {
  2859. dependency: 1,
  2860. setLineWidth: 2,
  2861. setLineCap: 3,
  2862. setLineJoin: 4,
  2863. setMiterLimit: 5,
  2864. setDash: 6,
  2865. setRenderingIntent: 7,
  2866. setFlatness: 8,
  2867. setGState: 9,
  2868. save: 10,
  2869. restore: 11,
  2870. transform: 12,
  2871. moveTo: 13,
  2872. lineTo: 14,
  2873. curveTo: 15,
  2874. curveTo2: 16,
  2875. curveTo3: 17,
  2876. closePath: 18,
  2877. rectangle: 19,
  2878. stroke: 20,
  2879. closeStroke: 21,
  2880. fill: 22,
  2881. eoFill: 23,
  2882. fillStroke: 24,
  2883. eoFillStroke: 25,
  2884. closeFillStroke: 26,
  2885. closeEOFillStroke: 27,
  2886. endPath: 28,
  2887. clip: 29,
  2888. eoClip: 30,
  2889. beginText: 31,
  2890. endText: 32,
  2891. setCharSpacing: 33,
  2892. setWordSpacing: 34,
  2893. setHScale: 35,
  2894. setLeading: 36,
  2895. setFont: 37,
  2896. setTextRenderingMode: 38,
  2897. setTextRise: 39,
  2898. moveText: 40,
  2899. setLeadingMoveText: 41,
  2900. setTextMatrix: 42,
  2901. nextLine: 43,
  2902. showText: 44,
  2903. showSpacedText: 45,
  2904. nextLineShowText: 46,
  2905. nextLineSetSpacingShowText: 47,
  2906. setCharWidth: 48,
  2907. setCharWidthAndBounds: 49,
  2908. setStrokeColorSpace: 50,
  2909. setFillColorSpace: 51,
  2910. setStrokeColor: 52,
  2911. setStrokeColorN: 53,
  2912. setFillColor: 54,
  2913. setFillColorN: 55,
  2914. setStrokeGray: 56,
  2915. setFillGray: 57,
  2916. setStrokeRGBColor: 58,
  2917. setFillRGBColor: 59,
  2918. setStrokeCMYKColor: 60,
  2919. setFillCMYKColor: 61,
  2920. shadingFill: 62,
  2921. beginInlineImage: 63,
  2922. beginImageData: 64,
  2923. endInlineImage: 65,
  2924. paintXObject: 66,
  2925. markPoint: 67,
  2926. markPointProps: 68,
  2927. beginMarkedContent: 69,
  2928. beginMarkedContentProps: 70,
  2929. endMarkedContent: 71,
  2930. beginCompat: 72,
  2931. endCompat: 73,
  2932. paintFormXObjectBegin: 74,
  2933. paintFormXObjectEnd: 75,
  2934. beginGroup: 76,
  2935. endGroup: 77,
  2936. beginAnnotations: 78,
  2937. endAnnotations: 79,
  2938. beginAnnotation: 80,
  2939. endAnnotation: 81,
  2940. paintJpegXObject: 82,
  2941. paintImageMaskXObject: 83,
  2942. paintImageMaskXObjectGroup: 84,
  2943. paintImageXObject: 85,
  2944. paintInlineImageXObject: 86,
  2945. paintInlineImageXObjectGroup: 87,
  2946. paintImageXObjectRepeat: 88,
  2947. paintImageMaskXObjectRepeat: 89,
  2948. paintSolidColorImageMask: 90,
  2949. constructPath: 91
  2950. };
  2951. var verbosity = VERBOSITY_LEVELS.warnings;
  2952. function setVerbosityLevel(level) {
  2953. verbosity = level;
  2954. }
  2955. function getVerbosityLevel() {
  2956. return verbosity;
  2957. }
  2958. function info(msg) {
  2959. if (verbosity >= VERBOSITY_LEVELS.infos) {
  2960. console.log('Info: ' + msg);
  2961. }
  2962. }
  2963. function warn(msg) {
  2964. if (verbosity >= VERBOSITY_LEVELS.warnings) {
  2965. console.log('Warning: ' + msg);
  2966. }
  2967. }
  2968. function deprecated(details) {
  2969. console.log('Deprecated API usage: ' + details);
  2970. }
  2971. function error(msg) {
  2972. if (verbosity >= VERBOSITY_LEVELS.errors) {
  2973. console.log('Error: ' + msg);
  2974. console.log(backtrace());
  2975. }
  2976. throw new Error(msg);
  2977. }
  2978. function backtrace() {
  2979. try {
  2980. throw new Error();
  2981. } catch (e) {
  2982. return e.stack ? e.stack.split('\n').slice(2).join('\n') : '';
  2983. }
  2984. }
  2985. function assert(cond, msg) {
  2986. if (!cond) {
  2987. error(msg);
  2988. }
  2989. }
  2990. var UNSUPPORTED_FEATURES = {
  2991. unknown: 'unknown',
  2992. forms: 'forms',
  2993. javaScript: 'javaScript',
  2994. smask: 'smask',
  2995. shadingPattern: 'shadingPattern',
  2996. font: 'font'
  2997. };
  2998. function isSameOrigin(baseUrl, otherUrl) {
  2999. try {
  3000. var base = new URL(baseUrl);
  3001. if (!base.origin || base.origin === 'null') {
  3002. return false;
  3003. }
  3004. } catch (e) {
  3005. return false;
  3006. }
  3007. var other = new URL(otherUrl, base);
  3008. return base.origin === other.origin;
  3009. }
  3010. function isValidProtocol(url) {
  3011. if (!url) {
  3012. return false;
  3013. }
  3014. switch (url.protocol) {
  3015. case 'http:':
  3016. case 'https:':
  3017. case 'ftp:':
  3018. case 'mailto:':
  3019. case 'tel:':
  3020. return true;
  3021. default:
  3022. return false;
  3023. }
  3024. }
  3025. function createValidAbsoluteUrl(url, baseUrl) {
  3026. if (!url) {
  3027. return null;
  3028. }
  3029. try {
  3030. var absoluteUrl = baseUrl ? new URL(url, baseUrl) : new URL(url);
  3031. if (isValidProtocol(absoluteUrl)) {
  3032. return absoluteUrl;
  3033. }
  3034. } catch (ex) {
  3035. }
  3036. return null;
  3037. }
  3038. function shadow(obj, prop, value) {
  3039. Object.defineProperty(obj, prop, {
  3040. value: value,
  3041. enumerable: true,
  3042. configurable: true,
  3043. writable: false
  3044. });
  3045. return value;
  3046. }
  3047. function getLookupTableFactory(initializer) {
  3048. var lookup;
  3049. return function () {
  3050. if (initializer) {
  3051. lookup = Object.create(null);
  3052. initializer(lookup);
  3053. initializer = null;
  3054. }
  3055. return lookup;
  3056. };
  3057. }
  3058. var PasswordResponses = {
  3059. NEED_PASSWORD: 1,
  3060. INCORRECT_PASSWORD: 2
  3061. };
  3062. var PasswordException = function PasswordExceptionClosure() {
  3063. function PasswordException(msg, code) {
  3064. this.name = 'PasswordException';
  3065. this.message = msg;
  3066. this.code = code;
  3067. }
  3068. PasswordException.prototype = new Error();
  3069. PasswordException.constructor = PasswordException;
  3070. return PasswordException;
  3071. }();
  3072. var UnknownErrorException = function UnknownErrorExceptionClosure() {
  3073. function UnknownErrorException(msg, details) {
  3074. this.name = 'UnknownErrorException';
  3075. this.message = msg;
  3076. this.details = details;
  3077. }
  3078. UnknownErrorException.prototype = new Error();
  3079. UnknownErrorException.constructor = UnknownErrorException;
  3080. return UnknownErrorException;
  3081. }();
  3082. var InvalidPDFException = function InvalidPDFExceptionClosure() {
  3083. function InvalidPDFException(msg) {
  3084. this.name = 'InvalidPDFException';
  3085. this.message = msg;
  3086. }
  3087. InvalidPDFException.prototype = new Error();
  3088. InvalidPDFException.constructor = InvalidPDFException;
  3089. return InvalidPDFException;
  3090. }();
  3091. var MissingPDFException = function MissingPDFExceptionClosure() {
  3092. function MissingPDFException(msg) {
  3093. this.name = 'MissingPDFException';
  3094. this.message = msg;
  3095. }
  3096. MissingPDFException.prototype = new Error();
  3097. MissingPDFException.constructor = MissingPDFException;
  3098. return MissingPDFException;
  3099. }();
  3100. var UnexpectedResponseException = function UnexpectedResponseExceptionClosure() {
  3101. function UnexpectedResponseException(msg, status) {
  3102. this.name = 'UnexpectedResponseException';
  3103. this.message = msg;
  3104. this.status = status;
  3105. }
  3106. UnexpectedResponseException.prototype = new Error();
  3107. UnexpectedResponseException.constructor = UnexpectedResponseException;
  3108. return UnexpectedResponseException;
  3109. }();
  3110. var NotImplementedException = function NotImplementedExceptionClosure() {
  3111. function NotImplementedException(msg) {
  3112. this.message = msg;
  3113. }
  3114. NotImplementedException.prototype = new Error();
  3115. NotImplementedException.prototype.name = 'NotImplementedException';
  3116. NotImplementedException.constructor = NotImplementedException;
  3117. return NotImplementedException;
  3118. }();
  3119. var MissingDataException = function MissingDataExceptionClosure() {
  3120. function MissingDataException(begin, end) {
  3121. this.begin = begin;
  3122. this.end = end;
  3123. this.message = 'Missing data [' + begin + ', ' + end + ')';
  3124. }
  3125. MissingDataException.prototype = new Error();
  3126. MissingDataException.prototype.name = 'MissingDataException';
  3127. MissingDataException.constructor = MissingDataException;
  3128. return MissingDataException;
  3129. }();
  3130. var XRefParseException = function XRefParseExceptionClosure() {
  3131. function XRefParseException(msg) {
  3132. this.message = msg;
  3133. }
  3134. XRefParseException.prototype = new Error();
  3135. XRefParseException.prototype.name = 'XRefParseException';
  3136. XRefParseException.constructor = XRefParseException;
  3137. return XRefParseException;
  3138. }();
  3139. var NullCharactersRegExp = /\x00/g;
  3140. function removeNullCharacters(str) {
  3141. if (typeof str !== 'string') {
  3142. warn('The argument for removeNullCharacters must be a string.');
  3143. return str;
  3144. }
  3145. return str.replace(NullCharactersRegExp, '');
  3146. }
  3147. function bytesToString(bytes) {
  3148. assert(bytes !== null && typeof bytes === 'object' && bytes.length !== undefined, 'Invalid argument for bytesToString');
  3149. var length = bytes.length;
  3150. var MAX_ARGUMENT_COUNT = 8192;
  3151. if (length < MAX_ARGUMENT_COUNT) {
  3152. return String.fromCharCode.apply(null, bytes);
  3153. }
  3154. var strBuf = [];
  3155. for (var i = 0; i < length; i += MAX_ARGUMENT_COUNT) {
  3156. var chunkEnd = Math.min(i + MAX_ARGUMENT_COUNT, length);
  3157. var chunk = bytes.subarray(i, chunkEnd);
  3158. strBuf.push(String.fromCharCode.apply(null, chunk));
  3159. }
  3160. return strBuf.join('');
  3161. }
  3162. function stringToBytes(str) {
  3163. assert(typeof str === 'string', 'Invalid argument for stringToBytes');
  3164. var length = str.length;
  3165. var bytes = new Uint8Array(length);
  3166. for (var i = 0; i < length; ++i) {
  3167. bytes[i] = str.charCodeAt(i) & 0xFF;
  3168. }
  3169. return bytes;
  3170. }
  3171. function arrayByteLength(arr) {
  3172. if (arr.length !== undefined) {
  3173. return arr.length;
  3174. }
  3175. assert(arr.byteLength !== undefined);
  3176. return arr.byteLength;
  3177. }
  3178. function arraysToBytes(arr) {
  3179. if (arr.length === 1 && arr[0] instanceof Uint8Array) {
  3180. return arr[0];
  3181. }
  3182. var resultLength = 0;
  3183. var i, ii = arr.length;
  3184. var item, itemLength;
  3185. for (i = 0; i < ii; i++) {
  3186. item = arr[i];
  3187. itemLength = arrayByteLength(item);
  3188. resultLength += itemLength;
  3189. }
  3190. var pos = 0;
  3191. var data = new Uint8Array(resultLength);
  3192. for (i = 0; i < ii; i++) {
  3193. item = arr[i];
  3194. if (!(item instanceof Uint8Array)) {
  3195. if (typeof item === 'string') {
  3196. item = stringToBytes(item);
  3197. } else {
  3198. item = new Uint8Array(item);
  3199. }
  3200. }
  3201. itemLength = item.byteLength;
  3202. data.set(item, pos);
  3203. pos += itemLength;
  3204. }
  3205. return data;
  3206. }
  3207. function string32(value) {
  3208. return String.fromCharCode(value >> 24 & 0xff, value >> 16 & 0xff, value >> 8 & 0xff, value & 0xff);
  3209. }
  3210. function log2(x) {
  3211. var n = 1, i = 0;
  3212. while (x > n) {
  3213. n <<= 1;
  3214. i++;
  3215. }
  3216. return i;
  3217. }
  3218. function readInt8(data, start) {
  3219. return data[start] << 24 >> 24;
  3220. }
  3221. function readUint16(data, offset) {
  3222. return data[offset] << 8 | data[offset + 1];
  3223. }
  3224. function readUint32(data, offset) {
  3225. return (data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3]) >>> 0;
  3226. }
  3227. function isLittleEndian() {
  3228. var buffer8 = new Uint8Array(2);
  3229. buffer8[0] = 1;
  3230. var buffer16 = new Uint16Array(buffer8.buffer);
  3231. return buffer16[0] === 1;
  3232. }
  3233. function isEvalSupported() {
  3234. try {
  3235. new Function('');
  3236. return true;
  3237. } catch (e) {
  3238. return false;
  3239. }
  3240. }
  3241. var Uint32ArrayView = function Uint32ArrayViewClosure() {
  3242. function Uint32ArrayView(buffer, length) {
  3243. this.buffer = buffer;
  3244. this.byteLength = buffer.length;
  3245. this.length = length === undefined ? this.byteLength >> 2 : length;
  3246. ensureUint32ArrayViewProps(this.length);
  3247. }
  3248. Uint32ArrayView.prototype = Object.create(null);
  3249. var uint32ArrayViewSetters = 0;
  3250. function createUint32ArrayProp(index) {
  3251. return {
  3252. get: function () {
  3253. var buffer = this.buffer, offset = index << 2;
  3254. return (buffer[offset] | buffer[offset + 1] << 8 | buffer[offset + 2] << 16 | buffer[offset + 3] << 24) >>> 0;
  3255. },
  3256. set: function (value) {
  3257. var buffer = this.buffer, offset = index << 2;
  3258. buffer[offset] = value & 255;
  3259. buffer[offset + 1] = value >> 8 & 255;
  3260. buffer[offset + 2] = value >> 16 & 255;
  3261. buffer[offset + 3] = value >>> 24 & 255;
  3262. }
  3263. };
  3264. }
  3265. function ensureUint32ArrayViewProps(length) {
  3266. while (uint32ArrayViewSetters < length) {
  3267. Object.defineProperty(Uint32ArrayView.prototype, uint32ArrayViewSetters, createUint32ArrayProp(uint32ArrayViewSetters));
  3268. uint32ArrayViewSetters++;
  3269. }
  3270. }
  3271. return Uint32ArrayView;
  3272. }();
  3273. exports.Uint32ArrayView = Uint32ArrayView;
  3274. var IDENTITY_MATRIX = [
  3275. 1,
  3276. 0,
  3277. 0,
  3278. 1,
  3279. 0,
  3280. 0
  3281. ];
  3282. var Util = function UtilClosure() {
  3283. function Util() {
  3284. }
  3285. var rgbBuf = [
  3286. 'rgb(',
  3287. 0,
  3288. ',',
  3289. 0,
  3290. ',',
  3291. 0,
  3292. ')'
  3293. ];
  3294. Util.makeCssRgb = function Util_makeCssRgb(r, g, b) {
  3295. rgbBuf[1] = r;
  3296. rgbBuf[3] = g;
  3297. rgbBuf[5] = b;
  3298. return rgbBuf.join('');
  3299. };
  3300. Util.transform = function Util_transform(m1, m2) {
  3301. return [
  3302. m1[0] * m2[0] + m1[2] * m2[1],
  3303. m1[1] * m2[0] + m1[3] * m2[1],
  3304. m1[0] * m2[2] + m1[2] * m2[3],
  3305. m1[1] * m2[2] + m1[3] * m2[3],
  3306. m1[0] * m2[4] + m1[2] * m2[5] + m1[4],
  3307. m1[1] * m2[4] + m1[3] * m2[5] + m1[5]
  3308. ];
  3309. };
  3310. Util.applyTransform = function Util_applyTransform(p, m) {
  3311. var xt = p[0] * m[0] + p[1] * m[2] + m[4];
  3312. var yt = p[0] * m[1] + p[1] * m[3] + m[5];
  3313. return [
  3314. xt,
  3315. yt
  3316. ];
  3317. };
  3318. Util.applyInverseTransform = function Util_applyInverseTransform(p, m) {
  3319. var d = m[0] * m[3] - m[1] * m[2];
  3320. var xt = (p[0] * m[3] - p[1] * m[2] + m[2] * m[5] - m[4] * m[3]) / d;
  3321. var yt = (-p[0] * m[1] + p[1] * m[0] + m[4] * m[1] - m[5] * m[0]) / d;
  3322. return [
  3323. xt,
  3324. yt
  3325. ];
  3326. };
  3327. Util.getAxialAlignedBoundingBox = function Util_getAxialAlignedBoundingBox(r, m) {
  3328. var p1 = Util.applyTransform(r, m);
  3329. var p2 = Util.applyTransform(r.slice(2, 4), m);
  3330. var p3 = Util.applyTransform([
  3331. r[0],
  3332. r[3]
  3333. ], m);
  3334. var p4 = Util.applyTransform([
  3335. r[2],
  3336. r[1]
  3337. ], m);
  3338. return [
  3339. Math.min(p1[0], p2[0], p3[0], p4[0]),
  3340. Math.min(p1[1], p2[1], p3[1], p4[1]),
  3341. Math.max(p1[0], p2[0], p3[0], p4[0]),
  3342. Math.max(p1[1], p2[1], p3[1], p4[1])
  3343. ];
  3344. };
  3345. Util.inverseTransform = function Util_inverseTransform(m) {
  3346. var d = m[0] * m[3] - m[1] * m[2];
  3347. return [
  3348. m[3] / d,
  3349. -m[1] / d,
  3350. -m[2] / d,
  3351. m[0] / d,
  3352. (m[2] * m[5] - m[4] * m[3]) / d,
  3353. (m[4] * m[1] - m[5] * m[0]) / d
  3354. ];
  3355. };
  3356. Util.apply3dTransform = function Util_apply3dTransform(m, v) {
  3357. return [
  3358. m[0] * v[0] + m[1] * v[1] + m[2] * v[2],
  3359. m[3] * v[0] + m[4] * v[1] + m[5] * v[2],
  3360. m[6] * v[0] + m[7] * v[1] + m[8] * v[2]
  3361. ];
  3362. };
  3363. Util.singularValueDecompose2dScale = function Util_singularValueDecompose2dScale(m) {
  3364. var transpose = [
  3365. m[0],
  3366. m[2],
  3367. m[1],
  3368. m[3]
  3369. ];
  3370. var a = m[0] * transpose[0] + m[1] * transpose[2];
  3371. var b = m[0] * transpose[1] + m[1] * transpose[3];
  3372. var c = m[2] * transpose[0] + m[3] * transpose[2];
  3373. var d = m[2] * transpose[1] + m[3] * transpose[3];
  3374. var first = (a + d) / 2;
  3375. var second = Math.sqrt((a + d) * (a + d) - 4 * (a * d - c * b)) / 2;
  3376. var sx = first + second || 1;
  3377. var sy = first - second || 1;
  3378. return [
  3379. Math.sqrt(sx),
  3380. Math.sqrt(sy)
  3381. ];
  3382. };
  3383. Util.normalizeRect = function Util_normalizeRect(rect) {
  3384. var r = rect.slice(0);
  3385. if (rect[0] > rect[2]) {
  3386. r[0] = rect[2];
  3387. r[2] = rect[0];
  3388. }
  3389. if (rect[1] > rect[3]) {
  3390. r[1] = rect[3];
  3391. r[3] = rect[1];
  3392. }
  3393. return r;
  3394. };
  3395. Util.intersect = function Util_intersect(rect1, rect2) {
  3396. function compare(a, b) {
  3397. return a - b;
  3398. }
  3399. var orderedX = [
  3400. rect1[0],
  3401. rect1[2],
  3402. rect2[0],
  3403. rect2[2]
  3404. ].sort(compare), orderedY = [
  3405. rect1[1],
  3406. rect1[3],
  3407. rect2[1],
  3408. rect2[3]
  3409. ].sort(compare), result = [];
  3410. rect1 = Util.normalizeRect(rect1);
  3411. rect2 = Util.normalizeRect(rect2);
  3412. if (orderedX[0] === rect1[0] && orderedX[1] === rect2[0] || orderedX[0] === rect2[0] && orderedX[1] === rect1[0]) {
  3413. result[0] = orderedX[1];
  3414. result[2] = orderedX[2];
  3415. } else {
  3416. return false;
  3417. }
  3418. if (orderedY[0] === rect1[1] && orderedY[1] === rect2[1] || orderedY[0] === rect2[1] && orderedY[1] === rect1[1]) {
  3419. result[1] = orderedY[1];
  3420. result[3] = orderedY[2];
  3421. } else {
  3422. return false;
  3423. }
  3424. return result;
  3425. };
  3426. Util.sign = function Util_sign(num) {
  3427. return num < 0 ? -1 : 1;
  3428. };
  3429. var ROMAN_NUMBER_MAP = [
  3430. '',
  3431. 'C',
  3432. 'CC',
  3433. 'CCC',
  3434. 'CD',
  3435. 'D',
  3436. 'DC',
  3437. 'DCC',
  3438. 'DCCC',
  3439. 'CM',
  3440. '',
  3441. 'X',
  3442. 'XX',
  3443. 'XXX',
  3444. 'XL',
  3445. 'L',
  3446. 'LX',
  3447. 'LXX',
  3448. 'LXXX',
  3449. 'XC',
  3450. '',
  3451. 'I',
  3452. 'II',
  3453. 'III',
  3454. 'IV',
  3455. 'V',
  3456. 'VI',
  3457. 'VII',
  3458. 'VIII',
  3459. 'IX'
  3460. ];
  3461. Util.toRoman = function Util_toRoman(number, lowerCase) {
  3462. assert(isInt(number) && number > 0, 'The number should be a positive integer.');
  3463. var pos, romanBuf = [];
  3464. while (number >= 1000) {
  3465. number -= 1000;
  3466. romanBuf.push('M');
  3467. }
  3468. pos = number / 100 | 0;
  3469. number %= 100;
  3470. romanBuf.push(ROMAN_NUMBER_MAP[pos]);
  3471. pos = number / 10 | 0;
  3472. number %= 10;
  3473. romanBuf.push(ROMAN_NUMBER_MAP[10 + pos]);
  3474. romanBuf.push(ROMAN_NUMBER_MAP[20 + number]);
  3475. var romanStr = romanBuf.join('');
  3476. return lowerCase ? romanStr.toLowerCase() : romanStr;
  3477. };
  3478. Util.appendToArray = function Util_appendToArray(arr1, arr2) {
  3479. Array.prototype.push.apply(arr1, arr2);
  3480. };
  3481. Util.prependToArray = function Util_prependToArray(arr1, arr2) {
  3482. Array.prototype.unshift.apply(arr1, arr2);
  3483. };
  3484. Util.extendObj = function extendObj(obj1, obj2) {
  3485. for (var key in obj2) {
  3486. obj1[key] = obj2[key];
  3487. }
  3488. };
  3489. Util.getInheritableProperty = function Util_getInheritableProperty(dict, name, getArray) {
  3490. while (dict && !dict.has(name)) {
  3491. dict = dict.get('Parent');
  3492. }
  3493. if (!dict) {
  3494. return null;
  3495. }
  3496. return getArray ? dict.getArray(name) : dict.get(name);
  3497. };
  3498. Util.inherit = function Util_inherit(sub, base, prototype) {
  3499. sub.prototype = Object.create(base.prototype);
  3500. sub.prototype.constructor = sub;
  3501. for (var prop in prototype) {
  3502. sub.prototype[prop] = prototype[prop];
  3503. }
  3504. };
  3505. Util.loadScript = function Util_loadScript(src, callback) {
  3506. var script = document.createElement('script');
  3507. var loaded = false;
  3508. script.setAttribute('src', src);
  3509. if (callback) {
  3510. script.onload = function () {
  3511. if (!loaded) {
  3512. callback();
  3513. }
  3514. loaded = true;
  3515. };
  3516. }
  3517. document.getElementsByTagName('head')[0].appendChild(script);
  3518. };
  3519. return Util;
  3520. }();
  3521. var PageViewport = function PageViewportClosure() {
  3522. function PageViewport(viewBox, scale, rotation, offsetX, offsetY, dontFlip) {
  3523. this.viewBox = viewBox;
  3524. this.scale = scale;
  3525. this.rotation = rotation;
  3526. this.offsetX = offsetX;
  3527. this.offsetY = offsetY;
  3528. var centerX = (viewBox[2] + viewBox[0]) / 2;
  3529. var centerY = (viewBox[3] + viewBox[1]) / 2;
  3530. var rotateA, rotateB, rotateC, rotateD;
  3531. rotation = rotation % 360;
  3532. rotation = rotation < 0 ? rotation + 360 : rotation;
  3533. switch (rotation) {
  3534. case 180:
  3535. rotateA = -1;
  3536. rotateB = 0;
  3537. rotateC = 0;
  3538. rotateD = 1;
  3539. break;
  3540. case 90:
  3541. rotateA = 0;
  3542. rotateB = 1;
  3543. rotateC = 1;
  3544. rotateD = 0;
  3545. break;
  3546. case 270:
  3547. rotateA = 0;
  3548. rotateB = -1;
  3549. rotateC = -1;
  3550. rotateD = 0;
  3551. break;
  3552. default:
  3553. rotateA = 1;
  3554. rotateB = 0;
  3555. rotateC = 0;
  3556. rotateD = -1;
  3557. break;
  3558. }
  3559. if (dontFlip) {
  3560. rotateC = -rotateC;
  3561. rotateD = -rotateD;
  3562. }
  3563. var offsetCanvasX, offsetCanvasY;
  3564. var width, height;
  3565. if (rotateA === 0) {
  3566. offsetCanvasX = Math.abs(centerY - viewBox[1]) * scale + offsetX;
  3567. offsetCanvasY = Math.abs(centerX - viewBox[0]) * scale + offsetY;
  3568. width = Math.abs(viewBox[3] - viewBox[1]) * scale;
  3569. height = Math.abs(viewBox[2] - viewBox[0]) * scale;
  3570. } else {
  3571. offsetCanvasX = Math.abs(centerX - viewBox[0]) * scale + offsetX;
  3572. offsetCanvasY = Math.abs(centerY - viewBox[1]) * scale + offsetY;
  3573. width = Math.abs(viewBox[2] - viewBox[0]) * scale;
  3574. height = Math.abs(viewBox[3] - viewBox[1]) * scale;
  3575. }
  3576. this.transform = [
  3577. rotateA * scale,
  3578. rotateB * scale,
  3579. rotateC * scale,
  3580. rotateD * scale,
  3581. offsetCanvasX - rotateA * scale * centerX - rotateC * scale * centerY,
  3582. offsetCanvasY - rotateB * scale * centerX - rotateD * scale * centerY
  3583. ];
  3584. this.width = width;
  3585. this.height = height;
  3586. this.fontScale = scale;
  3587. }
  3588. PageViewport.prototype = {
  3589. clone: function PageViewPort_clone(args) {
  3590. args = args || {};
  3591. var scale = 'scale' in args ? args.scale : this.scale;
  3592. var rotation = 'rotation' in args ? args.rotation : this.rotation;
  3593. return new PageViewport(this.viewBox.slice(), scale, rotation, this.offsetX, this.offsetY, args.dontFlip);
  3594. },
  3595. convertToViewportPoint: function PageViewport_convertToViewportPoint(x, y) {
  3596. return Util.applyTransform([
  3597. x,
  3598. y
  3599. ], this.transform);
  3600. },
  3601. convertToViewportRectangle: function PageViewport_convertToViewportRectangle(rect) {
  3602. var tl = Util.applyTransform([
  3603. rect[0],
  3604. rect[1]
  3605. ], this.transform);
  3606. var br = Util.applyTransform([
  3607. rect[2],
  3608. rect[3]
  3609. ], this.transform);
  3610. return [
  3611. tl[0],
  3612. tl[1],
  3613. br[0],
  3614. br[1]
  3615. ];
  3616. },
  3617. convertToPdfPoint: function PageViewport_convertToPdfPoint(x, y) {
  3618. return Util.applyInverseTransform([
  3619. x,
  3620. y
  3621. ], this.transform);
  3622. }
  3623. };
  3624. return PageViewport;
  3625. }();
  3626. var PDFStringTranslateTable = [
  3627. 0,
  3628. 0,
  3629. 0,
  3630. 0,
  3631. 0,
  3632. 0,
  3633. 0,
  3634. 0,
  3635. 0,
  3636. 0,
  3637. 0,
  3638. 0,
  3639. 0,
  3640. 0,
  3641. 0,
  3642. 0,
  3643. 0,
  3644. 0,
  3645. 0,
  3646. 0,
  3647. 0,
  3648. 0,
  3649. 0,
  3650. 0,
  3651. 0x2D8,
  3652. 0x2C7,
  3653. 0x2C6,
  3654. 0x2D9,
  3655. 0x2DD,
  3656. 0x2DB,
  3657. 0x2DA,
  3658. 0x2DC,
  3659. 0,
  3660. 0,
  3661. 0,
  3662. 0,
  3663. 0,
  3664. 0,
  3665. 0,
  3666. 0,
  3667. 0,
  3668. 0,
  3669. 0,
  3670. 0,
  3671. 0,
  3672. 0,
  3673. 0,
  3674. 0,
  3675. 0,
  3676. 0,
  3677. 0,
  3678. 0,
  3679. 0,
  3680. 0,
  3681. 0,
  3682. 0,
  3683. 0,
  3684. 0,
  3685. 0,
  3686. 0,
  3687. 0,
  3688. 0,
  3689. 0,
  3690. 0,
  3691. 0,
  3692. 0,
  3693. 0,
  3694. 0,
  3695. 0,
  3696. 0,
  3697. 0,
  3698. 0,
  3699. 0,
  3700. 0,
  3701. 0,
  3702. 0,
  3703. 0,
  3704. 0,
  3705. 0,
  3706. 0,
  3707. 0,
  3708. 0,
  3709. 0,
  3710. 0,
  3711. 0,
  3712. 0,
  3713. 0,
  3714. 0,
  3715. 0,
  3716. 0,
  3717. 0,
  3718. 0,
  3719. 0,
  3720. 0,
  3721. 0,
  3722. 0,
  3723. 0,
  3724. 0,
  3725. 0,
  3726. 0,
  3727. 0,
  3728. 0,
  3729. 0,
  3730. 0,
  3731. 0,
  3732. 0,
  3733. 0,
  3734. 0,
  3735. 0,
  3736. 0,
  3737. 0,
  3738. 0,
  3739. 0,
  3740. 0,
  3741. 0,
  3742. 0,
  3743. 0,
  3744. 0,
  3745. 0,
  3746. 0,
  3747. 0,
  3748. 0,
  3749. 0,
  3750. 0,
  3751. 0,
  3752. 0,
  3753. 0,
  3754. 0,
  3755. 0x2022,
  3756. 0x2020,
  3757. 0x2021,
  3758. 0x2026,
  3759. 0x2014,
  3760. 0x2013,
  3761. 0x192,
  3762. 0x2044,
  3763. 0x2039,
  3764. 0x203A,
  3765. 0x2212,
  3766. 0x2030,
  3767. 0x201E,
  3768. 0x201C,
  3769. 0x201D,
  3770. 0x2018,
  3771. 0x2019,
  3772. 0x201A,
  3773. 0x2122,
  3774. 0xFB01,
  3775. 0xFB02,
  3776. 0x141,
  3777. 0x152,
  3778. 0x160,
  3779. 0x178,
  3780. 0x17D,
  3781. 0x131,
  3782. 0x142,
  3783. 0x153,
  3784. 0x161,
  3785. 0x17E,
  3786. 0,
  3787. 0x20AC
  3788. ];
  3789. function stringToPDFString(str) {
  3790. var i, n = str.length, strBuf = [];
  3791. if (str[0] === '\xFE' && str[1] === '\xFF') {
  3792. for (i = 2; i < n; i += 2) {
  3793. strBuf.push(String.fromCharCode(str.charCodeAt(i) << 8 | str.charCodeAt(i + 1)));
  3794. }
  3795. } else {
  3796. for (i = 0; i < n; ++i) {
  3797. var code = PDFStringTranslateTable[str.charCodeAt(i)];
  3798. strBuf.push(code ? String.fromCharCode(code) : str.charAt(i));
  3799. }
  3800. }
  3801. return strBuf.join('');
  3802. }
  3803. function stringToUTF8String(str) {
  3804. return decodeURIComponent(escape(str));
  3805. }
  3806. function utf8StringToString(str) {
  3807. return unescape(encodeURIComponent(str));
  3808. }
  3809. function isEmptyObj(obj) {
  3810. for (var key in obj) {
  3811. return false;
  3812. }
  3813. return true;
  3814. }
  3815. function isBool(v) {
  3816. return typeof v === 'boolean';
  3817. }
  3818. function isInt(v) {
  3819. return typeof v === 'number' && (v | 0) === v;
  3820. }
  3821. function isNum(v) {
  3822. return typeof v === 'number';
  3823. }
  3824. function isString(v) {
  3825. return typeof v === 'string';
  3826. }
  3827. function isArray(v) {
  3828. return v instanceof Array;
  3829. }
  3830. function isArrayBuffer(v) {
  3831. return typeof v === 'object' && v !== null && v.byteLength !== undefined;
  3832. }
  3833. function isSpace(ch) {
  3834. return ch === 0x20 || ch === 0x09 || ch === 0x0D || ch === 0x0A;
  3835. }
  3836. function createPromiseCapability() {
  3837. var capability = {};
  3838. capability.promise = new Promise(function (resolve, reject) {
  3839. capability.resolve = resolve;
  3840. capability.reject = reject;
  3841. });
  3842. return capability;
  3843. }
  3844. (function PromiseClosure() {
  3845. if (globalScope.Promise) {
  3846. if (typeof globalScope.Promise.all !== 'function') {
  3847. globalScope.Promise.all = function (iterable) {
  3848. var count = 0, results = [], resolve, reject;
  3849. var promise = new globalScope.Promise(function (resolve_, reject_) {
  3850. resolve = resolve_;
  3851. reject = reject_;
  3852. });
  3853. iterable.forEach(function (p, i) {
  3854. count++;
  3855. p.then(function (result) {
  3856. results[i] = result;
  3857. count--;
  3858. if (count === 0) {
  3859. resolve(results);
  3860. }
  3861. }, reject);
  3862. });
  3863. if (count === 0) {
  3864. resolve(results);
  3865. }
  3866. return promise;
  3867. };
  3868. }
  3869. if (typeof globalScope.Promise.resolve !== 'function') {
  3870. globalScope.Promise.resolve = function (value) {
  3871. return new globalScope.Promise(function (resolve) {
  3872. resolve(value);
  3873. });
  3874. };
  3875. }
  3876. if (typeof globalScope.Promise.reject !== 'function') {
  3877. globalScope.Promise.reject = function (reason) {
  3878. return new globalScope.Promise(function (resolve, reject) {
  3879. reject(reason);
  3880. });
  3881. };
  3882. }
  3883. if (typeof globalScope.Promise.prototype.catch !== 'function') {
  3884. globalScope.Promise.prototype.catch = function (onReject) {
  3885. return globalScope.Promise.prototype.then(undefined, onReject);
  3886. };
  3887. }
  3888. return;
  3889. }
  3890. var STATUS_PENDING = 0;
  3891. var STATUS_RESOLVED = 1;
  3892. var STATUS_REJECTED = 2;
  3893. var REJECTION_TIMEOUT = 500;
  3894. var HandlerManager = {
  3895. handlers: [],
  3896. running: false,
  3897. unhandledRejections: [],
  3898. pendingRejectionCheck: false,
  3899. scheduleHandlers: function scheduleHandlers(promise) {
  3900. if (promise._status === STATUS_PENDING) {
  3901. return;
  3902. }
  3903. this.handlers = this.handlers.concat(promise._handlers);
  3904. promise._handlers = [];
  3905. if (this.running) {
  3906. return;
  3907. }
  3908. this.running = true;
  3909. setTimeout(this.runHandlers.bind(this), 0);
  3910. },
  3911. runHandlers: function runHandlers() {
  3912. var RUN_TIMEOUT = 1;
  3913. var timeoutAt = Date.now() + RUN_TIMEOUT;
  3914. while (this.handlers.length > 0) {
  3915. var handler = this.handlers.shift();
  3916. var nextStatus = handler.thisPromise._status;
  3917. var nextValue = handler.thisPromise._value;
  3918. try {
  3919. if (nextStatus === STATUS_RESOLVED) {
  3920. if (typeof handler.onResolve === 'function') {
  3921. nextValue = handler.onResolve(nextValue);
  3922. }
  3923. } else if (typeof handler.onReject === 'function') {
  3924. nextValue = handler.onReject(nextValue);
  3925. nextStatus = STATUS_RESOLVED;
  3926. if (handler.thisPromise._unhandledRejection) {
  3927. this.removeUnhandeledRejection(handler.thisPromise);
  3928. }
  3929. }
  3930. } catch (ex) {
  3931. nextStatus = STATUS_REJECTED;
  3932. nextValue = ex;
  3933. }
  3934. handler.nextPromise._updateStatus(nextStatus, nextValue);
  3935. if (Date.now() >= timeoutAt) {
  3936. break;
  3937. }
  3938. }
  3939. if (this.handlers.length > 0) {
  3940. setTimeout(this.runHandlers.bind(this), 0);
  3941. return;
  3942. }
  3943. this.running = false;
  3944. },
  3945. addUnhandledRejection: function addUnhandledRejection(promise) {
  3946. this.unhandledRejections.push({
  3947. promise: promise,
  3948. time: Date.now()
  3949. });
  3950. this.scheduleRejectionCheck();
  3951. },
  3952. removeUnhandeledRejection: function removeUnhandeledRejection(promise) {
  3953. promise._unhandledRejection = false;
  3954. for (var i = 0; i < this.unhandledRejections.length; i++) {
  3955. if (this.unhandledRejections[i].promise === promise) {
  3956. this.unhandledRejections.splice(i);
  3957. i--;
  3958. }
  3959. }
  3960. },
  3961. scheduleRejectionCheck: function scheduleRejectionCheck() {
  3962. if (this.pendingRejectionCheck) {
  3963. return;
  3964. }
  3965. this.pendingRejectionCheck = true;
  3966. setTimeout(function rejectionCheck() {
  3967. this.pendingRejectionCheck = false;
  3968. var now = Date.now();
  3969. for (var i = 0; i < this.unhandledRejections.length; i++) {
  3970. if (now - this.unhandledRejections[i].time > REJECTION_TIMEOUT) {
  3971. var unhandled = this.unhandledRejections[i].promise._value;
  3972. var msg = 'Unhandled rejection: ' + unhandled;
  3973. if (unhandled.stack) {
  3974. msg += '\n' + unhandled.stack;
  3975. }
  3976. warn(msg);
  3977. this.unhandledRejections.splice(i);
  3978. i--;
  3979. }
  3980. }
  3981. if (this.unhandledRejections.length) {
  3982. this.scheduleRejectionCheck();
  3983. }
  3984. }.bind(this), REJECTION_TIMEOUT);
  3985. }
  3986. };
  3987. var Promise = function Promise(resolver) {
  3988. this._status = STATUS_PENDING;
  3989. this._handlers = [];
  3990. try {
  3991. resolver.call(this, this._resolve.bind(this), this._reject.bind(this));
  3992. } catch (e) {
  3993. this._reject(e);
  3994. }
  3995. };
  3996. Promise.all = function Promise_all(promises) {
  3997. var resolveAll, rejectAll;
  3998. var deferred = new Promise(function (resolve, reject) {
  3999. resolveAll = resolve;
  4000. rejectAll = reject;
  4001. });
  4002. var unresolved = promises.length;
  4003. var results = [];
  4004. if (unresolved === 0) {
  4005. resolveAll(results);
  4006. return deferred;
  4007. }
  4008. function reject(reason) {
  4009. if (deferred._status === STATUS_REJECTED) {
  4010. return;
  4011. }
  4012. results = [];
  4013. rejectAll(reason);
  4014. }
  4015. for (var i = 0, ii = promises.length; i < ii; ++i) {
  4016. var promise = promises[i];
  4017. var resolve = function (i) {
  4018. return function (value) {
  4019. if (deferred._status === STATUS_REJECTED) {
  4020. return;
  4021. }
  4022. results[i] = value;
  4023. unresolved--;
  4024. if (unresolved === 0) {
  4025. resolveAll(results);
  4026. }
  4027. };
  4028. }(i);
  4029. if (Promise.isPromise(promise)) {
  4030. promise.then(resolve, reject);
  4031. } else {
  4032. resolve(promise);
  4033. }
  4034. }
  4035. return deferred;
  4036. };
  4037. Promise.isPromise = function Promise_isPromise(value) {
  4038. return value && typeof value.then === 'function';
  4039. };
  4040. Promise.resolve = function Promise_resolve(value) {
  4041. return new Promise(function (resolve) {
  4042. resolve(value);
  4043. });
  4044. };
  4045. Promise.reject = function Promise_reject(reason) {
  4046. return new Promise(function (resolve, reject) {
  4047. reject(reason);
  4048. });
  4049. };
  4050. Promise.prototype = {
  4051. _status: null,
  4052. _value: null,
  4053. _handlers: null,
  4054. _unhandledRejection: null,
  4055. _updateStatus: function Promise__updateStatus(status, value) {
  4056. if (this._status === STATUS_RESOLVED || this._status === STATUS_REJECTED) {
  4057. return;
  4058. }
  4059. if (status === STATUS_RESOLVED && Promise.isPromise(value)) {
  4060. value.then(this._updateStatus.bind(this, STATUS_RESOLVED), this._updateStatus.bind(this, STATUS_REJECTED));
  4061. return;
  4062. }
  4063. this._status = status;
  4064. this._value = value;
  4065. if (status === STATUS_REJECTED && this._handlers.length === 0) {
  4066. this._unhandledRejection = true;
  4067. HandlerManager.addUnhandledRejection(this);
  4068. }
  4069. HandlerManager.scheduleHandlers(this);
  4070. },
  4071. _resolve: function Promise_resolve(value) {
  4072. this._updateStatus(STATUS_RESOLVED, value);
  4073. },
  4074. _reject: function Promise_reject(reason) {
  4075. this._updateStatus(STATUS_REJECTED, reason);
  4076. },
  4077. then: function Promise_then(onResolve, onReject) {
  4078. var nextPromise = new Promise(function (resolve, reject) {
  4079. this.resolve = resolve;
  4080. this.reject = reject;
  4081. });
  4082. this._handlers.push({
  4083. thisPromise: this,
  4084. onResolve: onResolve,
  4085. onReject: onReject,
  4086. nextPromise: nextPromise
  4087. });
  4088. HandlerManager.scheduleHandlers(this);
  4089. return nextPromise;
  4090. },
  4091. catch: function Promise_catch(onReject) {
  4092. return this.then(undefined, onReject);
  4093. }
  4094. };
  4095. globalScope.Promise = Promise;
  4096. }());
  4097. (function WeakMapClosure() {
  4098. if (globalScope.WeakMap) {
  4099. return;
  4100. }
  4101. var id = 0;
  4102. function WeakMap() {
  4103. this.id = '$weakmap' + id++;
  4104. }
  4105. WeakMap.prototype = {
  4106. has: function (obj) {
  4107. return !!Object.getOwnPropertyDescriptor(obj, this.id);
  4108. },
  4109. get: function (obj, defaultValue) {
  4110. return this.has(obj) ? obj[this.id] : defaultValue;
  4111. },
  4112. set: function (obj, value) {
  4113. Object.defineProperty(obj, this.id, {
  4114. value: value,
  4115. enumerable: false,
  4116. configurable: true
  4117. });
  4118. },
  4119. delete: function (obj) {
  4120. delete obj[this.id];
  4121. }
  4122. };
  4123. globalScope.WeakMap = WeakMap;
  4124. }());
  4125. var StatTimer = function StatTimerClosure() {
  4126. function rpad(str, pad, length) {
  4127. while (str.length < length) {
  4128. str += pad;
  4129. }
  4130. return str;
  4131. }
  4132. function StatTimer() {
  4133. this.started = Object.create(null);
  4134. this.times = [];
  4135. this.enabled = true;
  4136. }
  4137. StatTimer.prototype = {
  4138. time: function StatTimer_time(name) {
  4139. if (!this.enabled) {
  4140. return;
  4141. }
  4142. if (name in this.started) {
  4143. warn('Timer is already running for ' + name);
  4144. }
  4145. this.started[name] = Date.now();
  4146. },
  4147. timeEnd: function StatTimer_timeEnd(name) {
  4148. if (!this.enabled) {
  4149. return;
  4150. }
  4151. if (!(name in this.started)) {
  4152. warn('Timer has not been started for ' + name);
  4153. }
  4154. this.times.push({
  4155. 'name': name,
  4156. 'start': this.started[name],
  4157. 'end': Date.now()
  4158. });
  4159. delete this.started[name];
  4160. },
  4161. toString: function StatTimer_toString() {
  4162. var i, ii;
  4163. var times = this.times;
  4164. var out = '';
  4165. var longest = 0;
  4166. for (i = 0, ii = times.length; i < ii; ++i) {
  4167. var name = times[i]['name'];
  4168. if (name.length > longest) {
  4169. longest = name.length;
  4170. }
  4171. }
  4172. for (i = 0, ii = times.length; i < ii; ++i) {
  4173. var span = times[i];
  4174. var duration = span.end - span.start;
  4175. out += rpad(span['name'], ' ', longest) + ' ' + duration + 'ms\n';
  4176. }
  4177. return out;
  4178. }
  4179. };
  4180. return StatTimer;
  4181. }();
  4182. var createBlob = function createBlob(data, contentType) {
  4183. if (typeof Blob !== 'undefined') {
  4184. return new Blob([data], { type: contentType });
  4185. }
  4186. warn('The "Blob" constructor is not supported.');
  4187. };
  4188. var createObjectURL = function createObjectURLClosure() {
  4189. var digits = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';
  4190. return function createObjectURL(data, contentType, forceDataSchema) {
  4191. if (!forceDataSchema && typeof URL !== 'undefined' && URL.createObjectURL) {
  4192. var blob = createBlob(data, contentType);
  4193. return URL.createObjectURL(blob);
  4194. }
  4195. var buffer = 'data:' + contentType + ';base64,';
  4196. for (var i = 0, ii = data.length; i < ii; i += 3) {
  4197. var b1 = data[i] & 0xFF;
  4198. var b2 = data[i + 1] & 0xFF;
  4199. var b3 = data[i + 2] & 0xFF;
  4200. var d1 = b1 >> 2, d2 = (b1 & 3) << 4 | b2 >> 4;
  4201. var d3 = i + 1 < ii ? (b2 & 0xF) << 2 | b3 >> 6 : 64;
  4202. var d4 = i + 2 < ii ? b3 & 0x3F : 64;
  4203. buffer += digits[d1] + digits[d2] + digits[d3] + digits[d4];
  4204. }
  4205. return buffer;
  4206. };
  4207. }();
  4208. function MessageHandler(sourceName, targetName, comObj) {
  4209. this.sourceName = sourceName;
  4210. this.targetName = targetName;
  4211. this.comObj = comObj;
  4212. this.callbackIndex = 1;
  4213. this.postMessageTransfers = true;
  4214. var callbacksCapabilities = this.callbacksCapabilities = Object.create(null);
  4215. var ah = this.actionHandler = Object.create(null);
  4216. this._onComObjOnMessage = function messageHandlerComObjOnMessage(event) {
  4217. var data = event.data;
  4218. if (data.targetName !== this.sourceName) {
  4219. return;
  4220. }
  4221. if (data.isReply) {
  4222. var callbackId = data.callbackId;
  4223. if (data.callbackId in callbacksCapabilities) {
  4224. var callback = callbacksCapabilities[callbackId];
  4225. delete callbacksCapabilities[callbackId];
  4226. if ('error' in data) {
  4227. callback.reject(data.error);
  4228. } else {
  4229. callback.resolve(data.data);
  4230. }
  4231. } else {
  4232. error('Cannot resolve callback ' + callbackId);
  4233. }
  4234. } else if (data.action in ah) {
  4235. var action = ah[data.action];
  4236. if (data.callbackId) {
  4237. var sourceName = this.sourceName;
  4238. var targetName = data.sourceName;
  4239. Promise.resolve().then(function () {
  4240. return action[0].call(action[1], data.data);
  4241. }).then(function (result) {
  4242. comObj.postMessage({
  4243. sourceName: sourceName,
  4244. targetName: targetName,
  4245. isReply: true,
  4246. callbackId: data.callbackId,
  4247. data: result
  4248. });
  4249. }, function (reason) {
  4250. if (reason instanceof Error) {
  4251. reason = reason + '';
  4252. }
  4253. comObj.postMessage({
  4254. sourceName: sourceName,
  4255. targetName: targetName,
  4256. isReply: true,
  4257. callbackId: data.callbackId,
  4258. error: reason
  4259. });
  4260. });
  4261. } else {
  4262. action[0].call(action[1], data.data);
  4263. }
  4264. } else {
  4265. error('Unknown action from worker: ' + data.action);
  4266. }
  4267. }.bind(this);
  4268. comObj.addEventListener('message', this._onComObjOnMessage);
  4269. }
  4270. MessageHandler.prototype = {
  4271. on: function messageHandlerOn(actionName, handler, scope) {
  4272. var ah = this.actionHandler;
  4273. if (ah[actionName]) {
  4274. error('There is already an actionName called "' + actionName + '"');
  4275. }
  4276. ah[actionName] = [
  4277. handler,
  4278. scope
  4279. ];
  4280. },
  4281. send: function messageHandlerSend(actionName, data, transfers) {
  4282. var message = {
  4283. sourceName: this.sourceName,
  4284. targetName: this.targetName,
  4285. action: actionName,
  4286. data: data
  4287. };
  4288. this.postMessage(message, transfers);
  4289. },
  4290. sendWithPromise: function messageHandlerSendWithPromise(actionName, data, transfers) {
  4291. var callbackId = this.callbackIndex++;
  4292. var message = {
  4293. sourceName: this.sourceName,
  4294. targetName: this.targetName,
  4295. action: actionName,
  4296. data: data,
  4297. callbackId: callbackId
  4298. };
  4299. var capability = createPromiseCapability();
  4300. this.callbacksCapabilities[callbackId] = capability;
  4301. try {
  4302. this.postMessage(message, transfers);
  4303. } catch (e) {
  4304. capability.reject(e);
  4305. }
  4306. return capability.promise;
  4307. },
  4308. postMessage: function (message, transfers) {
  4309. if (transfers && this.postMessageTransfers) {
  4310. this.comObj.postMessage(message, transfers);
  4311. } else {
  4312. this.comObj.postMessage(message);
  4313. }
  4314. },
  4315. destroy: function () {
  4316. this.comObj.removeEventListener('message', this._onComObjOnMessage);
  4317. }
  4318. };
  4319. function loadJpegStream(id, imageUrl, objs) {
  4320. var img = new Image();
  4321. img.onload = function loadJpegStream_onloadClosure() {
  4322. objs.resolve(id, img);
  4323. };
  4324. img.onerror = function loadJpegStream_onerrorClosure() {
  4325. objs.resolve(id, null);
  4326. warn('Error during JPEG image loading');
  4327. };
  4328. img.src = imageUrl;
  4329. }
  4330. /* Any copyright is dedicated to the Public Domain.
  4331. * http://creativecommons.org/publicdomain/zero/1.0/ */
  4332. (function checkURLConstructor(scope) {
  4333. var hasWorkingUrl = false;
  4334. try {
  4335. if (typeof URL === 'function' && typeof URL.prototype === 'object' && 'origin' in URL.prototype) {
  4336. var u = new URL('b', 'http://a');
  4337. u.pathname = 'c%20d';
  4338. hasWorkingUrl = u.href === 'http://a/c%20d';
  4339. }
  4340. } catch (e) {
  4341. }
  4342. if (hasWorkingUrl) {
  4343. return;
  4344. }
  4345. var relative = Object.create(null);
  4346. relative['ftp'] = 21;
  4347. relative['file'] = 0;
  4348. relative['gopher'] = 70;
  4349. relative['http'] = 80;
  4350. relative['https'] = 443;
  4351. relative['ws'] = 80;
  4352. relative['wss'] = 443;
  4353. var relativePathDotMapping = Object.create(null);
  4354. relativePathDotMapping['%2e'] = '.';
  4355. relativePathDotMapping['.%2e'] = '..';
  4356. relativePathDotMapping['%2e.'] = '..';
  4357. relativePathDotMapping['%2e%2e'] = '..';
  4358. function isRelativeScheme(scheme) {
  4359. return relative[scheme] !== undefined;
  4360. }
  4361. function invalid() {
  4362. clear.call(this);
  4363. this._isInvalid = true;
  4364. }
  4365. function IDNAToASCII(h) {
  4366. if ('' === h) {
  4367. invalid.call(this);
  4368. }
  4369. return h.toLowerCase();
  4370. }
  4371. function percentEscape(c) {
  4372. var unicode = c.charCodeAt(0);
  4373. if (unicode > 0x20 && unicode < 0x7F && [
  4374. 0x22,
  4375. 0x23,
  4376. 0x3C,
  4377. 0x3E,
  4378. 0x3F,
  4379. 0x60
  4380. ].indexOf(unicode) === -1) {
  4381. return c;
  4382. }
  4383. return encodeURIComponent(c);
  4384. }
  4385. function percentEscapeQuery(c) {
  4386. var unicode = c.charCodeAt(0);
  4387. if (unicode > 0x20 && unicode < 0x7F && [
  4388. 0x22,
  4389. 0x23,
  4390. 0x3C,
  4391. 0x3E,
  4392. 0x60
  4393. ].indexOf(unicode) === -1) {
  4394. return c;
  4395. }
  4396. return encodeURIComponent(c);
  4397. }
  4398. var EOF, ALPHA = /[a-zA-Z]/, ALPHANUMERIC = /[a-zA-Z0-9\+\-\.]/;
  4399. function parse(input, stateOverride, base) {
  4400. function err(message) {
  4401. errors.push(message);
  4402. }
  4403. var state = stateOverride || 'scheme start', cursor = 0, buffer = '', seenAt = false, seenBracket = false, errors = [];
  4404. loop:
  4405. while ((input[cursor - 1] !== EOF || cursor === 0) && !this._isInvalid) {
  4406. var c = input[cursor];
  4407. switch (state) {
  4408. case 'scheme start':
  4409. if (c && ALPHA.test(c)) {
  4410. buffer += c.toLowerCase();
  4411. state = 'scheme';
  4412. } else if (!stateOverride) {
  4413. buffer = '';
  4414. state = 'no scheme';
  4415. continue;
  4416. } else {
  4417. err('Invalid scheme.');
  4418. break loop;
  4419. }
  4420. break;
  4421. case 'scheme':
  4422. if (c && ALPHANUMERIC.test(c)) {
  4423. buffer += c.toLowerCase();
  4424. } else if (':' === c) {
  4425. this._scheme = buffer;
  4426. buffer = '';
  4427. if (stateOverride) {
  4428. break loop;
  4429. }
  4430. if (isRelativeScheme(this._scheme)) {
  4431. this._isRelative = true;
  4432. }
  4433. if ('file' === this._scheme) {
  4434. state = 'relative';
  4435. } else if (this._isRelative && base && base._scheme === this._scheme) {
  4436. state = 'relative or authority';
  4437. } else if (this._isRelative) {
  4438. state = 'authority first slash';
  4439. } else {
  4440. state = 'scheme data';
  4441. }
  4442. } else if (!stateOverride) {
  4443. buffer = '';
  4444. cursor = 0;
  4445. state = 'no scheme';
  4446. continue;
  4447. } else if (EOF === c) {
  4448. break loop;
  4449. } else {
  4450. err('Code point not allowed in scheme: ' + c);
  4451. break loop;
  4452. }
  4453. break;
  4454. case 'scheme data':
  4455. if ('?' === c) {
  4456. this._query = '?';
  4457. state = 'query';
  4458. } else if ('#' === c) {
  4459. this._fragment = '#';
  4460. state = 'fragment';
  4461. } else {
  4462. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4463. this._schemeData += percentEscape(c);
  4464. }
  4465. }
  4466. break;
  4467. case 'no scheme':
  4468. if (!base || !isRelativeScheme(base._scheme)) {
  4469. err('Missing scheme.');
  4470. invalid.call(this);
  4471. } else {
  4472. state = 'relative';
  4473. continue;
  4474. }
  4475. break;
  4476. case 'relative or authority':
  4477. if ('/' === c && '/' === input[cursor + 1]) {
  4478. state = 'authority ignore slashes';
  4479. } else {
  4480. err('Expected /, got: ' + c);
  4481. state = 'relative';
  4482. continue;
  4483. }
  4484. break;
  4485. case 'relative':
  4486. this._isRelative = true;
  4487. if ('file' !== this._scheme) {
  4488. this._scheme = base._scheme;
  4489. }
  4490. if (EOF === c) {
  4491. this._host = base._host;
  4492. this._port = base._port;
  4493. this._path = base._path.slice();
  4494. this._query = base._query;
  4495. this._username = base._username;
  4496. this._password = base._password;
  4497. break loop;
  4498. } else if ('/' === c || '\\' === c) {
  4499. if ('\\' === c) {
  4500. err('\\ is an invalid code point.');
  4501. }
  4502. state = 'relative slash';
  4503. } else if ('?' === c) {
  4504. this._host = base._host;
  4505. this._port = base._port;
  4506. this._path = base._path.slice();
  4507. this._query = '?';
  4508. this._username = base._username;
  4509. this._password = base._password;
  4510. state = 'query';
  4511. } else if ('#' === c) {
  4512. this._host = base._host;
  4513. this._port = base._port;
  4514. this._path = base._path.slice();
  4515. this._query = base._query;
  4516. this._fragment = '#';
  4517. this._username = base._username;
  4518. this._password = base._password;
  4519. state = 'fragment';
  4520. } else {
  4521. var nextC = input[cursor + 1];
  4522. var nextNextC = input[cursor + 2];
  4523. if ('file' !== this._scheme || !ALPHA.test(c) || nextC !== ':' && nextC !== '|' || EOF !== nextNextC && '/' !== nextNextC && '\\' !== nextNextC && '?' !== nextNextC && '#' !== nextNextC) {
  4524. this._host = base._host;
  4525. this._port = base._port;
  4526. this._username = base._username;
  4527. this._password = base._password;
  4528. this._path = base._path.slice();
  4529. this._path.pop();
  4530. }
  4531. state = 'relative path';
  4532. continue;
  4533. }
  4534. break;
  4535. case 'relative slash':
  4536. if ('/' === c || '\\' === c) {
  4537. if ('\\' === c) {
  4538. err('\\ is an invalid code point.');
  4539. }
  4540. if ('file' === this._scheme) {
  4541. state = 'file host';
  4542. } else {
  4543. state = 'authority ignore slashes';
  4544. }
  4545. } else {
  4546. if ('file' !== this._scheme) {
  4547. this._host = base._host;
  4548. this._port = base._port;
  4549. this._username = base._username;
  4550. this._password = base._password;
  4551. }
  4552. state = 'relative path';
  4553. continue;
  4554. }
  4555. break;
  4556. case 'authority first slash':
  4557. if ('/' === c) {
  4558. state = 'authority second slash';
  4559. } else {
  4560. err('Expected \'/\', got: ' + c);
  4561. state = 'authority ignore slashes';
  4562. continue;
  4563. }
  4564. break;
  4565. case 'authority second slash':
  4566. state = 'authority ignore slashes';
  4567. if ('/' !== c) {
  4568. err('Expected \'/\', got: ' + c);
  4569. continue;
  4570. }
  4571. break;
  4572. case 'authority ignore slashes':
  4573. if ('/' !== c && '\\' !== c) {
  4574. state = 'authority';
  4575. continue;
  4576. } else {
  4577. err('Expected authority, got: ' + c);
  4578. }
  4579. break;
  4580. case 'authority':
  4581. if ('@' === c) {
  4582. if (seenAt) {
  4583. err('@ already seen.');
  4584. buffer += '%40';
  4585. }
  4586. seenAt = true;
  4587. for (var i = 0; i < buffer.length; i++) {
  4588. var cp = buffer[i];
  4589. if ('\t' === cp || '\n' === cp || '\r' === cp) {
  4590. err('Invalid whitespace in authority.');
  4591. continue;
  4592. }
  4593. if (':' === cp && null === this._password) {
  4594. this._password = '';
  4595. continue;
  4596. }
  4597. var tempC = percentEscape(cp);
  4598. if (null !== this._password) {
  4599. this._password += tempC;
  4600. } else {
  4601. this._username += tempC;
  4602. }
  4603. }
  4604. buffer = '';
  4605. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  4606. cursor -= buffer.length;
  4607. buffer = '';
  4608. state = 'host';
  4609. continue;
  4610. } else {
  4611. buffer += c;
  4612. }
  4613. break;
  4614. case 'file host':
  4615. if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  4616. if (buffer.length === 2 && ALPHA.test(buffer[0]) && (buffer[1] === ':' || buffer[1] === '|')) {
  4617. state = 'relative path';
  4618. } else if (buffer.length === 0) {
  4619. state = 'relative path start';
  4620. } else {
  4621. this._host = IDNAToASCII.call(this, buffer);
  4622. buffer = '';
  4623. state = 'relative path start';
  4624. }
  4625. continue;
  4626. } else if ('\t' === c || '\n' === c || '\r' === c) {
  4627. err('Invalid whitespace in file host.');
  4628. } else {
  4629. buffer += c;
  4630. }
  4631. break;
  4632. case 'host':
  4633. case 'hostname':
  4634. if (':' === c && !seenBracket) {
  4635. this._host = IDNAToASCII.call(this, buffer);
  4636. buffer = '';
  4637. state = 'port';
  4638. if ('hostname' === stateOverride) {
  4639. break loop;
  4640. }
  4641. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c) {
  4642. this._host = IDNAToASCII.call(this, buffer);
  4643. buffer = '';
  4644. state = 'relative path start';
  4645. if (stateOverride) {
  4646. break loop;
  4647. }
  4648. continue;
  4649. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  4650. if ('[' === c) {
  4651. seenBracket = true;
  4652. } else if (']' === c) {
  4653. seenBracket = false;
  4654. }
  4655. buffer += c;
  4656. } else {
  4657. err('Invalid code point in host/hostname: ' + c);
  4658. }
  4659. break;
  4660. case 'port':
  4661. if (/[0-9]/.test(c)) {
  4662. buffer += c;
  4663. } else if (EOF === c || '/' === c || '\\' === c || '?' === c || '#' === c || stateOverride) {
  4664. if ('' !== buffer) {
  4665. var temp = parseInt(buffer, 10);
  4666. if (temp !== relative[this._scheme]) {
  4667. this._port = temp + '';
  4668. }
  4669. buffer = '';
  4670. }
  4671. if (stateOverride) {
  4672. break loop;
  4673. }
  4674. state = 'relative path start';
  4675. continue;
  4676. } else if ('\t' === c || '\n' === c || '\r' === c) {
  4677. err('Invalid code point in port: ' + c);
  4678. } else {
  4679. invalid.call(this);
  4680. }
  4681. break;
  4682. case 'relative path start':
  4683. if ('\\' === c) {
  4684. err('\'\\\' not allowed in path.');
  4685. }
  4686. state = 'relative path';
  4687. if ('/' !== c && '\\' !== c) {
  4688. continue;
  4689. }
  4690. break;
  4691. case 'relative path':
  4692. if (EOF === c || '/' === c || '\\' === c || !stateOverride && ('?' === c || '#' === c)) {
  4693. if ('\\' === c) {
  4694. err('\\ not allowed in relative path.');
  4695. }
  4696. var tmp;
  4697. if (tmp = relativePathDotMapping[buffer.toLowerCase()]) {
  4698. buffer = tmp;
  4699. }
  4700. if ('..' === buffer) {
  4701. this._path.pop();
  4702. if ('/' !== c && '\\' !== c) {
  4703. this._path.push('');
  4704. }
  4705. } else if ('.' === buffer && '/' !== c && '\\' !== c) {
  4706. this._path.push('');
  4707. } else if ('.' !== buffer) {
  4708. if ('file' === this._scheme && this._path.length === 0 && buffer.length === 2 && ALPHA.test(buffer[0]) && buffer[1] === '|') {
  4709. buffer = buffer[0] + ':';
  4710. }
  4711. this._path.push(buffer);
  4712. }
  4713. buffer = '';
  4714. if ('?' === c) {
  4715. this._query = '?';
  4716. state = 'query';
  4717. } else if ('#' === c) {
  4718. this._fragment = '#';
  4719. state = 'fragment';
  4720. }
  4721. } else if ('\t' !== c && '\n' !== c && '\r' !== c) {
  4722. buffer += percentEscape(c);
  4723. }
  4724. break;
  4725. case 'query':
  4726. if (!stateOverride && '#' === c) {
  4727. this._fragment = '#';
  4728. state = 'fragment';
  4729. } else if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4730. this._query += percentEscapeQuery(c);
  4731. }
  4732. break;
  4733. case 'fragment':
  4734. if (EOF !== c && '\t' !== c && '\n' !== c && '\r' !== c) {
  4735. this._fragment += c;
  4736. }
  4737. break;
  4738. }
  4739. cursor++;
  4740. }
  4741. }
  4742. function clear() {
  4743. this._scheme = '';
  4744. this._schemeData = '';
  4745. this._username = '';
  4746. this._password = null;
  4747. this._host = '';
  4748. this._port = '';
  4749. this._path = [];
  4750. this._query = '';
  4751. this._fragment = '';
  4752. this._isInvalid = false;
  4753. this._isRelative = false;
  4754. }
  4755. function JURL(url, base)
  4756. {
  4757. if (base !== undefined && !(base instanceof JURL)) {
  4758. base = new JURL(String(base));
  4759. }
  4760. this._url = url;
  4761. clear.call(this);
  4762. var input = url.replace(/^[ \t\r\n\f]+|[ \t\r\n\f]+$/g, '');
  4763. parse.call(this, input, null, base);
  4764. }
  4765. JURL.prototype = {
  4766. toString: function () {
  4767. return this.href;
  4768. },
  4769. get href() {
  4770. if (this._isInvalid) {
  4771. return this._url;
  4772. }
  4773. var authority = '';
  4774. if ('' !== this._username || null !== this._password) {
  4775. authority = this._username + (null !== this._password ? ':' + this._password : '') + '@';
  4776. }
  4777. return this.protocol + (this._isRelative ? '//' + authority + this.host : '') + this.pathname + this._query + this._fragment;
  4778. },
  4779. set href(href) {
  4780. clear.call(this);
  4781. parse.call(this, href);
  4782. },
  4783. get protocol() {
  4784. return this._scheme + ':';
  4785. },
  4786. set protocol(protocol) {
  4787. if (this._isInvalid) {
  4788. return;
  4789. }
  4790. parse.call(this, protocol + ':', 'scheme start');
  4791. },
  4792. get host() {
  4793. return this._isInvalid ? '' : this._port ? this._host + ':' + this._port : this._host;
  4794. },
  4795. set host(host) {
  4796. if (this._isInvalid || !this._isRelative) {
  4797. return;
  4798. }
  4799. parse.call(this, host, 'host');
  4800. },
  4801. get hostname() {
  4802. return this._host;
  4803. },
  4804. set hostname(hostname) {
  4805. if (this._isInvalid || !this._isRelative) {
  4806. return;
  4807. }
  4808. parse.call(this, hostname, 'hostname');
  4809. },
  4810. get port() {
  4811. return this._port;
  4812. },
  4813. set port(port) {
  4814. if (this._isInvalid || !this._isRelative) {
  4815. return;
  4816. }
  4817. parse.call(this, port, 'port');
  4818. },
  4819. get pathname() {
  4820. return this._isInvalid ? '' : this._isRelative ? '/' + this._path.join('/') : this._schemeData;
  4821. },
  4822. set pathname(pathname) {
  4823. if (this._isInvalid || !this._isRelative) {
  4824. return;
  4825. }
  4826. this._path = [];
  4827. parse.call(this, pathname, 'relative path start');
  4828. },
  4829. get search() {
  4830. return this._isInvalid || !this._query || '?' === this._query ? '' : this._query;
  4831. },
  4832. set search(search) {
  4833. if (this._isInvalid || !this._isRelative) {
  4834. return;
  4835. }
  4836. this._query = '?';
  4837. if ('?' === search[0]) {
  4838. search = search.slice(1);
  4839. }
  4840. parse.call(this, search, 'query');
  4841. },
  4842. get hash() {
  4843. return this._isInvalid || !this._fragment || '#' === this._fragment ? '' : this._fragment;
  4844. },
  4845. set hash(hash) {
  4846. if (this._isInvalid) {
  4847. return;
  4848. }
  4849. this._fragment = '#';
  4850. if ('#' === hash[0]) {
  4851. hash = hash.slice(1);
  4852. }
  4853. parse.call(this, hash, 'fragment');
  4854. },
  4855. get origin() {
  4856. var host;
  4857. if (this._isInvalid || !this._scheme) {
  4858. return '';
  4859. }
  4860. switch (this._scheme) {
  4861. case 'data':
  4862. case 'file':
  4863. case 'javascript':
  4864. case 'mailto':
  4865. return 'null';
  4866. }
  4867. host = this.host;
  4868. if (!host) {
  4869. return '';
  4870. }
  4871. return this._scheme + '://' + host;
  4872. }
  4873. };
  4874. var OriginalURL = scope.URL;
  4875. if (OriginalURL) {
  4876. JURL.createObjectURL = function (blob) {
  4877. return OriginalURL.createObjectURL.apply(OriginalURL, arguments);
  4878. };
  4879. JURL.revokeObjectURL = function (url) {
  4880. OriginalURL.revokeObjectURL(url);
  4881. };
  4882. }
  4883. scope.URL = JURL;
  4884. }(globalScope));
  4885. exports.FONT_IDENTITY_MATRIX = FONT_IDENTITY_MATRIX;
  4886. exports.IDENTITY_MATRIX = IDENTITY_MATRIX;
  4887. exports.OPS = OPS;
  4888. exports.VERBOSITY_LEVELS = VERBOSITY_LEVELS;
  4889. exports.UNSUPPORTED_FEATURES = UNSUPPORTED_FEATURES;
  4890. exports.AnnotationBorderStyleType = AnnotationBorderStyleType;
  4891. exports.AnnotationFieldFlag = AnnotationFieldFlag;
  4892. exports.AnnotationFlag = AnnotationFlag;
  4893. exports.AnnotationType = AnnotationType;
  4894. exports.FontType = FontType;
  4895. exports.ImageKind = ImageKind;
  4896. exports.InvalidPDFException = InvalidPDFException;
  4897. exports.MessageHandler = MessageHandler;
  4898. exports.MissingDataException = MissingDataException;
  4899. exports.MissingPDFException = MissingPDFException;
  4900. exports.NotImplementedException = NotImplementedException;
  4901. exports.PageViewport = PageViewport;
  4902. exports.PasswordException = PasswordException;
  4903. exports.PasswordResponses = PasswordResponses;
  4904. exports.StatTimer = StatTimer;
  4905. exports.StreamType = StreamType;
  4906. exports.TextRenderingMode = TextRenderingMode;
  4907. exports.UnexpectedResponseException = UnexpectedResponseException;
  4908. exports.UnknownErrorException = UnknownErrorException;
  4909. exports.Util = Util;
  4910. exports.XRefParseException = XRefParseException;
  4911. exports.arrayByteLength = arrayByteLength;
  4912. exports.arraysToBytes = arraysToBytes;
  4913. exports.assert = assert;
  4914. exports.bytesToString = bytesToString;
  4915. exports.createBlob = createBlob;
  4916. exports.createPromiseCapability = createPromiseCapability;
  4917. exports.createObjectURL = createObjectURL;
  4918. exports.deprecated = deprecated;
  4919. exports.error = error;
  4920. exports.getLookupTableFactory = getLookupTableFactory;
  4921. exports.getVerbosityLevel = getVerbosityLevel;
  4922. exports.globalScope = globalScope;
  4923. exports.info = info;
  4924. exports.isArray = isArray;
  4925. exports.isArrayBuffer = isArrayBuffer;
  4926. exports.isBool = isBool;
  4927. exports.isEmptyObj = isEmptyObj;
  4928. exports.isInt = isInt;
  4929. exports.isNum = isNum;
  4930. exports.isString = isString;
  4931. exports.isSpace = isSpace;
  4932. exports.isSameOrigin = isSameOrigin;
  4933. exports.createValidAbsoluteUrl = createValidAbsoluteUrl;
  4934. exports.isLittleEndian = isLittleEndian;
  4935. exports.isEvalSupported = isEvalSupported;
  4936. exports.loadJpegStream = loadJpegStream;
  4937. exports.log2 = log2;
  4938. exports.readInt8 = readInt8;
  4939. exports.readUint16 = readUint16;
  4940. exports.readUint32 = readUint32;
  4941. exports.removeNullCharacters = removeNullCharacters;
  4942. exports.setVerbosityLevel = setVerbosityLevel;
  4943. exports.shadow = shadow;
  4944. exports.string32 = string32;
  4945. exports.stringToBytes = stringToBytes;
  4946. exports.stringToPDFString = stringToPDFString;
  4947. exports.stringToUTF8String = stringToUTF8String;
  4948. exports.utf8StringToString = utf8StringToString;
  4949. exports.warn = warn;
  4950. }));
  4951. (function (root, factory) {
  4952. factory(root.pdfjsCoreBidi = {}, root.pdfjsSharedUtil);
  4953. }(this, function (exports, sharedUtil) {
  4954. var warn = sharedUtil.warn;
  4955. var baseTypes = [
  4956. 'BN',
  4957. 'BN',
  4958. 'BN',
  4959. 'BN',
  4960. 'BN',
  4961. 'BN',
  4962. 'BN',
  4963. 'BN',
  4964. 'BN',
  4965. 'S',
  4966. 'B',
  4967. 'S',
  4968. 'WS',
  4969. 'B',
  4970. 'BN',
  4971. 'BN',
  4972. 'BN',
  4973. 'BN',
  4974. 'BN',
  4975. 'BN',
  4976. 'BN',
  4977. 'BN',
  4978. 'BN',
  4979. 'BN',
  4980. 'BN',
  4981. 'BN',
  4982. 'BN',
  4983. 'BN',
  4984. 'B',
  4985. 'B',
  4986. 'B',
  4987. 'S',
  4988. 'WS',
  4989. 'ON',
  4990. 'ON',
  4991. 'ET',
  4992. 'ET',
  4993. 'ET',
  4994. 'ON',
  4995. 'ON',
  4996. 'ON',
  4997. 'ON',
  4998. 'ON',
  4999. 'ES',
  5000. 'CS',
  5001. 'ES',
  5002. 'CS',
  5003. 'CS',
  5004. 'EN',
  5005. 'EN',
  5006. 'EN',
  5007. 'EN',
  5008. 'EN',
  5009. 'EN',
  5010. 'EN',
  5011. 'EN',
  5012. 'EN',
  5013. 'EN',
  5014. 'CS',
  5015. 'ON',
  5016. 'ON',
  5017. 'ON',
  5018. 'ON',
  5019. 'ON',
  5020. 'ON',
  5021. 'L',
  5022. 'L',
  5023. 'L',
  5024. 'L',
  5025. 'L',
  5026. 'L',
  5027. 'L',
  5028. 'L',
  5029. 'L',
  5030. 'L',
  5031. 'L',
  5032. 'L',
  5033. 'L',
  5034. 'L',
  5035. 'L',
  5036. 'L',
  5037. 'L',
  5038. 'L',
  5039. 'L',
  5040. 'L',
  5041. 'L',
  5042. 'L',
  5043. 'L',
  5044. 'L',
  5045. 'L',
  5046. 'L',
  5047. 'ON',
  5048. 'ON',
  5049. 'ON',
  5050. 'ON',
  5051. 'ON',
  5052. 'ON',
  5053. 'L',
  5054. 'L',
  5055. 'L',
  5056. 'L',
  5057. 'L',
  5058. 'L',
  5059. 'L',
  5060. 'L',
  5061. 'L',
  5062. 'L',
  5063. 'L',
  5064. 'L',
  5065. 'L',
  5066. 'L',
  5067. 'L',
  5068. 'L',
  5069. 'L',
  5070. 'L',
  5071. 'L',
  5072. 'L',
  5073. 'L',
  5074. 'L',
  5075. 'L',
  5076. 'L',
  5077. 'L',
  5078. 'L',
  5079. 'ON',
  5080. 'ON',
  5081. 'ON',
  5082. 'ON',
  5083. 'BN',
  5084. 'BN',
  5085. 'BN',
  5086. 'BN',
  5087. 'BN',
  5088. 'BN',
  5089. 'B',
  5090. 'BN',
  5091. 'BN',
  5092. 'BN',
  5093. 'BN',
  5094. 'BN',
  5095. 'BN',
  5096. 'BN',
  5097. 'BN',
  5098. 'BN',
  5099. 'BN',
  5100. 'BN',
  5101. 'BN',
  5102. 'BN',
  5103. 'BN',
  5104. 'BN',
  5105. 'BN',
  5106. 'BN',
  5107. 'BN',
  5108. 'BN',
  5109. 'BN',
  5110. 'BN',
  5111. 'BN',
  5112. 'BN',
  5113. 'BN',
  5114. 'BN',
  5115. 'BN',
  5116. 'CS',
  5117. 'ON',
  5118. 'ET',
  5119. 'ET',
  5120. 'ET',
  5121. 'ET',
  5122. 'ON',
  5123. 'ON',
  5124. 'ON',
  5125. 'ON',
  5126. 'L',
  5127. 'ON',
  5128. 'ON',
  5129. 'BN',
  5130. 'ON',
  5131. 'ON',
  5132. 'ET',
  5133. 'ET',
  5134. 'EN',
  5135. 'EN',
  5136. 'ON',
  5137. 'L',
  5138. 'ON',
  5139. 'ON',
  5140. 'ON',
  5141. 'EN',
  5142. 'L',
  5143. 'ON',
  5144. 'ON',
  5145. 'ON',
  5146. 'ON',
  5147. 'ON',
  5148. 'L',
  5149. 'L',
  5150. 'L',
  5151. 'L',
  5152. 'L',
  5153. 'L',
  5154. 'L',
  5155. 'L',
  5156. 'L',
  5157. 'L',
  5158. 'L',
  5159. 'L',
  5160. 'L',
  5161. 'L',
  5162. 'L',
  5163. 'L',
  5164. 'L',
  5165. 'L',
  5166. 'L',
  5167. 'L',
  5168. 'L',
  5169. 'L',
  5170. 'L',
  5171. 'ON',
  5172. 'L',
  5173. 'L',
  5174. 'L',
  5175. 'L',
  5176. 'L',
  5177. 'L',
  5178. 'L',
  5179. 'L',
  5180. 'L',
  5181. 'L',
  5182. 'L',
  5183. 'L',
  5184. 'L',
  5185. 'L',
  5186. 'L',
  5187. 'L',
  5188. 'L',
  5189. 'L',
  5190. 'L',
  5191. 'L',
  5192. 'L',
  5193. 'L',
  5194. 'L',
  5195. 'L',
  5196. 'L',
  5197. 'L',
  5198. 'L',
  5199. 'L',
  5200. 'L',
  5201. 'L',
  5202. 'L',
  5203. 'ON',
  5204. 'L',
  5205. 'L',
  5206. 'L',
  5207. 'L',
  5208. 'L',
  5209. 'L',
  5210. 'L',
  5211. 'L'
  5212. ];
  5213. var arabicTypes = [
  5214. 'AN',
  5215. 'AN',
  5216. 'AN',
  5217. 'AN',
  5218. 'AN',
  5219. 'AN',
  5220. 'ON',
  5221. 'ON',
  5222. 'AL',
  5223. 'ET',
  5224. 'ET',
  5225. 'AL',
  5226. 'CS',
  5227. 'AL',
  5228. 'ON',
  5229. 'ON',
  5230. 'NSM',
  5231. 'NSM',
  5232. 'NSM',
  5233. 'NSM',
  5234. 'NSM',
  5235. 'NSM',
  5236. 'NSM',
  5237. 'NSM',
  5238. 'NSM',
  5239. 'NSM',
  5240. 'NSM',
  5241. 'AL',
  5242. 'AL',
  5243. '',
  5244. 'AL',
  5245. 'AL',
  5246. 'AL',
  5247. 'AL',
  5248. 'AL',
  5249. 'AL',
  5250. 'AL',
  5251. 'AL',
  5252. 'AL',
  5253. 'AL',
  5254. 'AL',
  5255. 'AL',
  5256. 'AL',
  5257. 'AL',
  5258. 'AL',
  5259. 'AL',
  5260. 'AL',
  5261. 'AL',
  5262. 'AL',
  5263. 'AL',
  5264. 'AL',
  5265. 'AL',
  5266. 'AL',
  5267. 'AL',
  5268. 'AL',
  5269. 'AL',
  5270. 'AL',
  5271. 'AL',
  5272. 'AL',
  5273. 'AL',
  5274. 'AL',
  5275. 'AL',
  5276. 'AL',
  5277. 'AL',
  5278. 'AL',
  5279. 'AL',
  5280. 'AL',
  5281. 'AL',
  5282. 'AL',
  5283. 'AL',
  5284. 'AL',
  5285. 'AL',
  5286. 'AL',
  5287. 'AL',
  5288. 'AL',
  5289. 'NSM',
  5290. 'NSM',
  5291. 'NSM',
  5292. 'NSM',
  5293. 'NSM',
  5294. 'NSM',
  5295. 'NSM',
  5296. 'NSM',
  5297. 'NSM',
  5298. 'NSM',
  5299. 'NSM',
  5300. 'NSM',
  5301. 'NSM',
  5302. 'NSM',
  5303. 'NSM',
  5304. 'NSM',
  5305. 'NSM',
  5306. 'NSM',
  5307. 'NSM',
  5308. 'NSM',
  5309. 'NSM',
  5310. 'AN',
  5311. 'AN',
  5312. 'AN',
  5313. 'AN',
  5314. 'AN',
  5315. 'AN',
  5316. 'AN',
  5317. 'AN',
  5318. 'AN',
  5319. 'AN',
  5320. 'ET',
  5321. 'AN',
  5322. 'AN',
  5323. 'AL',
  5324. 'AL',
  5325. 'AL',
  5326. 'NSM',
  5327. 'AL',
  5328. 'AL',
  5329. 'AL',
  5330. 'AL',
  5331. 'AL',
  5332. 'AL',
  5333. 'AL',
  5334. 'AL',
  5335. 'AL',
  5336. 'AL',
  5337. 'AL',
  5338. 'AL',
  5339. 'AL',
  5340. 'AL',
  5341. 'AL',
  5342. 'AL',
  5343. 'AL',
  5344. 'AL',
  5345. 'AL',
  5346. 'AL',
  5347. 'AL',
  5348. 'AL',
  5349. 'AL',
  5350. 'AL',
  5351. 'AL',
  5352. 'AL',
  5353. 'AL',
  5354. 'AL',
  5355. 'AL',
  5356. 'AL',
  5357. 'AL',
  5358. 'AL',
  5359. 'AL',
  5360. 'AL',
  5361. 'AL',
  5362. 'AL',
  5363. 'AL',
  5364. 'AL',
  5365. 'AL',
  5366. 'AL',
  5367. 'AL',
  5368. 'AL',
  5369. 'AL',
  5370. 'AL',
  5371. 'AL',
  5372. 'AL',
  5373. 'AL',
  5374. 'AL',
  5375. 'AL',
  5376. 'AL',
  5377. 'AL',
  5378. 'AL',
  5379. 'AL',
  5380. 'AL',
  5381. 'AL',
  5382. 'AL',
  5383. 'AL',
  5384. 'AL',
  5385. 'AL',
  5386. 'AL',
  5387. 'AL',
  5388. 'AL',
  5389. 'AL',
  5390. 'AL',
  5391. 'AL',
  5392. 'AL',
  5393. 'AL',
  5394. 'AL',
  5395. 'AL',
  5396. 'AL',
  5397. 'AL',
  5398. 'AL',
  5399. 'AL',
  5400. 'AL',
  5401. 'AL',
  5402. 'AL',
  5403. 'AL',
  5404. 'AL',
  5405. 'AL',
  5406. 'AL',
  5407. 'AL',
  5408. 'AL',
  5409. 'AL',
  5410. 'AL',
  5411. 'AL',
  5412. 'AL',
  5413. 'AL',
  5414. 'AL',
  5415. 'AL',
  5416. 'AL',
  5417. 'AL',
  5418. 'AL',
  5419. 'AL',
  5420. 'AL',
  5421. 'AL',
  5422. 'AL',
  5423. 'AL',
  5424. 'AL',
  5425. 'AL',
  5426. 'AL',
  5427. 'AL',
  5428. 'NSM',
  5429. 'NSM',
  5430. 'NSM',
  5431. 'NSM',
  5432. 'NSM',
  5433. 'NSM',
  5434. 'NSM',
  5435. 'AN',
  5436. 'ON',
  5437. 'NSM',
  5438. 'NSM',
  5439. 'NSM',
  5440. 'NSM',
  5441. 'NSM',
  5442. 'NSM',
  5443. 'AL',
  5444. 'AL',
  5445. 'NSM',
  5446. 'NSM',
  5447. 'ON',
  5448. 'NSM',
  5449. 'NSM',
  5450. 'NSM',
  5451. 'NSM',
  5452. 'AL',
  5453. 'AL',
  5454. 'EN',
  5455. 'EN',
  5456. 'EN',
  5457. 'EN',
  5458. 'EN',
  5459. 'EN',
  5460. 'EN',
  5461. 'EN',
  5462. 'EN',
  5463. 'EN',
  5464. 'AL',
  5465. 'AL',
  5466. 'AL',
  5467. 'AL',
  5468. 'AL',
  5469. 'AL'
  5470. ];
  5471. function isOdd(i) {
  5472. return (i & 1) !== 0;
  5473. }
  5474. function isEven(i) {
  5475. return (i & 1) === 0;
  5476. }
  5477. function findUnequal(arr, start, value) {
  5478. for (var j = start, jj = arr.length; j < jj; ++j) {
  5479. if (arr[j] !== value) {
  5480. return j;
  5481. }
  5482. }
  5483. return j;
  5484. }
  5485. function setValues(arr, start, end, value) {
  5486. for (var j = start; j < end; ++j) {
  5487. arr[j] = value;
  5488. }
  5489. }
  5490. function reverseValues(arr, start, end) {
  5491. for (var i = start, j = end - 1; i < j; ++i, --j) {
  5492. var temp = arr[i];
  5493. arr[i] = arr[j];
  5494. arr[j] = temp;
  5495. }
  5496. }
  5497. function createBidiText(str, isLTR, vertical) {
  5498. return {
  5499. str: str,
  5500. dir: vertical ? 'ttb' : isLTR ? 'ltr' : 'rtl'
  5501. };
  5502. }
  5503. var chars = [];
  5504. var types = [];
  5505. function bidi(str, startLevel, vertical) {
  5506. var isLTR = true;
  5507. var strLength = str.length;
  5508. if (strLength === 0 || vertical) {
  5509. return createBidiText(str, isLTR, vertical);
  5510. }
  5511. chars.length = strLength;
  5512. types.length = strLength;
  5513. var numBidi = 0;
  5514. var i, ii;
  5515. for (i = 0; i < strLength; ++i) {
  5516. chars[i] = str.charAt(i);
  5517. var charCode = str.charCodeAt(i);
  5518. var charType = 'L';
  5519. if (charCode <= 0x00ff) {
  5520. charType = baseTypes[charCode];
  5521. } else if (0x0590 <= charCode && charCode <= 0x05f4) {
  5522. charType = 'R';
  5523. } else if (0x0600 <= charCode && charCode <= 0x06ff) {
  5524. charType = arabicTypes[charCode & 0xff];
  5525. if (!charType) {
  5526. warn('Bidi: invalid Unicode character ' + charCode.toString(16));
  5527. }
  5528. } else if (0x0700 <= charCode && charCode <= 0x08AC) {
  5529. charType = 'AL';
  5530. }
  5531. if (charType === 'R' || charType === 'AL' || charType === 'AN') {
  5532. numBidi++;
  5533. }
  5534. types[i] = charType;
  5535. }
  5536. if (numBidi === 0) {
  5537. isLTR = true;
  5538. return createBidiText(str, isLTR);
  5539. }
  5540. if (startLevel === -1) {
  5541. if (strLength / numBidi < 0.3) {
  5542. isLTR = true;
  5543. startLevel = 0;
  5544. } else {
  5545. isLTR = false;
  5546. startLevel = 1;
  5547. }
  5548. }
  5549. var levels = [];
  5550. for (i = 0; i < strLength; ++i) {
  5551. levels[i] = startLevel;
  5552. }
  5553. var e = isOdd(startLevel) ? 'R' : 'L';
  5554. var sor = e;
  5555. var eor = sor;
  5556. var lastType = sor;
  5557. for (i = 0; i < strLength; ++i) {
  5558. if (types[i] === 'NSM') {
  5559. types[i] = lastType;
  5560. } else {
  5561. lastType = types[i];
  5562. }
  5563. }
  5564. lastType = sor;
  5565. var t;
  5566. for (i = 0; i < strLength; ++i) {
  5567. t = types[i];
  5568. if (t === 'EN') {
  5569. types[i] = lastType === 'AL' ? 'AN' : 'EN';
  5570. } else if (t === 'R' || t === 'L' || t === 'AL') {
  5571. lastType = t;
  5572. }
  5573. }
  5574. for (i = 0; i < strLength; ++i) {
  5575. t = types[i];
  5576. if (t === 'AL') {
  5577. types[i] = 'R';
  5578. }
  5579. }
  5580. for (i = 1; i < strLength - 1; ++i) {
  5581. if (types[i] === 'ES' && types[i - 1] === 'EN' && types[i + 1] === 'EN') {
  5582. types[i] = 'EN';
  5583. }
  5584. if (types[i] === 'CS' && (types[i - 1] === 'EN' || types[i - 1] === 'AN') && types[i + 1] === types[i - 1]) {
  5585. types[i] = types[i - 1];
  5586. }
  5587. }
  5588. for (i = 0; i < strLength; ++i) {
  5589. if (types[i] === 'EN') {
  5590. var j;
  5591. for (j = i - 1; j >= 0; --j) {
  5592. if (types[j] !== 'ET') {
  5593. break;
  5594. }
  5595. types[j] = 'EN';
  5596. }
  5597. for (j = i + 1; j < strLength; ++j) {
  5598. if (types[j] !== 'ET') {
  5599. break;
  5600. }
  5601. types[j] = 'EN';
  5602. }
  5603. }
  5604. }
  5605. for (i = 0; i < strLength; ++i) {
  5606. t = types[i];
  5607. if (t === 'WS' || t === 'ES' || t === 'ET' || t === 'CS') {
  5608. types[i] = 'ON';
  5609. }
  5610. }
  5611. lastType = sor;
  5612. for (i = 0; i < strLength; ++i) {
  5613. t = types[i];
  5614. if (t === 'EN') {
  5615. types[i] = lastType === 'L' ? 'L' : 'EN';
  5616. } else if (t === 'R' || t === 'L') {
  5617. lastType = t;
  5618. }
  5619. }
  5620. for (i = 0; i < strLength; ++i) {
  5621. if (types[i] === 'ON') {
  5622. var end = findUnequal(types, i + 1, 'ON');
  5623. var before = sor;
  5624. if (i > 0) {
  5625. before = types[i - 1];
  5626. }
  5627. var after = eor;
  5628. if (end + 1 < strLength) {
  5629. after = types[end + 1];
  5630. }
  5631. if (before !== 'L') {
  5632. before = 'R';
  5633. }
  5634. if (after !== 'L') {
  5635. after = 'R';
  5636. }
  5637. if (before === after) {
  5638. setValues(types, i, end, before);
  5639. }
  5640. i = end - 1;
  5641. }
  5642. }
  5643. for (i = 0; i < strLength; ++i) {
  5644. if (types[i] === 'ON') {
  5645. types[i] = e;
  5646. }
  5647. }
  5648. for (i = 0; i < strLength; ++i) {
  5649. t = types[i];
  5650. if (isEven(levels[i])) {
  5651. if (t === 'R') {
  5652. levels[i] += 1;
  5653. } else if (t === 'AN' || t === 'EN') {
  5654. levels[i] += 2;
  5655. }
  5656. } else {
  5657. if (t === 'L' || t === 'AN' || t === 'EN') {
  5658. levels[i] += 1;
  5659. }
  5660. }
  5661. }
  5662. var highestLevel = -1;
  5663. var lowestOddLevel = 99;
  5664. var level;
  5665. for (i = 0, ii = levels.length; i < ii; ++i) {
  5666. level = levels[i];
  5667. if (highestLevel < level) {
  5668. highestLevel = level;
  5669. }
  5670. if (lowestOddLevel > level && isOdd(level)) {
  5671. lowestOddLevel = level;
  5672. }
  5673. }
  5674. for (level = highestLevel; level >= lowestOddLevel; --level) {
  5675. var start = -1;
  5676. for (i = 0, ii = levels.length; i < ii; ++i) {
  5677. if (levels[i] < level) {
  5678. if (start >= 0) {
  5679. reverseValues(chars, start, i);
  5680. start = -1;
  5681. }
  5682. } else if (start < 0) {
  5683. start = i;
  5684. }
  5685. }
  5686. if (start >= 0) {
  5687. reverseValues(chars, start, levels.length);
  5688. }
  5689. }
  5690. for (i = 0, ii = chars.length; i < ii; ++i) {
  5691. var ch = chars[i];
  5692. if (ch === '<' || ch === '>') {
  5693. chars[i] = '';
  5694. }
  5695. }
  5696. return createBidiText(chars.join(''), isLTR);
  5697. }
  5698. exports.bidi = bidi;
  5699. }));
  5700. (function (root, factory) {
  5701. factory(root.pdfjsCoreCFFParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreCharsets, root.pdfjsCoreEncodings);
  5702. }(this, function (exports, sharedUtil, coreCharsets, coreEncodings) {
  5703. var error = sharedUtil.error;
  5704. var info = sharedUtil.info;
  5705. var bytesToString = sharedUtil.bytesToString;
  5706. var warn = sharedUtil.warn;
  5707. var isArray = sharedUtil.isArray;
  5708. var Util = sharedUtil.Util;
  5709. var stringToBytes = sharedUtil.stringToBytes;
  5710. var assert = sharedUtil.assert;
  5711. var ISOAdobeCharset = coreCharsets.ISOAdobeCharset;
  5712. var ExpertCharset = coreCharsets.ExpertCharset;
  5713. var ExpertSubsetCharset = coreCharsets.ExpertSubsetCharset;
  5714. var StandardEncoding = coreEncodings.StandardEncoding;
  5715. var ExpertEncoding = coreEncodings.ExpertEncoding;
  5716. var MAX_SUBR_NESTING = 10;
  5717. var CFFStandardStrings = [
  5718. '.notdef',
  5719. 'space',
  5720. 'exclam',
  5721. 'quotedbl',
  5722. 'numbersign',
  5723. 'dollar',
  5724. 'percent',
  5725. 'ampersand',
  5726. 'quoteright',
  5727. 'parenleft',
  5728. 'parenright',
  5729. 'asterisk',
  5730. 'plus',
  5731. 'comma',
  5732. 'hyphen',
  5733. 'period',
  5734. 'slash',
  5735. 'zero',
  5736. 'one',
  5737. 'two',
  5738. 'three',
  5739. 'four',
  5740. 'five',
  5741. 'six',
  5742. 'seven',
  5743. 'eight',
  5744. 'nine',
  5745. 'colon',
  5746. 'semicolon',
  5747. 'less',
  5748. 'equal',
  5749. 'greater',
  5750. 'question',
  5751. 'at',
  5752. 'A',
  5753. 'B',
  5754. 'C',
  5755. 'D',
  5756. 'E',
  5757. 'F',
  5758. 'G',
  5759. 'H',
  5760. 'I',
  5761. 'J',
  5762. 'K',
  5763. 'L',
  5764. 'M',
  5765. 'N',
  5766. 'O',
  5767. 'P',
  5768. 'Q',
  5769. 'R',
  5770. 'S',
  5771. 'T',
  5772. 'U',
  5773. 'V',
  5774. 'W',
  5775. 'X',
  5776. 'Y',
  5777. 'Z',
  5778. 'bracketleft',
  5779. 'backslash',
  5780. 'bracketright',
  5781. 'asciicircum',
  5782. 'underscore',
  5783. 'quoteleft',
  5784. 'a',
  5785. 'b',
  5786. 'c',
  5787. 'd',
  5788. 'e',
  5789. 'f',
  5790. 'g',
  5791. 'h',
  5792. 'i',
  5793. 'j',
  5794. 'k',
  5795. 'l',
  5796. 'm',
  5797. 'n',
  5798. 'o',
  5799. 'p',
  5800. 'q',
  5801. 'r',
  5802. 's',
  5803. 't',
  5804. 'u',
  5805. 'v',
  5806. 'w',
  5807. 'x',
  5808. 'y',
  5809. 'z',
  5810. 'braceleft',
  5811. 'bar',
  5812. 'braceright',
  5813. 'asciitilde',
  5814. 'exclamdown',
  5815. 'cent',
  5816. 'sterling',
  5817. 'fraction',
  5818. 'yen',
  5819. 'florin',
  5820. 'section',
  5821. 'currency',
  5822. 'quotesingle',
  5823. 'quotedblleft',
  5824. 'guillemotleft',
  5825. 'guilsinglleft',
  5826. 'guilsinglright',
  5827. 'fi',
  5828. 'fl',
  5829. 'endash',
  5830. 'dagger',
  5831. 'daggerdbl',
  5832. 'periodcentered',
  5833. 'paragraph',
  5834. 'bullet',
  5835. 'quotesinglbase',
  5836. 'quotedblbase',
  5837. 'quotedblright',
  5838. 'guillemotright',
  5839. 'ellipsis',
  5840. 'perthousand',
  5841. 'questiondown',
  5842. 'grave',
  5843. 'acute',
  5844. 'circumflex',
  5845. 'tilde',
  5846. 'macron',
  5847. 'breve',
  5848. 'dotaccent',
  5849. 'dieresis',
  5850. 'ring',
  5851. 'cedilla',
  5852. 'hungarumlaut',
  5853. 'ogonek',
  5854. 'caron',
  5855. 'emdash',
  5856. 'AE',
  5857. 'ordfeminine',
  5858. 'Lslash',
  5859. 'Oslash',
  5860. 'OE',
  5861. 'ordmasculine',
  5862. 'ae',
  5863. 'dotlessi',
  5864. 'lslash',
  5865. 'oslash',
  5866. 'oe',
  5867. 'germandbls',
  5868. 'onesuperior',
  5869. 'logicalnot',
  5870. 'mu',
  5871. 'trademark',
  5872. 'Eth',
  5873. 'onehalf',
  5874. 'plusminus',
  5875. 'Thorn',
  5876. 'onequarter',
  5877. 'divide',
  5878. 'brokenbar',
  5879. 'degree',
  5880. 'thorn',
  5881. 'threequarters',
  5882. 'twosuperior',
  5883. 'registered',
  5884. 'minus',
  5885. 'eth',
  5886. 'multiply',
  5887. 'threesuperior',
  5888. 'copyright',
  5889. 'Aacute',
  5890. 'Acircumflex',
  5891. 'Adieresis',
  5892. 'Agrave',
  5893. 'Aring',
  5894. 'Atilde',
  5895. 'Ccedilla',
  5896. 'Eacute',
  5897. 'Ecircumflex',
  5898. 'Edieresis',
  5899. 'Egrave',
  5900. 'Iacute',
  5901. 'Icircumflex',
  5902. 'Idieresis',
  5903. 'Igrave',
  5904. 'Ntilde',
  5905. 'Oacute',
  5906. 'Ocircumflex',
  5907. 'Odieresis',
  5908. 'Ograve',
  5909. 'Otilde',
  5910. 'Scaron',
  5911. 'Uacute',
  5912. 'Ucircumflex',
  5913. 'Udieresis',
  5914. 'Ugrave',
  5915. 'Yacute',
  5916. 'Ydieresis',
  5917. 'Zcaron',
  5918. 'aacute',
  5919. 'acircumflex',
  5920. 'adieresis',
  5921. 'agrave',
  5922. 'aring',
  5923. 'atilde',
  5924. 'ccedilla',
  5925. 'eacute',
  5926. 'ecircumflex',
  5927. 'edieresis',
  5928. 'egrave',
  5929. 'iacute',
  5930. 'icircumflex',
  5931. 'idieresis',
  5932. 'igrave',
  5933. 'ntilde',
  5934. 'oacute',
  5935. 'ocircumflex',
  5936. 'odieresis',
  5937. 'ograve',
  5938. 'otilde',
  5939. 'scaron',
  5940. 'uacute',
  5941. 'ucircumflex',
  5942. 'udieresis',
  5943. 'ugrave',
  5944. 'yacute',
  5945. 'ydieresis',
  5946. 'zcaron',
  5947. 'exclamsmall',
  5948. 'Hungarumlautsmall',
  5949. 'dollaroldstyle',
  5950. 'dollarsuperior',
  5951. 'ampersandsmall',
  5952. 'Acutesmall',
  5953. 'parenleftsuperior',
  5954. 'parenrightsuperior',
  5955. 'twodotenleader',
  5956. 'onedotenleader',
  5957. 'zerooldstyle',
  5958. 'oneoldstyle',
  5959. 'twooldstyle',
  5960. 'threeoldstyle',
  5961. 'fouroldstyle',
  5962. 'fiveoldstyle',
  5963. 'sixoldstyle',
  5964. 'sevenoldstyle',
  5965. 'eightoldstyle',
  5966. 'nineoldstyle',
  5967. 'commasuperior',
  5968. 'threequartersemdash',
  5969. 'periodsuperior',
  5970. 'questionsmall',
  5971. 'asuperior',
  5972. 'bsuperior',
  5973. 'centsuperior',
  5974. 'dsuperior',
  5975. 'esuperior',
  5976. 'isuperior',
  5977. 'lsuperior',
  5978. 'msuperior',
  5979. 'nsuperior',
  5980. 'osuperior',
  5981. 'rsuperior',
  5982. 'ssuperior',
  5983. 'tsuperior',
  5984. 'ff',
  5985. 'ffi',
  5986. 'ffl',
  5987. 'parenleftinferior',
  5988. 'parenrightinferior',
  5989. 'Circumflexsmall',
  5990. 'hyphensuperior',
  5991. 'Gravesmall',
  5992. 'Asmall',
  5993. 'Bsmall',
  5994. 'Csmall',
  5995. 'Dsmall',
  5996. 'Esmall',
  5997. 'Fsmall',
  5998. 'Gsmall',
  5999. 'Hsmall',
  6000. 'Ismall',
  6001. 'Jsmall',
  6002. 'Ksmall',
  6003. 'Lsmall',
  6004. 'Msmall',
  6005. 'Nsmall',
  6006. 'Osmall',
  6007. 'Psmall',
  6008. 'Qsmall',
  6009. 'Rsmall',
  6010. 'Ssmall',
  6011. 'Tsmall',
  6012. 'Usmall',
  6013. 'Vsmall',
  6014. 'Wsmall',
  6015. 'Xsmall',
  6016. 'Ysmall',
  6017. 'Zsmall',
  6018. 'colonmonetary',
  6019. 'onefitted',
  6020. 'rupiah',
  6021. 'Tildesmall',
  6022. 'exclamdownsmall',
  6023. 'centoldstyle',
  6024. 'Lslashsmall',
  6025. 'Scaronsmall',
  6026. 'Zcaronsmall',
  6027. 'Dieresissmall',
  6028. 'Brevesmall',
  6029. 'Caronsmall',
  6030. 'Dotaccentsmall',
  6031. 'Macronsmall',
  6032. 'figuredash',
  6033. 'hypheninferior',
  6034. 'Ogoneksmall',
  6035. 'Ringsmall',
  6036. 'Cedillasmall',
  6037. 'questiondownsmall',
  6038. 'oneeighth',
  6039. 'threeeighths',
  6040. 'fiveeighths',
  6041. 'seveneighths',
  6042. 'onethird',
  6043. 'twothirds',
  6044. 'zerosuperior',
  6045. 'foursuperior',
  6046. 'fivesuperior',
  6047. 'sixsuperior',
  6048. 'sevensuperior',
  6049. 'eightsuperior',
  6050. 'ninesuperior',
  6051. 'zeroinferior',
  6052. 'oneinferior',
  6053. 'twoinferior',
  6054. 'threeinferior',
  6055. 'fourinferior',
  6056. 'fiveinferior',
  6057. 'sixinferior',
  6058. 'seveninferior',
  6059. 'eightinferior',
  6060. 'nineinferior',
  6061. 'centinferior',
  6062. 'dollarinferior',
  6063. 'periodinferior',
  6064. 'commainferior',
  6065. 'Agravesmall',
  6066. 'Aacutesmall',
  6067. 'Acircumflexsmall',
  6068. 'Atildesmall',
  6069. 'Adieresissmall',
  6070. 'Aringsmall',
  6071. 'AEsmall',
  6072. 'Ccedillasmall',
  6073. 'Egravesmall',
  6074. 'Eacutesmall',
  6075. 'Ecircumflexsmall',
  6076. 'Edieresissmall',
  6077. 'Igravesmall',
  6078. 'Iacutesmall',
  6079. 'Icircumflexsmall',
  6080. 'Idieresissmall',
  6081. 'Ethsmall',
  6082. 'Ntildesmall',
  6083. 'Ogravesmall',
  6084. 'Oacutesmall',
  6085. 'Ocircumflexsmall',
  6086. 'Otildesmall',
  6087. 'Odieresissmall',
  6088. 'OEsmall',
  6089. 'Oslashsmall',
  6090. 'Ugravesmall',
  6091. 'Uacutesmall',
  6092. 'Ucircumflexsmall',
  6093. 'Udieresissmall',
  6094. 'Yacutesmall',
  6095. 'Thornsmall',
  6096. 'Ydieresissmall',
  6097. '001.000',
  6098. '001.001',
  6099. '001.002',
  6100. '001.003',
  6101. 'Black',
  6102. 'Bold',
  6103. 'Book',
  6104. 'Light',
  6105. 'Medium',
  6106. 'Regular',
  6107. 'Roman',
  6108. 'Semibold'
  6109. ];
  6110. var CFFParser = function CFFParserClosure() {
  6111. var CharstringValidationData = [
  6112. null,
  6113. {
  6114. id: 'hstem',
  6115. min: 2,
  6116. stackClearing: true,
  6117. stem: true
  6118. },
  6119. null,
  6120. {
  6121. id: 'vstem',
  6122. min: 2,
  6123. stackClearing: true,
  6124. stem: true
  6125. },
  6126. {
  6127. id: 'vmoveto',
  6128. min: 1,
  6129. stackClearing: true
  6130. },
  6131. {
  6132. id: 'rlineto',
  6133. min: 2,
  6134. resetStack: true
  6135. },
  6136. {
  6137. id: 'hlineto',
  6138. min: 1,
  6139. resetStack: true
  6140. },
  6141. {
  6142. id: 'vlineto',
  6143. min: 1,
  6144. resetStack: true
  6145. },
  6146. {
  6147. id: 'rrcurveto',
  6148. min: 6,
  6149. resetStack: true
  6150. },
  6151. null,
  6152. {
  6153. id: 'callsubr',
  6154. min: 1,
  6155. undefStack: true
  6156. },
  6157. {
  6158. id: 'return',
  6159. min: 0,
  6160. undefStack: true
  6161. },
  6162. null,
  6163. null,
  6164. {
  6165. id: 'endchar',
  6166. min: 0,
  6167. stackClearing: true
  6168. },
  6169. null,
  6170. null,
  6171. null,
  6172. {
  6173. id: 'hstemhm',
  6174. min: 2,
  6175. stackClearing: true,
  6176. stem: true
  6177. },
  6178. {
  6179. id: 'hintmask',
  6180. min: 0,
  6181. stackClearing: true
  6182. },
  6183. {
  6184. id: 'cntrmask',
  6185. min: 0,
  6186. stackClearing: true
  6187. },
  6188. {
  6189. id: 'rmoveto',
  6190. min: 2,
  6191. stackClearing: true
  6192. },
  6193. {
  6194. id: 'hmoveto',
  6195. min: 1,
  6196. stackClearing: true
  6197. },
  6198. {
  6199. id: 'vstemhm',
  6200. min: 2,
  6201. stackClearing: true,
  6202. stem: true
  6203. },
  6204. {
  6205. id: 'rcurveline',
  6206. min: 8,
  6207. resetStack: true
  6208. },
  6209. {
  6210. id: 'rlinecurve',
  6211. min: 8,
  6212. resetStack: true
  6213. },
  6214. {
  6215. id: 'vvcurveto',
  6216. min: 4,
  6217. resetStack: true
  6218. },
  6219. {
  6220. id: 'hhcurveto',
  6221. min: 4,
  6222. resetStack: true
  6223. },
  6224. null,
  6225. {
  6226. id: 'callgsubr',
  6227. min: 1,
  6228. undefStack: true
  6229. },
  6230. {
  6231. id: 'vhcurveto',
  6232. min: 4,
  6233. resetStack: true
  6234. },
  6235. {
  6236. id: 'hvcurveto',
  6237. min: 4,
  6238. resetStack: true
  6239. }
  6240. ];
  6241. var CharstringValidationData12 = [
  6242. null,
  6243. null,
  6244. null,
  6245. {
  6246. id: 'and',
  6247. min: 2,
  6248. stackDelta: -1
  6249. },
  6250. {
  6251. id: 'or',
  6252. min: 2,
  6253. stackDelta: -1
  6254. },
  6255. {
  6256. id: 'not',
  6257. min: 1,
  6258. stackDelta: 0
  6259. },
  6260. null,
  6261. null,
  6262. null,
  6263. {
  6264. id: 'abs',
  6265. min: 1,
  6266. stackDelta: 0
  6267. },
  6268. {
  6269. id: 'add',
  6270. min: 2,
  6271. stackDelta: -1,
  6272. stackFn: function stack_div(stack, index) {
  6273. stack[index - 2] = stack[index - 2] + stack[index - 1];
  6274. }
  6275. },
  6276. {
  6277. id: 'sub',
  6278. min: 2,
  6279. stackDelta: -1,
  6280. stackFn: function stack_div(stack, index) {
  6281. stack[index - 2] = stack[index - 2] - stack[index - 1];
  6282. }
  6283. },
  6284. {
  6285. id: 'div',
  6286. min: 2,
  6287. stackDelta: -1,
  6288. stackFn: function stack_div(stack, index) {
  6289. stack[index - 2] = stack[index - 2] / stack[index - 1];
  6290. }
  6291. },
  6292. null,
  6293. {
  6294. id: 'neg',
  6295. min: 1,
  6296. stackDelta: 0,
  6297. stackFn: function stack_div(stack, index) {
  6298. stack[index - 1] = -stack[index - 1];
  6299. }
  6300. },
  6301. {
  6302. id: 'eq',
  6303. min: 2,
  6304. stackDelta: -1
  6305. },
  6306. null,
  6307. null,
  6308. {
  6309. id: 'drop',
  6310. min: 1,
  6311. stackDelta: -1
  6312. },
  6313. null,
  6314. {
  6315. id: 'put',
  6316. min: 2,
  6317. stackDelta: -2
  6318. },
  6319. {
  6320. id: 'get',
  6321. min: 1,
  6322. stackDelta: 0
  6323. },
  6324. {
  6325. id: 'ifelse',
  6326. min: 4,
  6327. stackDelta: -3
  6328. },
  6329. {
  6330. id: 'random',
  6331. min: 0,
  6332. stackDelta: 1
  6333. },
  6334. {
  6335. id: 'mul',
  6336. min: 2,
  6337. stackDelta: -1,
  6338. stackFn: function stack_div(stack, index) {
  6339. stack[index - 2] = stack[index - 2] * stack[index - 1];
  6340. }
  6341. },
  6342. null,
  6343. {
  6344. id: 'sqrt',
  6345. min: 1,
  6346. stackDelta: 0
  6347. },
  6348. {
  6349. id: 'dup',
  6350. min: 1,
  6351. stackDelta: 1
  6352. },
  6353. {
  6354. id: 'exch',
  6355. min: 2,
  6356. stackDelta: 0
  6357. },
  6358. {
  6359. id: 'index',
  6360. min: 2,
  6361. stackDelta: 0
  6362. },
  6363. {
  6364. id: 'roll',
  6365. min: 3,
  6366. stackDelta: -2
  6367. },
  6368. null,
  6369. null,
  6370. null,
  6371. {
  6372. id: 'hflex',
  6373. min: 7,
  6374. resetStack: true
  6375. },
  6376. {
  6377. id: 'flex',
  6378. min: 13,
  6379. resetStack: true
  6380. },
  6381. {
  6382. id: 'hflex1',
  6383. min: 9,
  6384. resetStack: true
  6385. },
  6386. {
  6387. id: 'flex1',
  6388. min: 11,
  6389. resetStack: true
  6390. }
  6391. ];
  6392. function CFFParser(file, properties, seacAnalysisEnabled) {
  6393. this.bytes = file.getBytes();
  6394. this.properties = properties;
  6395. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  6396. }
  6397. CFFParser.prototype = {
  6398. parse: function CFFParser_parse() {
  6399. var properties = this.properties;
  6400. var cff = new CFF();
  6401. this.cff = cff;
  6402. var header = this.parseHeader();
  6403. var nameIndex = this.parseIndex(header.endPos);
  6404. var topDictIndex = this.parseIndex(nameIndex.endPos);
  6405. var stringIndex = this.parseIndex(topDictIndex.endPos);
  6406. var globalSubrIndex = this.parseIndex(stringIndex.endPos);
  6407. var topDictParsed = this.parseDict(topDictIndex.obj.get(0));
  6408. var topDict = this.createDict(CFFTopDict, topDictParsed, cff.strings);
  6409. cff.header = header.obj;
  6410. cff.names = this.parseNameIndex(nameIndex.obj);
  6411. cff.strings = this.parseStringIndex(stringIndex.obj);
  6412. cff.topDict = topDict;
  6413. cff.globalSubrIndex = globalSubrIndex.obj;
  6414. this.parsePrivateDict(cff.topDict);
  6415. cff.isCIDFont = topDict.hasName('ROS');
  6416. var charStringOffset = topDict.getByName('CharStrings');
  6417. var charStringIndex = this.parseIndex(charStringOffset).obj;
  6418. var fontMatrix = topDict.getByName('FontMatrix');
  6419. if (fontMatrix) {
  6420. properties.fontMatrix = fontMatrix;
  6421. }
  6422. var fontBBox = topDict.getByName('FontBBox');
  6423. if (fontBBox) {
  6424. properties.ascent = fontBBox[3];
  6425. properties.descent = fontBBox[1];
  6426. properties.ascentScaled = true;
  6427. }
  6428. var charset, encoding;
  6429. if (cff.isCIDFont) {
  6430. var fdArrayIndex = this.parseIndex(topDict.getByName('FDArray')).obj;
  6431. for (var i = 0, ii = fdArrayIndex.count; i < ii; ++i) {
  6432. var dictRaw = fdArrayIndex.get(i);
  6433. var fontDict = this.createDict(CFFTopDict, this.parseDict(dictRaw), cff.strings);
  6434. this.parsePrivateDict(fontDict);
  6435. cff.fdArray.push(fontDict);
  6436. }
  6437. encoding = null;
  6438. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, true);
  6439. cff.fdSelect = this.parseFDSelect(topDict.getByName('FDSelect'), charStringIndex.count);
  6440. } else {
  6441. charset = this.parseCharsets(topDict.getByName('charset'), charStringIndex.count, cff.strings, false);
  6442. encoding = this.parseEncoding(topDict.getByName('Encoding'), properties, cff.strings, charset.charset);
  6443. }
  6444. cff.charset = charset;
  6445. cff.encoding = encoding;
  6446. var charStringsAndSeacs = this.parseCharStrings(charStringIndex, topDict.privateDict.subrsIndex, globalSubrIndex.obj, cff.fdSelect, cff.fdArray);
  6447. cff.charStrings = charStringsAndSeacs.charStrings;
  6448. cff.seacs = charStringsAndSeacs.seacs;
  6449. cff.widths = charStringsAndSeacs.widths;
  6450. return cff;
  6451. },
  6452. parseHeader: function CFFParser_parseHeader() {
  6453. var bytes = this.bytes;
  6454. var bytesLength = bytes.length;
  6455. var offset = 0;
  6456. while (offset < bytesLength && bytes[offset] !== 1) {
  6457. ++offset;
  6458. }
  6459. if (offset >= bytesLength) {
  6460. error('Invalid CFF header');
  6461. } else if (offset !== 0) {
  6462. info('cff data is shifted');
  6463. bytes = bytes.subarray(offset);
  6464. this.bytes = bytes;
  6465. }
  6466. var major = bytes[0];
  6467. var minor = bytes[1];
  6468. var hdrSize = bytes[2];
  6469. var offSize = bytes[3];
  6470. var header = new CFFHeader(major, minor, hdrSize, offSize);
  6471. return {
  6472. obj: header,
  6473. endPos: hdrSize
  6474. };
  6475. },
  6476. parseDict: function CFFParser_parseDict(dict) {
  6477. var pos = 0;
  6478. function parseOperand() {
  6479. var value = dict[pos++];
  6480. if (value === 30) {
  6481. return parseFloatOperand();
  6482. } else if (value === 28) {
  6483. value = dict[pos++];
  6484. value = (value << 24 | dict[pos++] << 16) >> 16;
  6485. return value;
  6486. } else if (value === 29) {
  6487. value = dict[pos++];
  6488. value = value << 8 | dict[pos++];
  6489. value = value << 8 | dict[pos++];
  6490. value = value << 8 | dict[pos++];
  6491. return value;
  6492. } else if (value >= 32 && value <= 246) {
  6493. return value - 139;
  6494. } else if (value >= 247 && value <= 250) {
  6495. return (value - 247) * 256 + dict[pos++] + 108;
  6496. } else if (value >= 251 && value <= 254) {
  6497. return -((value - 251) * 256) - dict[pos++] - 108;
  6498. } else {
  6499. warn('CFFParser_parseDict: "' + value + '" is a reserved command.');
  6500. return NaN;
  6501. }
  6502. }
  6503. function parseFloatOperand() {
  6504. var str = '';
  6505. var eof = 15;
  6506. var lookup = [
  6507. '0',
  6508. '1',
  6509. '2',
  6510. '3',
  6511. '4',
  6512. '5',
  6513. '6',
  6514. '7',
  6515. '8',
  6516. '9',
  6517. '.',
  6518. 'E',
  6519. 'E-',
  6520. null,
  6521. '-'
  6522. ];
  6523. var length = dict.length;
  6524. while (pos < length) {
  6525. var b = dict[pos++];
  6526. var b1 = b >> 4;
  6527. var b2 = b & 15;
  6528. if (b1 === eof) {
  6529. break;
  6530. }
  6531. str += lookup[b1];
  6532. if (b2 === eof) {
  6533. break;
  6534. }
  6535. str += lookup[b2];
  6536. }
  6537. return parseFloat(str);
  6538. }
  6539. var operands = [];
  6540. var entries = [];
  6541. pos = 0;
  6542. var end = dict.length;
  6543. while (pos < end) {
  6544. var b = dict[pos];
  6545. if (b <= 21) {
  6546. if (b === 12) {
  6547. b = b << 8 | dict[++pos];
  6548. }
  6549. entries.push([
  6550. b,
  6551. operands
  6552. ]);
  6553. operands = [];
  6554. ++pos;
  6555. } else {
  6556. operands.push(parseOperand());
  6557. }
  6558. }
  6559. return entries;
  6560. },
  6561. parseIndex: function CFFParser_parseIndex(pos) {
  6562. var cffIndex = new CFFIndex();
  6563. var bytes = this.bytes;
  6564. var count = bytes[pos++] << 8 | bytes[pos++];
  6565. var offsets = [];
  6566. var end = pos;
  6567. var i, ii;
  6568. if (count !== 0) {
  6569. var offsetSize = bytes[pos++];
  6570. var startPos = pos + (count + 1) * offsetSize - 1;
  6571. for (i = 0, ii = count + 1; i < ii; ++i) {
  6572. var offset = 0;
  6573. for (var j = 0; j < offsetSize; ++j) {
  6574. offset <<= 8;
  6575. offset += bytes[pos++];
  6576. }
  6577. offsets.push(startPos + offset);
  6578. }
  6579. end = offsets[count];
  6580. }
  6581. for (i = 0, ii = offsets.length - 1; i < ii; ++i) {
  6582. var offsetStart = offsets[i];
  6583. var offsetEnd = offsets[i + 1];
  6584. cffIndex.add(bytes.subarray(offsetStart, offsetEnd));
  6585. }
  6586. return {
  6587. obj: cffIndex,
  6588. endPos: end
  6589. };
  6590. },
  6591. parseNameIndex: function CFFParser_parseNameIndex(index) {
  6592. var names = [];
  6593. for (var i = 0, ii = index.count; i < ii; ++i) {
  6594. var name = index.get(i);
  6595. var length = Math.min(name.length, 127);
  6596. var data = [];
  6597. for (var j = 0; j < length; ++j) {
  6598. var c = name[j];
  6599. if (j === 0 && c === 0) {
  6600. data[j] = c;
  6601. continue;
  6602. }
  6603. if (c < 33 || c > 126 || c === 91 || c === 93 || c === 40 || c === 41 || c === 123 || c === 125 || c === 60 || c === 62 || c === 47 || c === 37 || c === 35)
  6604. {
  6605. data[j] = 95;
  6606. continue;
  6607. }
  6608. data[j] = c;
  6609. }
  6610. names.push(bytesToString(data));
  6611. }
  6612. return names;
  6613. },
  6614. parseStringIndex: function CFFParser_parseStringIndex(index) {
  6615. var strings = new CFFStrings();
  6616. for (var i = 0, ii = index.count; i < ii; ++i) {
  6617. var data = index.get(i);
  6618. strings.add(bytesToString(data));
  6619. }
  6620. return strings;
  6621. },
  6622. createDict: function CFFParser_createDict(Type, dict, strings) {
  6623. var cffDict = new Type(strings);
  6624. for (var i = 0, ii = dict.length; i < ii; ++i) {
  6625. var pair = dict[i];
  6626. var key = pair[0];
  6627. var value = pair[1];
  6628. cffDict.setByKey(key, value);
  6629. }
  6630. return cffDict;
  6631. },
  6632. parseCharString: function CFFParser_parseCharString(state, data, localSubrIndex, globalSubrIndex) {
  6633. if (state.callDepth > MAX_SUBR_NESTING) {
  6634. return false;
  6635. }
  6636. var stackSize = state.stackSize;
  6637. var stack = state.stack;
  6638. var length = data.length;
  6639. for (var j = 0; j < length;) {
  6640. var value = data[j++];
  6641. var validationCommand = null;
  6642. if (value === 12) {
  6643. var q = data[j++];
  6644. if (q === 0) {
  6645. data[j - 2] = 139;
  6646. data[j - 1] = 22;
  6647. stackSize = 0;
  6648. } else {
  6649. validationCommand = CharstringValidationData12[q];
  6650. }
  6651. } else if (value === 28) {
  6652. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16) >> 16;
  6653. j += 2;
  6654. stackSize++;
  6655. } else if (value === 14) {
  6656. if (stackSize >= 4) {
  6657. stackSize -= 4;
  6658. if (this.seacAnalysisEnabled) {
  6659. state.seac = stack.slice(stackSize, stackSize + 4);
  6660. return false;
  6661. }
  6662. }
  6663. validationCommand = CharstringValidationData[value];
  6664. } else if (value >= 32 && value <= 246) {
  6665. stack[stackSize] = value - 139;
  6666. stackSize++;
  6667. } else if (value >= 247 && value <= 254) {
  6668. stack[stackSize] = value < 251 ? (value - 247 << 8) + data[j] + 108 : -(value - 251 << 8) - data[j] - 108;
  6669. j++;
  6670. stackSize++;
  6671. } else if (value === 255) {
  6672. stack[stackSize] = (data[j] << 24 | data[j + 1] << 16 | data[j + 2] << 8 | data[j + 3]) / 65536;
  6673. j += 4;
  6674. stackSize++;
  6675. } else if (value === 19 || value === 20) {
  6676. state.hints += stackSize >> 1;
  6677. j += state.hints + 7 >> 3;
  6678. stackSize %= 2;
  6679. validationCommand = CharstringValidationData[value];
  6680. } else if (value === 10 || value === 29) {
  6681. var subrsIndex;
  6682. if (value === 10) {
  6683. subrsIndex = localSubrIndex;
  6684. } else {
  6685. subrsIndex = globalSubrIndex;
  6686. }
  6687. if (!subrsIndex) {
  6688. validationCommand = CharstringValidationData[value];
  6689. warn('Missing subrsIndex for ' + validationCommand.id);
  6690. return false;
  6691. }
  6692. var bias = 32768;
  6693. if (subrsIndex.count < 1240) {
  6694. bias = 107;
  6695. } else if (subrsIndex.count < 33900) {
  6696. bias = 1131;
  6697. }
  6698. var subrNumber = stack[--stackSize] + bias;
  6699. if (subrNumber < 0 || subrNumber >= subrsIndex.count) {
  6700. validationCommand = CharstringValidationData[value];
  6701. warn('Out of bounds subrIndex for ' + validationCommand.id);
  6702. return false;
  6703. }
  6704. state.stackSize = stackSize;
  6705. state.callDepth++;
  6706. var valid = this.parseCharString(state, subrsIndex.get(subrNumber), localSubrIndex, globalSubrIndex);
  6707. if (!valid) {
  6708. return false;
  6709. }
  6710. state.callDepth--;
  6711. stackSize = state.stackSize;
  6712. continue;
  6713. } else if (value === 11) {
  6714. state.stackSize = stackSize;
  6715. return true;
  6716. } else {
  6717. validationCommand = CharstringValidationData[value];
  6718. }
  6719. if (validationCommand) {
  6720. if (validationCommand.stem) {
  6721. state.hints += stackSize >> 1;
  6722. }
  6723. if ('min' in validationCommand) {
  6724. if (!state.undefStack && stackSize < validationCommand.min) {
  6725. warn('Not enough parameters for ' + validationCommand.id + '; actual: ' + stackSize + ', expected: ' + validationCommand.min);
  6726. return false;
  6727. }
  6728. }
  6729. if (state.firstStackClearing && validationCommand.stackClearing) {
  6730. state.firstStackClearing = false;
  6731. stackSize -= validationCommand.min;
  6732. if (stackSize >= 2 && validationCommand.stem) {
  6733. stackSize %= 2;
  6734. } else if (stackSize > 1) {
  6735. warn('Found too many parameters for stack-clearing command');
  6736. }
  6737. if (stackSize > 0 && stack[stackSize - 1] >= 0) {
  6738. state.width = stack[stackSize - 1];
  6739. }
  6740. }
  6741. if ('stackDelta' in validationCommand) {
  6742. if ('stackFn' in validationCommand) {
  6743. validationCommand.stackFn(stack, stackSize);
  6744. }
  6745. stackSize += validationCommand.stackDelta;
  6746. } else if (validationCommand.stackClearing) {
  6747. stackSize = 0;
  6748. } else if (validationCommand.resetStack) {
  6749. stackSize = 0;
  6750. state.undefStack = false;
  6751. } else if (validationCommand.undefStack) {
  6752. stackSize = 0;
  6753. state.undefStack = true;
  6754. state.firstStackClearing = false;
  6755. }
  6756. }
  6757. }
  6758. state.stackSize = stackSize;
  6759. return true;
  6760. },
  6761. parseCharStrings: function CFFParser_parseCharStrings(charStrings, localSubrIndex, globalSubrIndex, fdSelect, fdArray) {
  6762. var seacs = [];
  6763. var widths = [];
  6764. var count = charStrings.count;
  6765. for (var i = 0; i < count; i++) {
  6766. var charstring = charStrings.get(i);
  6767. var state = {
  6768. callDepth: 0,
  6769. stackSize: 0,
  6770. stack: [],
  6771. undefStack: true,
  6772. hints: 0,
  6773. firstStackClearing: true,
  6774. seac: null,
  6775. width: null
  6776. };
  6777. var valid = true;
  6778. var localSubrToUse = null;
  6779. if (fdSelect && fdArray.length) {
  6780. var fdIndex = fdSelect.getFDIndex(i);
  6781. if (fdIndex === -1) {
  6782. warn('Glyph index is not in fd select.');
  6783. valid = false;
  6784. }
  6785. if (fdIndex >= fdArray.length) {
  6786. warn('Invalid fd index for glyph index.');
  6787. valid = false;
  6788. }
  6789. if (valid) {
  6790. localSubrToUse = fdArray[fdIndex].privateDict.subrsIndex;
  6791. }
  6792. } else if (localSubrIndex) {
  6793. localSubrToUse = localSubrIndex;
  6794. }
  6795. if (valid) {
  6796. valid = this.parseCharString(state, charstring, localSubrToUse, globalSubrIndex);
  6797. }
  6798. if (state.width !== null) {
  6799. widths[i] = state.width;
  6800. }
  6801. if (state.seac !== null) {
  6802. seacs[i] = state.seac;
  6803. }
  6804. if (!valid) {
  6805. charStrings.set(i, new Uint8Array([14]));
  6806. }
  6807. }
  6808. return {
  6809. charStrings: charStrings,
  6810. seacs: seacs,
  6811. widths: widths
  6812. };
  6813. },
  6814. emptyPrivateDictionary: function CFFParser_emptyPrivateDictionary(parentDict) {
  6815. var privateDict = this.createDict(CFFPrivateDict, [], parentDict.strings);
  6816. parentDict.setByKey(18, [
  6817. 0,
  6818. 0
  6819. ]);
  6820. parentDict.privateDict = privateDict;
  6821. },
  6822. parsePrivateDict: function CFFParser_parsePrivateDict(parentDict) {
  6823. if (!parentDict.hasName('Private')) {
  6824. this.emptyPrivateDictionary(parentDict);
  6825. return;
  6826. }
  6827. var privateOffset = parentDict.getByName('Private');
  6828. if (!isArray(privateOffset) || privateOffset.length !== 2) {
  6829. parentDict.removeByName('Private');
  6830. return;
  6831. }
  6832. var size = privateOffset[0];
  6833. var offset = privateOffset[1];
  6834. if (size === 0 || offset >= this.bytes.length) {
  6835. this.emptyPrivateDictionary(parentDict);
  6836. return;
  6837. }
  6838. var privateDictEnd = offset + size;
  6839. var dictData = this.bytes.subarray(offset, privateDictEnd);
  6840. var dict = this.parseDict(dictData);
  6841. var privateDict = this.createDict(CFFPrivateDict, dict, parentDict.strings);
  6842. parentDict.privateDict = privateDict;
  6843. if (!privateDict.getByName('Subrs')) {
  6844. return;
  6845. }
  6846. var subrsOffset = privateDict.getByName('Subrs');
  6847. var relativeOffset = offset + subrsOffset;
  6848. if (subrsOffset === 0 || relativeOffset >= this.bytes.length) {
  6849. this.emptyPrivateDictionary(parentDict);
  6850. return;
  6851. }
  6852. var subrsIndex = this.parseIndex(relativeOffset);
  6853. privateDict.subrsIndex = subrsIndex.obj;
  6854. },
  6855. parseCharsets: function CFFParser_parseCharsets(pos, length, strings, cid) {
  6856. if (pos === 0) {
  6857. return new CFFCharset(true, CFFCharsetPredefinedTypes.ISO_ADOBE, ISOAdobeCharset);
  6858. } else if (pos === 1) {
  6859. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT, ExpertCharset);
  6860. } else if (pos === 2) {
  6861. return new CFFCharset(true, CFFCharsetPredefinedTypes.EXPERT_SUBSET, ExpertSubsetCharset);
  6862. }
  6863. var bytes = this.bytes;
  6864. var start = pos;
  6865. var format = bytes[pos++];
  6866. var charset = ['.notdef'];
  6867. var id, count, i;
  6868. length -= 1;
  6869. switch (format) {
  6870. case 0:
  6871. for (i = 0; i < length; i++) {
  6872. id = bytes[pos++] << 8 | bytes[pos++];
  6873. charset.push(cid ? id : strings.get(id));
  6874. }
  6875. break;
  6876. case 1:
  6877. while (charset.length <= length) {
  6878. id = bytes[pos++] << 8 | bytes[pos++];
  6879. count = bytes[pos++];
  6880. for (i = 0; i <= count; i++) {
  6881. charset.push(cid ? id++ : strings.get(id++));
  6882. }
  6883. }
  6884. break;
  6885. case 2:
  6886. while (charset.length <= length) {
  6887. id = bytes[pos++] << 8 | bytes[pos++];
  6888. count = bytes[pos++] << 8 | bytes[pos++];
  6889. for (i = 0; i <= count; i++) {
  6890. charset.push(cid ? id++ : strings.get(id++));
  6891. }
  6892. }
  6893. break;
  6894. default:
  6895. error('Unknown charset format');
  6896. }
  6897. var end = pos;
  6898. var raw = bytes.subarray(start, end);
  6899. return new CFFCharset(false, format, charset, raw);
  6900. },
  6901. parseEncoding: function CFFParser_parseEncoding(pos, properties, strings, charset) {
  6902. var encoding = Object.create(null);
  6903. var bytes = this.bytes;
  6904. var predefined = false;
  6905. var hasSupplement = false;
  6906. var format, i, ii;
  6907. var raw = null;
  6908. function readSupplement() {
  6909. var supplementsCount = bytes[pos++];
  6910. for (i = 0; i < supplementsCount; i++) {
  6911. var code = bytes[pos++];
  6912. var sid = (bytes[pos++] << 8) + (bytes[pos++] & 0xff);
  6913. encoding[code] = charset.indexOf(strings.get(sid));
  6914. }
  6915. }
  6916. if (pos === 0 || pos === 1) {
  6917. predefined = true;
  6918. format = pos;
  6919. var baseEncoding = pos ? ExpertEncoding : StandardEncoding;
  6920. for (i = 0, ii = charset.length; i < ii; i++) {
  6921. var index = baseEncoding.indexOf(charset[i]);
  6922. if (index !== -1) {
  6923. encoding[index] = i;
  6924. }
  6925. }
  6926. } else {
  6927. var dataStart = pos;
  6928. format = bytes[pos++];
  6929. switch (format & 0x7f) {
  6930. case 0:
  6931. var glyphsCount = bytes[pos++];
  6932. for (i = 1; i <= glyphsCount; i++) {
  6933. encoding[bytes[pos++]] = i;
  6934. }
  6935. break;
  6936. case 1:
  6937. var rangesCount = bytes[pos++];
  6938. var gid = 1;
  6939. for (i = 0; i < rangesCount; i++) {
  6940. var start = bytes[pos++];
  6941. var left = bytes[pos++];
  6942. for (var j = start; j <= start + left; j++) {
  6943. encoding[j] = gid++;
  6944. }
  6945. }
  6946. break;
  6947. default:
  6948. error('Unknown encoding format: ' + format + ' in CFF');
  6949. break;
  6950. }
  6951. var dataEnd = pos;
  6952. if (format & 0x80) {
  6953. bytes[dataStart] &= 0x7f;
  6954. readSupplement();
  6955. hasSupplement = true;
  6956. }
  6957. raw = bytes.subarray(dataStart, dataEnd);
  6958. }
  6959. format = format & 0x7f;
  6960. return new CFFEncoding(predefined, format, encoding, raw);
  6961. },
  6962. parseFDSelect: function CFFParser_parseFDSelect(pos, length) {
  6963. var start = pos;
  6964. var bytes = this.bytes;
  6965. var format = bytes[pos++];
  6966. var fdSelect = [], rawBytes;
  6967. var i, invalidFirstGID = false;
  6968. switch (format) {
  6969. case 0:
  6970. for (i = 0; i < length; ++i) {
  6971. var id = bytes[pos++];
  6972. fdSelect.push(id);
  6973. }
  6974. rawBytes = bytes.subarray(start, pos);
  6975. break;
  6976. case 3:
  6977. var rangesCount = bytes[pos++] << 8 | bytes[pos++];
  6978. for (i = 0; i < rangesCount; ++i) {
  6979. var first = bytes[pos++] << 8 | bytes[pos++];
  6980. if (i === 0 && first !== 0) {
  6981. warn('parseFDSelect: The first range must have a first GID of 0' + ' -- trying to recover.');
  6982. invalidFirstGID = true;
  6983. first = 0;
  6984. }
  6985. var fdIndex = bytes[pos++];
  6986. var next = bytes[pos] << 8 | bytes[pos + 1];
  6987. for (var j = first; j < next; ++j) {
  6988. fdSelect.push(fdIndex);
  6989. }
  6990. }
  6991. pos += 2;
  6992. rawBytes = bytes.subarray(start, pos);
  6993. if (invalidFirstGID) {
  6994. rawBytes[3] = rawBytes[4] = 0;
  6995. }
  6996. break;
  6997. default:
  6998. error('parseFDSelect: Unknown format "' + format + '".');
  6999. break;
  7000. }
  7001. assert(fdSelect.length === length, 'parseFDSelect: Invalid font data.');
  7002. return new CFFFDSelect(fdSelect, rawBytes);
  7003. }
  7004. };
  7005. return CFFParser;
  7006. }();
  7007. var CFF = function CFFClosure() {
  7008. function CFF() {
  7009. this.header = null;
  7010. this.names = [];
  7011. this.topDict = null;
  7012. this.strings = new CFFStrings();
  7013. this.globalSubrIndex = null;
  7014. this.encoding = null;
  7015. this.charset = null;
  7016. this.charStrings = null;
  7017. this.fdArray = [];
  7018. this.fdSelect = null;
  7019. this.isCIDFont = false;
  7020. }
  7021. return CFF;
  7022. }();
  7023. var CFFHeader = function CFFHeaderClosure() {
  7024. function CFFHeader(major, minor, hdrSize, offSize) {
  7025. this.major = major;
  7026. this.minor = minor;
  7027. this.hdrSize = hdrSize;
  7028. this.offSize = offSize;
  7029. }
  7030. return CFFHeader;
  7031. }();
  7032. var CFFStrings = function CFFStringsClosure() {
  7033. function CFFStrings() {
  7034. this.strings = [];
  7035. }
  7036. CFFStrings.prototype = {
  7037. get: function CFFStrings_get(index) {
  7038. if (index >= 0 && index <= 390) {
  7039. return CFFStandardStrings[index];
  7040. }
  7041. if (index - 391 <= this.strings.length) {
  7042. return this.strings[index - 391];
  7043. }
  7044. return CFFStandardStrings[0];
  7045. },
  7046. add: function CFFStrings_add(value) {
  7047. this.strings.push(value);
  7048. },
  7049. get count() {
  7050. return this.strings.length;
  7051. }
  7052. };
  7053. return CFFStrings;
  7054. }();
  7055. var CFFIndex = function CFFIndexClosure() {
  7056. function CFFIndex() {
  7057. this.objects = [];
  7058. this.length = 0;
  7059. }
  7060. CFFIndex.prototype = {
  7061. add: function CFFIndex_add(data) {
  7062. this.length += data.length;
  7063. this.objects.push(data);
  7064. },
  7065. set: function CFFIndex_set(index, data) {
  7066. this.length += data.length - this.objects[index].length;
  7067. this.objects[index] = data;
  7068. },
  7069. get: function CFFIndex_get(index) {
  7070. return this.objects[index];
  7071. },
  7072. get count() {
  7073. return this.objects.length;
  7074. }
  7075. };
  7076. return CFFIndex;
  7077. }();
  7078. var CFFDict = function CFFDictClosure() {
  7079. function CFFDict(tables, strings) {
  7080. this.keyToNameMap = tables.keyToNameMap;
  7081. this.nameToKeyMap = tables.nameToKeyMap;
  7082. this.defaults = tables.defaults;
  7083. this.types = tables.types;
  7084. this.opcodes = tables.opcodes;
  7085. this.order = tables.order;
  7086. this.strings = strings;
  7087. this.values = Object.create(null);
  7088. }
  7089. CFFDict.prototype = {
  7090. setByKey: function CFFDict_setByKey(key, value) {
  7091. if (!(key in this.keyToNameMap)) {
  7092. return false;
  7093. }
  7094. var valueLength = value.length;
  7095. if (valueLength === 0) {
  7096. return true;
  7097. }
  7098. for (var i = 0; i < valueLength; i++) {
  7099. if (isNaN(value[i])) {
  7100. warn('Invalid CFFDict value: "' + value + '" for key "' + key + '".');
  7101. return true;
  7102. }
  7103. }
  7104. var type = this.types[key];
  7105. if (type === 'num' || type === 'sid' || type === 'offset') {
  7106. value = value[0];
  7107. }
  7108. this.values[key] = value;
  7109. return true;
  7110. },
  7111. setByName: function CFFDict_setByName(name, value) {
  7112. if (!(name in this.nameToKeyMap)) {
  7113. error('Invalid dictionary name "' + name + '"');
  7114. }
  7115. this.values[this.nameToKeyMap[name]] = value;
  7116. },
  7117. hasName: function CFFDict_hasName(name) {
  7118. return this.nameToKeyMap[name] in this.values;
  7119. },
  7120. getByName: function CFFDict_getByName(name) {
  7121. if (!(name in this.nameToKeyMap)) {
  7122. error('Invalid dictionary name "' + name + '"');
  7123. }
  7124. var key = this.nameToKeyMap[name];
  7125. if (!(key in this.values)) {
  7126. return this.defaults[key];
  7127. }
  7128. return this.values[key];
  7129. },
  7130. removeByName: function CFFDict_removeByName(name) {
  7131. delete this.values[this.nameToKeyMap[name]];
  7132. }
  7133. };
  7134. CFFDict.createTables = function CFFDict_createTables(layout) {
  7135. var tables = {
  7136. keyToNameMap: {},
  7137. nameToKeyMap: {},
  7138. defaults: {},
  7139. types: {},
  7140. opcodes: {},
  7141. order: []
  7142. };
  7143. for (var i = 0, ii = layout.length; i < ii; ++i) {
  7144. var entry = layout[i];
  7145. var key = isArray(entry[0]) ? (entry[0][0] << 8) + entry[0][1] : entry[0];
  7146. tables.keyToNameMap[key] = entry[1];
  7147. tables.nameToKeyMap[entry[1]] = key;
  7148. tables.types[key] = entry[2];
  7149. tables.defaults[key] = entry[3];
  7150. tables.opcodes[key] = isArray(entry[0]) ? entry[0] : [entry[0]];
  7151. tables.order.push(key);
  7152. }
  7153. return tables;
  7154. };
  7155. return CFFDict;
  7156. }();
  7157. var CFFTopDict = function CFFTopDictClosure() {
  7158. var layout = [
  7159. [
  7160. [
  7161. 12,
  7162. 30
  7163. ],
  7164. 'ROS',
  7165. [
  7166. 'sid',
  7167. 'sid',
  7168. 'num'
  7169. ],
  7170. null
  7171. ],
  7172. [
  7173. [
  7174. 12,
  7175. 20
  7176. ],
  7177. 'SyntheticBase',
  7178. 'num',
  7179. null
  7180. ],
  7181. [
  7182. 0,
  7183. 'version',
  7184. 'sid',
  7185. null
  7186. ],
  7187. [
  7188. 1,
  7189. 'Notice',
  7190. 'sid',
  7191. null
  7192. ],
  7193. [
  7194. [
  7195. 12,
  7196. 0
  7197. ],
  7198. 'Copyright',
  7199. 'sid',
  7200. null
  7201. ],
  7202. [
  7203. 2,
  7204. 'FullName',
  7205. 'sid',
  7206. null
  7207. ],
  7208. [
  7209. 3,
  7210. 'FamilyName',
  7211. 'sid',
  7212. null
  7213. ],
  7214. [
  7215. 4,
  7216. 'Weight',
  7217. 'sid',
  7218. null
  7219. ],
  7220. [
  7221. [
  7222. 12,
  7223. 1
  7224. ],
  7225. 'isFixedPitch',
  7226. 'num',
  7227. 0
  7228. ],
  7229. [
  7230. [
  7231. 12,
  7232. 2
  7233. ],
  7234. 'ItalicAngle',
  7235. 'num',
  7236. 0
  7237. ],
  7238. [
  7239. [
  7240. 12,
  7241. 3
  7242. ],
  7243. 'UnderlinePosition',
  7244. 'num',
  7245. -100
  7246. ],
  7247. [
  7248. [
  7249. 12,
  7250. 4
  7251. ],
  7252. 'UnderlineThickness',
  7253. 'num',
  7254. 50
  7255. ],
  7256. [
  7257. [
  7258. 12,
  7259. 5
  7260. ],
  7261. 'PaintType',
  7262. 'num',
  7263. 0
  7264. ],
  7265. [
  7266. [
  7267. 12,
  7268. 6
  7269. ],
  7270. 'CharstringType',
  7271. 'num',
  7272. 2
  7273. ],
  7274. [
  7275. [
  7276. 12,
  7277. 7
  7278. ],
  7279. 'FontMatrix',
  7280. [
  7281. 'num',
  7282. 'num',
  7283. 'num',
  7284. 'num',
  7285. 'num',
  7286. 'num'
  7287. ],
  7288. [
  7289. 0.001,
  7290. 0,
  7291. 0,
  7292. 0.001,
  7293. 0,
  7294. 0
  7295. ]
  7296. ],
  7297. [
  7298. 13,
  7299. 'UniqueID',
  7300. 'num',
  7301. null
  7302. ],
  7303. [
  7304. 5,
  7305. 'FontBBox',
  7306. [
  7307. 'num',
  7308. 'num',
  7309. 'num',
  7310. 'num'
  7311. ],
  7312. [
  7313. 0,
  7314. 0,
  7315. 0,
  7316. 0
  7317. ]
  7318. ],
  7319. [
  7320. [
  7321. 12,
  7322. 8
  7323. ],
  7324. 'StrokeWidth',
  7325. 'num',
  7326. 0
  7327. ],
  7328. [
  7329. 14,
  7330. 'XUID',
  7331. 'array',
  7332. null
  7333. ],
  7334. [
  7335. 15,
  7336. 'charset',
  7337. 'offset',
  7338. 0
  7339. ],
  7340. [
  7341. 16,
  7342. 'Encoding',
  7343. 'offset',
  7344. 0
  7345. ],
  7346. [
  7347. 17,
  7348. 'CharStrings',
  7349. 'offset',
  7350. 0
  7351. ],
  7352. [
  7353. 18,
  7354. 'Private',
  7355. [
  7356. 'offset',
  7357. 'offset'
  7358. ],
  7359. null
  7360. ],
  7361. [
  7362. [
  7363. 12,
  7364. 21
  7365. ],
  7366. 'PostScript',
  7367. 'sid',
  7368. null
  7369. ],
  7370. [
  7371. [
  7372. 12,
  7373. 22
  7374. ],
  7375. 'BaseFontName',
  7376. 'sid',
  7377. null
  7378. ],
  7379. [
  7380. [
  7381. 12,
  7382. 23
  7383. ],
  7384. 'BaseFontBlend',
  7385. 'delta',
  7386. null
  7387. ],
  7388. [
  7389. [
  7390. 12,
  7391. 31
  7392. ],
  7393. 'CIDFontVersion',
  7394. 'num',
  7395. 0
  7396. ],
  7397. [
  7398. [
  7399. 12,
  7400. 32
  7401. ],
  7402. 'CIDFontRevision',
  7403. 'num',
  7404. 0
  7405. ],
  7406. [
  7407. [
  7408. 12,
  7409. 33
  7410. ],
  7411. 'CIDFontType',
  7412. 'num',
  7413. 0
  7414. ],
  7415. [
  7416. [
  7417. 12,
  7418. 34
  7419. ],
  7420. 'CIDCount',
  7421. 'num',
  7422. 8720
  7423. ],
  7424. [
  7425. [
  7426. 12,
  7427. 35
  7428. ],
  7429. 'UIDBase',
  7430. 'num',
  7431. null
  7432. ],
  7433. [
  7434. [
  7435. 12,
  7436. 37
  7437. ],
  7438. 'FDSelect',
  7439. 'offset',
  7440. null
  7441. ],
  7442. [
  7443. [
  7444. 12,
  7445. 36
  7446. ],
  7447. 'FDArray',
  7448. 'offset',
  7449. null
  7450. ],
  7451. [
  7452. [
  7453. 12,
  7454. 38
  7455. ],
  7456. 'FontName',
  7457. 'sid',
  7458. null
  7459. ]
  7460. ];
  7461. var tables = null;
  7462. function CFFTopDict(strings) {
  7463. if (tables === null) {
  7464. tables = CFFDict.createTables(layout);
  7465. }
  7466. CFFDict.call(this, tables, strings);
  7467. this.privateDict = null;
  7468. }
  7469. CFFTopDict.prototype = Object.create(CFFDict.prototype);
  7470. return CFFTopDict;
  7471. }();
  7472. var CFFPrivateDict = function CFFPrivateDictClosure() {
  7473. var layout = [
  7474. [
  7475. 6,
  7476. 'BlueValues',
  7477. 'delta',
  7478. null
  7479. ],
  7480. [
  7481. 7,
  7482. 'OtherBlues',
  7483. 'delta',
  7484. null
  7485. ],
  7486. [
  7487. 8,
  7488. 'FamilyBlues',
  7489. 'delta',
  7490. null
  7491. ],
  7492. [
  7493. 9,
  7494. 'FamilyOtherBlues',
  7495. 'delta',
  7496. null
  7497. ],
  7498. [
  7499. [
  7500. 12,
  7501. 9
  7502. ],
  7503. 'BlueScale',
  7504. 'num',
  7505. 0.039625
  7506. ],
  7507. [
  7508. [
  7509. 12,
  7510. 10
  7511. ],
  7512. 'BlueShift',
  7513. 'num',
  7514. 7
  7515. ],
  7516. [
  7517. [
  7518. 12,
  7519. 11
  7520. ],
  7521. 'BlueFuzz',
  7522. 'num',
  7523. 1
  7524. ],
  7525. [
  7526. 10,
  7527. 'StdHW',
  7528. 'num',
  7529. null
  7530. ],
  7531. [
  7532. 11,
  7533. 'StdVW',
  7534. 'num',
  7535. null
  7536. ],
  7537. [
  7538. [
  7539. 12,
  7540. 12
  7541. ],
  7542. 'StemSnapH',
  7543. 'delta',
  7544. null
  7545. ],
  7546. [
  7547. [
  7548. 12,
  7549. 13
  7550. ],
  7551. 'StemSnapV',
  7552. 'delta',
  7553. null
  7554. ],
  7555. [
  7556. [
  7557. 12,
  7558. 14
  7559. ],
  7560. 'ForceBold',
  7561. 'num',
  7562. 0
  7563. ],
  7564. [
  7565. [
  7566. 12,
  7567. 17
  7568. ],
  7569. 'LanguageGroup',
  7570. 'num',
  7571. 0
  7572. ],
  7573. [
  7574. [
  7575. 12,
  7576. 18
  7577. ],
  7578. 'ExpansionFactor',
  7579. 'num',
  7580. 0.06
  7581. ],
  7582. [
  7583. [
  7584. 12,
  7585. 19
  7586. ],
  7587. 'initialRandomSeed',
  7588. 'num',
  7589. 0
  7590. ],
  7591. [
  7592. 20,
  7593. 'defaultWidthX',
  7594. 'num',
  7595. 0
  7596. ],
  7597. [
  7598. 21,
  7599. 'nominalWidthX',
  7600. 'num',
  7601. 0
  7602. ],
  7603. [
  7604. 19,
  7605. 'Subrs',
  7606. 'offset',
  7607. null
  7608. ]
  7609. ];
  7610. var tables = null;
  7611. function CFFPrivateDict(strings) {
  7612. if (tables === null) {
  7613. tables = CFFDict.createTables(layout);
  7614. }
  7615. CFFDict.call(this, tables, strings);
  7616. this.subrsIndex = null;
  7617. }
  7618. CFFPrivateDict.prototype = Object.create(CFFDict.prototype);
  7619. return CFFPrivateDict;
  7620. }();
  7621. var CFFCharsetPredefinedTypes = {
  7622. ISO_ADOBE: 0,
  7623. EXPERT: 1,
  7624. EXPERT_SUBSET: 2
  7625. };
  7626. var CFFCharset = function CFFCharsetClosure() {
  7627. function CFFCharset(predefined, format, charset, raw) {
  7628. this.predefined = predefined;
  7629. this.format = format;
  7630. this.charset = charset;
  7631. this.raw = raw;
  7632. }
  7633. return CFFCharset;
  7634. }();
  7635. var CFFEncoding = function CFFEncodingClosure() {
  7636. function CFFEncoding(predefined, format, encoding, raw) {
  7637. this.predefined = predefined;
  7638. this.format = format;
  7639. this.encoding = encoding;
  7640. this.raw = raw;
  7641. }
  7642. return CFFEncoding;
  7643. }();
  7644. var CFFFDSelect = function CFFFDSelectClosure() {
  7645. function CFFFDSelect(fdSelect, raw) {
  7646. this.fdSelect = fdSelect;
  7647. this.raw = raw;
  7648. }
  7649. CFFFDSelect.prototype = {
  7650. getFDIndex: function CFFFDSelect_get(glyphIndex) {
  7651. if (glyphIndex < 0 || glyphIndex >= this.fdSelect.length) {
  7652. return -1;
  7653. }
  7654. return this.fdSelect[glyphIndex];
  7655. }
  7656. };
  7657. return CFFFDSelect;
  7658. }();
  7659. var CFFOffsetTracker = function CFFOffsetTrackerClosure() {
  7660. function CFFOffsetTracker() {
  7661. this.offsets = Object.create(null);
  7662. }
  7663. CFFOffsetTracker.prototype = {
  7664. isTracking: function CFFOffsetTracker_isTracking(key) {
  7665. return key in this.offsets;
  7666. },
  7667. track: function CFFOffsetTracker_track(key, location) {
  7668. if (key in this.offsets) {
  7669. error('Already tracking location of ' + key);
  7670. }
  7671. this.offsets[key] = location;
  7672. },
  7673. offset: function CFFOffsetTracker_offset(value) {
  7674. for (var key in this.offsets) {
  7675. this.offsets[key] += value;
  7676. }
  7677. },
  7678. setEntryLocation: function CFFOffsetTracker_setEntryLocation(key, values, output) {
  7679. if (!(key in this.offsets)) {
  7680. error('Not tracking location of ' + key);
  7681. }
  7682. var data = output.data;
  7683. var dataOffset = this.offsets[key];
  7684. var size = 5;
  7685. for (var i = 0, ii = values.length; i < ii; ++i) {
  7686. var offset0 = i * size + dataOffset;
  7687. var offset1 = offset0 + 1;
  7688. var offset2 = offset0 + 2;
  7689. var offset3 = offset0 + 3;
  7690. var offset4 = offset0 + 4;
  7691. if (data[offset0] !== 0x1d || data[offset1] !== 0 || data[offset2] !== 0 || data[offset3] !== 0 || data[offset4] !== 0) {
  7692. error('writing to an offset that is not empty');
  7693. }
  7694. var value = values[i];
  7695. data[offset0] = 0x1d;
  7696. data[offset1] = value >> 24 & 0xFF;
  7697. data[offset2] = value >> 16 & 0xFF;
  7698. data[offset3] = value >> 8 & 0xFF;
  7699. data[offset4] = value & 0xFF;
  7700. }
  7701. }
  7702. };
  7703. return CFFOffsetTracker;
  7704. }();
  7705. var CFFCompiler = function CFFCompilerClosure() {
  7706. function CFFCompiler(cff) {
  7707. this.cff = cff;
  7708. }
  7709. CFFCompiler.prototype = {
  7710. compile: function CFFCompiler_compile() {
  7711. var cff = this.cff;
  7712. var output = {
  7713. data: [],
  7714. length: 0,
  7715. add: function CFFCompiler_add(data) {
  7716. this.data = this.data.concat(data);
  7717. this.length = this.data.length;
  7718. }
  7719. };
  7720. var header = this.compileHeader(cff.header);
  7721. output.add(header);
  7722. var nameIndex = this.compileNameIndex(cff.names);
  7723. output.add(nameIndex);
  7724. if (cff.isCIDFont) {
  7725. if (cff.topDict.hasName('FontMatrix')) {
  7726. var base = cff.topDict.getByName('FontMatrix');
  7727. cff.topDict.removeByName('FontMatrix');
  7728. for (var i = 0, ii = cff.fdArray.length; i < ii; i++) {
  7729. var subDict = cff.fdArray[i];
  7730. var matrix = base.slice(0);
  7731. if (subDict.hasName('FontMatrix')) {
  7732. matrix = Util.transform(matrix, subDict.getByName('FontMatrix'));
  7733. }
  7734. subDict.setByName('FontMatrix', matrix);
  7735. }
  7736. }
  7737. }
  7738. var compiled = this.compileTopDicts([cff.topDict], output.length, cff.isCIDFont);
  7739. output.add(compiled.output);
  7740. var topDictTracker = compiled.trackers[0];
  7741. var stringIndex = this.compileStringIndex(cff.strings.strings);
  7742. output.add(stringIndex);
  7743. var globalSubrIndex = this.compileIndex(cff.globalSubrIndex);
  7744. output.add(globalSubrIndex);
  7745. if (cff.encoding && cff.topDict.hasName('Encoding')) {
  7746. if (cff.encoding.predefined) {
  7747. topDictTracker.setEntryLocation('Encoding', [cff.encoding.format], output);
  7748. } else {
  7749. var encoding = this.compileEncoding(cff.encoding);
  7750. topDictTracker.setEntryLocation('Encoding', [output.length], output);
  7751. output.add(encoding);
  7752. }
  7753. }
  7754. if (cff.charset && cff.topDict.hasName('charset')) {
  7755. if (cff.charset.predefined) {
  7756. topDictTracker.setEntryLocation('charset', [cff.charset.format], output);
  7757. } else {
  7758. var charset = this.compileCharset(cff.charset);
  7759. topDictTracker.setEntryLocation('charset', [output.length], output);
  7760. output.add(charset);
  7761. }
  7762. }
  7763. var charStrings = this.compileCharStrings(cff.charStrings);
  7764. topDictTracker.setEntryLocation('CharStrings', [output.length], output);
  7765. output.add(charStrings);
  7766. if (cff.isCIDFont) {
  7767. topDictTracker.setEntryLocation('FDSelect', [output.length], output);
  7768. var fdSelect = this.compileFDSelect(cff.fdSelect.raw);
  7769. output.add(fdSelect);
  7770. compiled = this.compileTopDicts(cff.fdArray, output.length, true);
  7771. topDictTracker.setEntryLocation('FDArray', [output.length], output);
  7772. output.add(compiled.output);
  7773. var fontDictTrackers = compiled.trackers;
  7774. this.compilePrivateDicts(cff.fdArray, fontDictTrackers, output);
  7775. }
  7776. this.compilePrivateDicts([cff.topDict], [topDictTracker], output);
  7777. output.add([0]);
  7778. return output.data;
  7779. },
  7780. encodeNumber: function CFFCompiler_encodeNumber(value) {
  7781. if (parseFloat(value) === parseInt(value, 10) && !isNaN(value)) {
  7782. return this.encodeInteger(value);
  7783. } else {
  7784. return this.encodeFloat(value);
  7785. }
  7786. },
  7787. encodeFloat: function CFFCompiler_encodeFloat(num) {
  7788. var value = num.toString();
  7789. var m = /\.(\d*?)(?:9{5,20}|0{5,20})\d{0,2}(?:e(.+)|$)/.exec(value);
  7790. if (m) {
  7791. var epsilon = parseFloat('1e' + ((m[2] ? +m[2] : 0) + m[1].length));
  7792. value = (Math.round(num * epsilon) / epsilon).toString();
  7793. }
  7794. var nibbles = '';
  7795. var i, ii;
  7796. for (i = 0, ii = value.length; i < ii; ++i) {
  7797. var a = value[i];
  7798. if (a === 'e') {
  7799. nibbles += value[++i] === '-' ? 'c' : 'b';
  7800. } else if (a === '.') {
  7801. nibbles += 'a';
  7802. } else if (a === '-') {
  7803. nibbles += 'e';
  7804. } else {
  7805. nibbles += a;
  7806. }
  7807. }
  7808. nibbles += nibbles.length & 1 ? 'f' : 'ff';
  7809. var out = [30];
  7810. for (i = 0, ii = nibbles.length; i < ii; i += 2) {
  7811. out.push(parseInt(nibbles.substr(i, 2), 16));
  7812. }
  7813. return out;
  7814. },
  7815. encodeInteger: function CFFCompiler_encodeInteger(value) {
  7816. var code;
  7817. if (value >= -107 && value <= 107) {
  7818. code = [value + 139];
  7819. } else if (value >= 108 && value <= 1131) {
  7820. value = value - 108;
  7821. code = [
  7822. (value >> 8) + 247,
  7823. value & 0xFF
  7824. ];
  7825. } else if (value >= -1131 && value <= -108) {
  7826. value = -value - 108;
  7827. code = [
  7828. (value >> 8) + 251,
  7829. value & 0xFF
  7830. ];
  7831. } else if (value >= -32768 && value <= 32767) {
  7832. code = [
  7833. 0x1c,
  7834. value >> 8 & 0xFF,
  7835. value & 0xFF
  7836. ];
  7837. } else {
  7838. code = [
  7839. 0x1d,
  7840. value >> 24 & 0xFF,
  7841. value >> 16 & 0xFF,
  7842. value >> 8 & 0xFF,
  7843. value & 0xFF
  7844. ];
  7845. }
  7846. return code;
  7847. },
  7848. compileHeader: function CFFCompiler_compileHeader(header) {
  7849. return [
  7850. header.major,
  7851. header.minor,
  7852. header.hdrSize,
  7853. header.offSize
  7854. ];
  7855. },
  7856. compileNameIndex: function CFFCompiler_compileNameIndex(names) {
  7857. var nameIndex = new CFFIndex();
  7858. for (var i = 0, ii = names.length; i < ii; ++i) {
  7859. nameIndex.add(stringToBytes(names[i]));
  7860. }
  7861. return this.compileIndex(nameIndex);
  7862. },
  7863. compileTopDicts: function CFFCompiler_compileTopDicts(dicts, length, removeCidKeys) {
  7864. var fontDictTrackers = [];
  7865. var fdArrayIndex = new CFFIndex();
  7866. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7867. var fontDict = dicts[i];
  7868. if (removeCidKeys) {
  7869. fontDict.removeByName('CIDFontVersion');
  7870. fontDict.removeByName('CIDFontRevision');
  7871. fontDict.removeByName('CIDFontType');
  7872. fontDict.removeByName('CIDCount');
  7873. fontDict.removeByName('UIDBase');
  7874. }
  7875. var fontDictTracker = new CFFOffsetTracker();
  7876. var fontDictData = this.compileDict(fontDict, fontDictTracker);
  7877. fontDictTrackers.push(fontDictTracker);
  7878. fdArrayIndex.add(fontDictData);
  7879. fontDictTracker.offset(length);
  7880. }
  7881. fdArrayIndex = this.compileIndex(fdArrayIndex, fontDictTrackers);
  7882. return {
  7883. trackers: fontDictTrackers,
  7884. output: fdArrayIndex
  7885. };
  7886. },
  7887. compilePrivateDicts: function CFFCompiler_compilePrivateDicts(dicts, trackers, output) {
  7888. for (var i = 0, ii = dicts.length; i < ii; ++i) {
  7889. var fontDict = dicts[i];
  7890. assert(fontDict.privateDict && fontDict.hasName('Private'), 'There must be an private dictionary.');
  7891. var privateDict = fontDict.privateDict;
  7892. var privateDictTracker = new CFFOffsetTracker();
  7893. var privateDictData = this.compileDict(privateDict, privateDictTracker);
  7894. var outputLength = output.length;
  7895. privateDictTracker.offset(outputLength);
  7896. if (!privateDictData.length) {
  7897. outputLength = 0;
  7898. }
  7899. trackers[i].setEntryLocation('Private', [
  7900. privateDictData.length,
  7901. outputLength
  7902. ], output);
  7903. output.add(privateDictData);
  7904. if (privateDict.subrsIndex && privateDict.hasName('Subrs')) {
  7905. var subrs = this.compileIndex(privateDict.subrsIndex);
  7906. privateDictTracker.setEntryLocation('Subrs', [privateDictData.length], output);
  7907. output.add(subrs);
  7908. }
  7909. }
  7910. },
  7911. compileDict: function CFFCompiler_compileDict(dict, offsetTracker) {
  7912. var out = [];
  7913. var order = dict.order;
  7914. for (var i = 0; i < order.length; ++i) {
  7915. var key = order[i];
  7916. if (!(key in dict.values)) {
  7917. continue;
  7918. }
  7919. var values = dict.values[key];
  7920. var types = dict.types[key];
  7921. if (!isArray(types)) {
  7922. types = [types];
  7923. }
  7924. if (!isArray(values)) {
  7925. values = [values];
  7926. }
  7927. if (values.length === 0) {
  7928. continue;
  7929. }
  7930. for (var j = 0, jj = types.length; j < jj; ++j) {
  7931. var type = types[j];
  7932. var value = values[j];
  7933. switch (type) {
  7934. case 'num':
  7935. case 'sid':
  7936. out = out.concat(this.encodeNumber(value));
  7937. break;
  7938. case 'offset':
  7939. var name = dict.keyToNameMap[key];
  7940. if (!offsetTracker.isTracking(name)) {
  7941. offsetTracker.track(name, out.length);
  7942. }
  7943. out = out.concat([
  7944. 0x1d,
  7945. 0,
  7946. 0,
  7947. 0,
  7948. 0
  7949. ]);
  7950. break;
  7951. case 'array':
  7952. case 'delta':
  7953. out = out.concat(this.encodeNumber(value));
  7954. for (var k = 1, kk = values.length; k < kk; ++k) {
  7955. out = out.concat(this.encodeNumber(values[k]));
  7956. }
  7957. break;
  7958. default:
  7959. error('Unknown data type of ' + type);
  7960. break;
  7961. }
  7962. }
  7963. out = out.concat(dict.opcodes[key]);
  7964. }
  7965. return out;
  7966. },
  7967. compileStringIndex: function CFFCompiler_compileStringIndex(strings) {
  7968. var stringIndex = new CFFIndex();
  7969. for (var i = 0, ii = strings.length; i < ii; ++i) {
  7970. stringIndex.add(stringToBytes(strings[i]));
  7971. }
  7972. return this.compileIndex(stringIndex);
  7973. },
  7974. compileGlobalSubrIndex: function CFFCompiler_compileGlobalSubrIndex() {
  7975. var globalSubrIndex = this.cff.globalSubrIndex;
  7976. this.out.writeByteArray(this.compileIndex(globalSubrIndex));
  7977. },
  7978. compileCharStrings: function CFFCompiler_compileCharStrings(charStrings) {
  7979. return this.compileIndex(charStrings);
  7980. },
  7981. compileCharset: function CFFCompiler_compileCharset(charset) {
  7982. return this.compileTypedArray(charset.raw);
  7983. },
  7984. compileEncoding: function CFFCompiler_compileEncoding(encoding) {
  7985. return this.compileTypedArray(encoding.raw);
  7986. },
  7987. compileFDSelect: function CFFCompiler_compileFDSelect(fdSelect) {
  7988. return this.compileTypedArray(fdSelect);
  7989. },
  7990. compileTypedArray: function CFFCompiler_compileTypedArray(data) {
  7991. var out = [];
  7992. for (var i = 0, ii = data.length; i < ii; ++i) {
  7993. out[i] = data[i];
  7994. }
  7995. return out;
  7996. },
  7997. compileIndex: function CFFCompiler_compileIndex(index, trackers) {
  7998. trackers = trackers || [];
  7999. var objects = index.objects;
  8000. var count = objects.length;
  8001. if (count === 0) {
  8002. return [
  8003. 0,
  8004. 0,
  8005. 0
  8006. ];
  8007. }
  8008. var data = [
  8009. count >> 8 & 0xFF,
  8010. count & 0xff
  8011. ];
  8012. var lastOffset = 1, i;
  8013. for (i = 0; i < count; ++i) {
  8014. lastOffset += objects[i].length;
  8015. }
  8016. var offsetSize;
  8017. if (lastOffset < 0x100) {
  8018. offsetSize = 1;
  8019. } else if (lastOffset < 0x10000) {
  8020. offsetSize = 2;
  8021. } else if (lastOffset < 0x1000000) {
  8022. offsetSize = 3;
  8023. } else {
  8024. offsetSize = 4;
  8025. }
  8026. data.push(offsetSize);
  8027. var relativeOffset = 1;
  8028. for (i = 0; i < count + 1; i++) {
  8029. if (offsetSize === 1) {
  8030. data.push(relativeOffset & 0xFF);
  8031. } else if (offsetSize === 2) {
  8032. data.push(relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8033. } else if (offsetSize === 3) {
  8034. data.push(relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8035. } else {
  8036. data.push(relativeOffset >>> 24 & 0xFF, relativeOffset >> 16 & 0xFF, relativeOffset >> 8 & 0xFF, relativeOffset & 0xFF);
  8037. }
  8038. if (objects[i]) {
  8039. relativeOffset += objects[i].length;
  8040. }
  8041. }
  8042. for (i = 0; i < count; i++) {
  8043. if (trackers[i]) {
  8044. trackers[i].offset(data.length);
  8045. }
  8046. for (var j = 0, jj = objects[i].length; j < jj; j++) {
  8047. data.push(objects[i][j]);
  8048. }
  8049. }
  8050. return data;
  8051. }
  8052. };
  8053. return CFFCompiler;
  8054. }();
  8055. exports.CFFStandardStrings = CFFStandardStrings;
  8056. exports.CFFParser = CFFParser;
  8057. exports.CFF = CFF;
  8058. exports.CFFHeader = CFFHeader;
  8059. exports.CFFStrings = CFFStrings;
  8060. exports.CFFIndex = CFFIndex;
  8061. exports.CFFCharset = CFFCharset;
  8062. exports.CFFTopDict = CFFTopDict;
  8063. exports.CFFPrivateDict = CFFPrivateDict;
  8064. exports.CFFCompiler = CFFCompiler;
  8065. }));
  8066. (function (root, factory) {
  8067. factory(root.pdfjsCoreChunkedStream = {}, root.pdfjsSharedUtil);
  8068. }(this, function (exports, sharedUtil) {
  8069. var MissingDataException = sharedUtil.MissingDataException;
  8070. var arrayByteLength = sharedUtil.arrayByteLength;
  8071. var arraysToBytes = sharedUtil.arraysToBytes;
  8072. var assert = sharedUtil.assert;
  8073. var createPromiseCapability = sharedUtil.createPromiseCapability;
  8074. var isInt = sharedUtil.isInt;
  8075. var isEmptyObj = sharedUtil.isEmptyObj;
  8076. var ChunkedStream = function ChunkedStreamClosure() {
  8077. function ChunkedStream(length, chunkSize, manager) {
  8078. this.bytes = new Uint8Array(length);
  8079. this.start = 0;
  8080. this.pos = 0;
  8081. this.end = length;
  8082. this.chunkSize = chunkSize;
  8083. this.loadedChunks = [];
  8084. this.numChunksLoaded = 0;
  8085. this.numChunks = Math.ceil(length / chunkSize);
  8086. this.manager = manager;
  8087. this.progressiveDataLength = 0;
  8088. this.lastSuccessfulEnsureByteChunk = -1;
  8089. }
  8090. ChunkedStream.prototype = {
  8091. getMissingChunks: function ChunkedStream_getMissingChunks() {
  8092. var chunks = [];
  8093. for (var chunk = 0, n = this.numChunks; chunk < n; ++chunk) {
  8094. if (!this.loadedChunks[chunk]) {
  8095. chunks.push(chunk);
  8096. }
  8097. }
  8098. return chunks;
  8099. },
  8100. getBaseStreams: function ChunkedStream_getBaseStreams() {
  8101. return [this];
  8102. },
  8103. allChunksLoaded: function ChunkedStream_allChunksLoaded() {
  8104. return this.numChunksLoaded === this.numChunks;
  8105. },
  8106. onReceiveData: function ChunkedStream_onReceiveData(begin, chunk) {
  8107. var end = begin + chunk.byteLength;
  8108. assert(begin % this.chunkSize === 0, 'Bad begin offset: ' + begin);
  8109. var length = this.bytes.length;
  8110. assert(end % this.chunkSize === 0 || end === length, 'Bad end offset: ' + end);
  8111. this.bytes.set(new Uint8Array(chunk), begin);
  8112. var chunkSize = this.chunkSize;
  8113. var beginChunk = Math.floor(begin / chunkSize);
  8114. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8115. var curChunk;
  8116. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8117. if (!this.loadedChunks[curChunk]) {
  8118. this.loadedChunks[curChunk] = true;
  8119. ++this.numChunksLoaded;
  8120. }
  8121. }
  8122. },
  8123. onReceiveProgressiveData: function ChunkedStream_onReceiveProgressiveData(data) {
  8124. var position = this.progressiveDataLength;
  8125. var beginChunk = Math.floor(position / this.chunkSize);
  8126. this.bytes.set(new Uint8Array(data), position);
  8127. position += data.byteLength;
  8128. this.progressiveDataLength = position;
  8129. var endChunk = position >= this.end ? this.numChunks : Math.floor(position / this.chunkSize);
  8130. var curChunk;
  8131. for (curChunk = beginChunk; curChunk < endChunk; ++curChunk) {
  8132. if (!this.loadedChunks[curChunk]) {
  8133. this.loadedChunks[curChunk] = true;
  8134. ++this.numChunksLoaded;
  8135. }
  8136. }
  8137. },
  8138. ensureByte: function ChunkedStream_ensureByte(pos) {
  8139. var chunk = Math.floor(pos / this.chunkSize);
  8140. if (chunk === this.lastSuccessfulEnsureByteChunk) {
  8141. return;
  8142. }
  8143. if (!this.loadedChunks[chunk]) {
  8144. throw new MissingDataException(pos, pos + 1);
  8145. }
  8146. this.lastSuccessfulEnsureByteChunk = chunk;
  8147. },
  8148. ensureRange: function ChunkedStream_ensureRange(begin, end) {
  8149. if (begin >= end) {
  8150. return;
  8151. }
  8152. if (end <= this.progressiveDataLength) {
  8153. return;
  8154. }
  8155. var chunkSize = this.chunkSize;
  8156. var beginChunk = Math.floor(begin / chunkSize);
  8157. var endChunk = Math.floor((end - 1) / chunkSize) + 1;
  8158. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8159. if (!this.loadedChunks[chunk]) {
  8160. throw new MissingDataException(begin, end);
  8161. }
  8162. }
  8163. },
  8164. nextEmptyChunk: function ChunkedStream_nextEmptyChunk(beginChunk) {
  8165. var chunk, numChunks = this.numChunks;
  8166. for (var i = 0; i < numChunks; ++i) {
  8167. chunk = (beginChunk + i) % numChunks;
  8168. if (!this.loadedChunks[chunk]) {
  8169. return chunk;
  8170. }
  8171. }
  8172. return null;
  8173. },
  8174. hasChunk: function ChunkedStream_hasChunk(chunk) {
  8175. return !!this.loadedChunks[chunk];
  8176. },
  8177. get length() {
  8178. return this.end - this.start;
  8179. },
  8180. get isEmpty() {
  8181. return this.length === 0;
  8182. },
  8183. getByte: function ChunkedStream_getByte() {
  8184. var pos = this.pos;
  8185. if (pos >= this.end) {
  8186. return -1;
  8187. }
  8188. this.ensureByte(pos);
  8189. return this.bytes[this.pos++];
  8190. },
  8191. getUint16: function ChunkedStream_getUint16() {
  8192. var b0 = this.getByte();
  8193. var b1 = this.getByte();
  8194. if (b0 === -1 || b1 === -1) {
  8195. return -1;
  8196. }
  8197. return (b0 << 8) + b1;
  8198. },
  8199. getInt32: function ChunkedStream_getInt32() {
  8200. var b0 = this.getByte();
  8201. var b1 = this.getByte();
  8202. var b2 = this.getByte();
  8203. var b3 = this.getByte();
  8204. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  8205. },
  8206. getBytes: function ChunkedStream_getBytes(length) {
  8207. var bytes = this.bytes;
  8208. var pos = this.pos;
  8209. var strEnd = this.end;
  8210. if (!length) {
  8211. this.ensureRange(pos, strEnd);
  8212. return bytes.subarray(pos, strEnd);
  8213. }
  8214. var end = pos + length;
  8215. if (end > strEnd) {
  8216. end = strEnd;
  8217. }
  8218. this.ensureRange(pos, end);
  8219. this.pos = end;
  8220. return bytes.subarray(pos, end);
  8221. },
  8222. peekByte: function ChunkedStream_peekByte() {
  8223. var peekedByte = this.getByte();
  8224. this.pos--;
  8225. return peekedByte;
  8226. },
  8227. peekBytes: function ChunkedStream_peekBytes(length) {
  8228. var bytes = this.getBytes(length);
  8229. this.pos -= bytes.length;
  8230. return bytes;
  8231. },
  8232. getByteRange: function ChunkedStream_getBytes(begin, end) {
  8233. this.ensureRange(begin, end);
  8234. return this.bytes.subarray(begin, end);
  8235. },
  8236. skip: function ChunkedStream_skip(n) {
  8237. if (!n) {
  8238. n = 1;
  8239. }
  8240. this.pos += n;
  8241. },
  8242. reset: function ChunkedStream_reset() {
  8243. this.pos = this.start;
  8244. },
  8245. moveStart: function ChunkedStream_moveStart() {
  8246. this.start = this.pos;
  8247. },
  8248. makeSubStream: function ChunkedStream_makeSubStream(start, length, dict) {
  8249. this.ensureRange(start, start + length);
  8250. function ChunkedStreamSubstream() {
  8251. }
  8252. ChunkedStreamSubstream.prototype = Object.create(this);
  8253. ChunkedStreamSubstream.prototype.getMissingChunks = function () {
  8254. var chunkSize = this.chunkSize;
  8255. var beginChunk = Math.floor(this.start / chunkSize);
  8256. var endChunk = Math.floor((this.end - 1) / chunkSize) + 1;
  8257. var missingChunks = [];
  8258. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8259. if (!this.loadedChunks[chunk]) {
  8260. missingChunks.push(chunk);
  8261. }
  8262. }
  8263. return missingChunks;
  8264. };
  8265. var subStream = new ChunkedStreamSubstream();
  8266. subStream.pos = subStream.start = start;
  8267. subStream.end = start + length || this.end;
  8268. subStream.dict = dict;
  8269. return subStream;
  8270. },
  8271. isStream: true
  8272. };
  8273. return ChunkedStream;
  8274. }();
  8275. var ChunkedStreamManager = function ChunkedStreamManagerClosure() {
  8276. function ChunkedStreamManager(pdfNetworkStream, args) {
  8277. var chunkSize = args.rangeChunkSize;
  8278. var length = args.length;
  8279. this.stream = new ChunkedStream(length, chunkSize, this);
  8280. this.length = length;
  8281. this.chunkSize = chunkSize;
  8282. this.pdfNetworkStream = pdfNetworkStream;
  8283. this.url = args.url;
  8284. this.disableAutoFetch = args.disableAutoFetch;
  8285. this.msgHandler = args.msgHandler;
  8286. this.currRequestId = 0;
  8287. this.chunksNeededByRequest = Object.create(null);
  8288. this.requestsByChunk = Object.create(null);
  8289. this.promisesByRequest = Object.create(null);
  8290. this.progressiveDataLength = 0;
  8291. this.aborted = false;
  8292. this._loadedStreamCapability = createPromiseCapability();
  8293. }
  8294. ChunkedStreamManager.prototype = {
  8295. onLoadedStream: function ChunkedStreamManager_getLoadedStream() {
  8296. return this._loadedStreamCapability.promise;
  8297. },
  8298. sendRequest: function ChunkedStreamManager_sendRequest(begin, end) {
  8299. var rangeReader = this.pdfNetworkStream.getRangeReader(begin, end);
  8300. if (!rangeReader.isStreamingSupported) {
  8301. rangeReader.onProgress = this.onProgress.bind(this);
  8302. }
  8303. var chunks = [], loaded = 0;
  8304. var manager = this;
  8305. var promise = new Promise(function (resolve, reject) {
  8306. var readChunk = function (chunk) {
  8307. try {
  8308. if (!chunk.done) {
  8309. var data = chunk.value;
  8310. chunks.push(data);
  8311. loaded += arrayByteLength(data);
  8312. if (rangeReader.isStreamingSupported) {
  8313. manager.onProgress({ loaded: loaded });
  8314. }
  8315. rangeReader.read().then(readChunk, reject);
  8316. return;
  8317. }
  8318. var chunkData = arraysToBytes(chunks);
  8319. chunks = null;
  8320. resolve(chunkData);
  8321. } catch (e) {
  8322. reject(e);
  8323. }
  8324. };
  8325. rangeReader.read().then(readChunk, reject);
  8326. });
  8327. promise.then(function (data) {
  8328. if (this.aborted) {
  8329. return;
  8330. }
  8331. this.onReceiveData({
  8332. chunk: data,
  8333. begin: begin
  8334. });
  8335. }.bind(this));
  8336. },
  8337. requestAllChunks: function ChunkedStreamManager_requestAllChunks() {
  8338. var missingChunks = this.stream.getMissingChunks();
  8339. this._requestChunks(missingChunks);
  8340. return this._loadedStreamCapability.promise;
  8341. },
  8342. _requestChunks: function ChunkedStreamManager_requestChunks(chunks) {
  8343. var requestId = this.currRequestId++;
  8344. var i, ii;
  8345. var chunksNeeded = Object.create(null);
  8346. this.chunksNeededByRequest[requestId] = chunksNeeded;
  8347. for (i = 0, ii = chunks.length; i < ii; i++) {
  8348. if (!this.stream.hasChunk(chunks[i])) {
  8349. chunksNeeded[chunks[i]] = true;
  8350. }
  8351. }
  8352. if (isEmptyObj(chunksNeeded)) {
  8353. return Promise.resolve();
  8354. }
  8355. var capability = createPromiseCapability();
  8356. this.promisesByRequest[requestId] = capability;
  8357. var chunksToRequest = [];
  8358. for (var chunk in chunksNeeded) {
  8359. chunk = chunk | 0;
  8360. if (!(chunk in this.requestsByChunk)) {
  8361. this.requestsByChunk[chunk] = [];
  8362. chunksToRequest.push(chunk);
  8363. }
  8364. this.requestsByChunk[chunk].push(requestId);
  8365. }
  8366. if (!chunksToRequest.length) {
  8367. return capability.promise;
  8368. }
  8369. var groupedChunksToRequest = this.groupChunks(chunksToRequest);
  8370. for (i = 0; i < groupedChunksToRequest.length; ++i) {
  8371. var groupedChunk = groupedChunksToRequest[i];
  8372. var begin = groupedChunk.beginChunk * this.chunkSize;
  8373. var end = Math.min(groupedChunk.endChunk * this.chunkSize, this.length);
  8374. this.sendRequest(begin, end);
  8375. }
  8376. return capability.promise;
  8377. },
  8378. getStream: function ChunkedStreamManager_getStream() {
  8379. return this.stream;
  8380. },
  8381. requestRange: function ChunkedStreamManager_requestRange(begin, end) {
  8382. end = Math.min(end, this.length);
  8383. var beginChunk = this.getBeginChunk(begin);
  8384. var endChunk = this.getEndChunk(end);
  8385. var chunks = [];
  8386. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8387. chunks.push(chunk);
  8388. }
  8389. return this._requestChunks(chunks);
  8390. },
  8391. requestRanges: function ChunkedStreamManager_requestRanges(ranges) {
  8392. ranges = ranges || [];
  8393. var chunksToRequest = [];
  8394. for (var i = 0; i < ranges.length; i++) {
  8395. var beginChunk = this.getBeginChunk(ranges[i].begin);
  8396. var endChunk = this.getEndChunk(ranges[i].end);
  8397. for (var chunk = beginChunk; chunk < endChunk; ++chunk) {
  8398. if (chunksToRequest.indexOf(chunk) < 0) {
  8399. chunksToRequest.push(chunk);
  8400. }
  8401. }
  8402. }
  8403. chunksToRequest.sort(function (a, b) {
  8404. return a - b;
  8405. });
  8406. return this._requestChunks(chunksToRequest);
  8407. },
  8408. groupChunks: function ChunkedStreamManager_groupChunks(chunks) {
  8409. var groupedChunks = [];
  8410. var beginChunk = -1;
  8411. var prevChunk = -1;
  8412. for (var i = 0; i < chunks.length; ++i) {
  8413. var chunk = chunks[i];
  8414. if (beginChunk < 0) {
  8415. beginChunk = chunk;
  8416. }
  8417. if (prevChunk >= 0 && prevChunk + 1 !== chunk) {
  8418. groupedChunks.push({
  8419. beginChunk: beginChunk,
  8420. endChunk: prevChunk + 1
  8421. });
  8422. beginChunk = chunk;
  8423. }
  8424. if (i + 1 === chunks.length) {
  8425. groupedChunks.push({
  8426. beginChunk: beginChunk,
  8427. endChunk: chunk + 1
  8428. });
  8429. }
  8430. prevChunk = chunk;
  8431. }
  8432. return groupedChunks;
  8433. },
  8434. onProgress: function ChunkedStreamManager_onProgress(args) {
  8435. var bytesLoaded = this.stream.numChunksLoaded * this.chunkSize + args.loaded;
  8436. this.msgHandler.send('DocProgress', {
  8437. loaded: bytesLoaded,
  8438. total: this.length
  8439. });
  8440. },
  8441. onReceiveData: function ChunkedStreamManager_onReceiveData(args) {
  8442. var chunk = args.chunk;
  8443. var isProgressive = args.begin === undefined;
  8444. var begin = isProgressive ? this.progressiveDataLength : args.begin;
  8445. var end = begin + chunk.byteLength;
  8446. var beginChunk = Math.floor(begin / this.chunkSize);
  8447. var endChunk = end < this.length ? Math.floor(end / this.chunkSize) : Math.ceil(end / this.chunkSize);
  8448. if (isProgressive) {
  8449. this.stream.onReceiveProgressiveData(chunk);
  8450. this.progressiveDataLength = end;
  8451. } else {
  8452. this.stream.onReceiveData(begin, chunk);
  8453. }
  8454. if (this.stream.allChunksLoaded()) {
  8455. this._loadedStreamCapability.resolve(this.stream);
  8456. }
  8457. var loadedRequests = [];
  8458. var i, requestId;
  8459. for (chunk = beginChunk; chunk < endChunk; ++chunk) {
  8460. var requestIds = this.requestsByChunk[chunk] || [];
  8461. delete this.requestsByChunk[chunk];
  8462. for (i = 0; i < requestIds.length; ++i) {
  8463. requestId = requestIds[i];
  8464. var chunksNeeded = this.chunksNeededByRequest[requestId];
  8465. if (chunk in chunksNeeded) {
  8466. delete chunksNeeded[chunk];
  8467. }
  8468. if (!isEmptyObj(chunksNeeded)) {
  8469. continue;
  8470. }
  8471. loadedRequests.push(requestId);
  8472. }
  8473. }
  8474. if (!this.disableAutoFetch && isEmptyObj(this.requestsByChunk)) {
  8475. var nextEmptyChunk;
  8476. if (this.stream.numChunksLoaded === 1) {
  8477. var lastChunk = this.stream.numChunks - 1;
  8478. if (!this.stream.hasChunk(lastChunk)) {
  8479. nextEmptyChunk = lastChunk;
  8480. }
  8481. } else {
  8482. nextEmptyChunk = this.stream.nextEmptyChunk(endChunk);
  8483. }
  8484. if (isInt(nextEmptyChunk)) {
  8485. this._requestChunks([nextEmptyChunk]);
  8486. }
  8487. }
  8488. for (i = 0; i < loadedRequests.length; ++i) {
  8489. requestId = loadedRequests[i];
  8490. var capability = this.promisesByRequest[requestId];
  8491. delete this.promisesByRequest[requestId];
  8492. capability.resolve();
  8493. }
  8494. this.msgHandler.send('DocProgress', {
  8495. loaded: this.stream.numChunksLoaded * this.chunkSize,
  8496. total: this.length
  8497. });
  8498. },
  8499. onError: function ChunkedStreamManager_onError(err) {
  8500. this._loadedStreamCapability.reject(err);
  8501. },
  8502. getBeginChunk: function ChunkedStreamManager_getBeginChunk(begin) {
  8503. var chunk = Math.floor(begin / this.chunkSize);
  8504. return chunk;
  8505. },
  8506. getEndChunk: function ChunkedStreamManager_getEndChunk(end) {
  8507. var chunk = Math.floor((end - 1) / this.chunkSize) + 1;
  8508. return chunk;
  8509. },
  8510. abort: function ChunkedStreamManager_abort() {
  8511. this.aborted = true;
  8512. if (this.pdfNetworkStream) {
  8513. this.pdfNetworkStream.cancelAllRequests('abort');
  8514. }
  8515. for (var requestId in this.promisesByRequest) {
  8516. var capability = this.promisesByRequest[requestId];
  8517. capability.reject(new Error('Request was aborted'));
  8518. }
  8519. }
  8520. };
  8521. return ChunkedStreamManager;
  8522. }();
  8523. exports.ChunkedStream = ChunkedStream;
  8524. exports.ChunkedStreamManager = ChunkedStreamManager;
  8525. }));
  8526. (function (root, factory) {
  8527. factory(root.pdfjsCoreGlyphList = {}, root.pdfjsSharedUtil);
  8528. }(this, function (exports, sharedUtil) {
  8529. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  8530. var getGlyphsUnicode = getLookupTableFactory(function (t) {
  8531. t['A'] = 0x0041;
  8532. t['AE'] = 0x00C6;
  8533. t['AEacute'] = 0x01FC;
  8534. t['AEmacron'] = 0x01E2;
  8535. t['AEsmall'] = 0xF7E6;
  8536. t['Aacute'] = 0x00C1;
  8537. t['Aacutesmall'] = 0xF7E1;
  8538. t['Abreve'] = 0x0102;
  8539. t['Abreveacute'] = 0x1EAE;
  8540. t['Abrevecyrillic'] = 0x04D0;
  8541. t['Abrevedotbelow'] = 0x1EB6;
  8542. t['Abrevegrave'] = 0x1EB0;
  8543. t['Abrevehookabove'] = 0x1EB2;
  8544. t['Abrevetilde'] = 0x1EB4;
  8545. t['Acaron'] = 0x01CD;
  8546. t['Acircle'] = 0x24B6;
  8547. t['Acircumflex'] = 0x00C2;
  8548. t['Acircumflexacute'] = 0x1EA4;
  8549. t['Acircumflexdotbelow'] = 0x1EAC;
  8550. t['Acircumflexgrave'] = 0x1EA6;
  8551. t['Acircumflexhookabove'] = 0x1EA8;
  8552. t['Acircumflexsmall'] = 0xF7E2;
  8553. t['Acircumflextilde'] = 0x1EAA;
  8554. t['Acute'] = 0xF6C9;
  8555. t['Acutesmall'] = 0xF7B4;
  8556. t['Acyrillic'] = 0x0410;
  8557. t['Adblgrave'] = 0x0200;
  8558. t['Adieresis'] = 0x00C4;
  8559. t['Adieresiscyrillic'] = 0x04D2;
  8560. t['Adieresismacron'] = 0x01DE;
  8561. t['Adieresissmall'] = 0xF7E4;
  8562. t['Adotbelow'] = 0x1EA0;
  8563. t['Adotmacron'] = 0x01E0;
  8564. t['Agrave'] = 0x00C0;
  8565. t['Agravesmall'] = 0xF7E0;
  8566. t['Ahookabove'] = 0x1EA2;
  8567. t['Aiecyrillic'] = 0x04D4;
  8568. t['Ainvertedbreve'] = 0x0202;
  8569. t['Alpha'] = 0x0391;
  8570. t['Alphatonos'] = 0x0386;
  8571. t['Amacron'] = 0x0100;
  8572. t['Amonospace'] = 0xFF21;
  8573. t['Aogonek'] = 0x0104;
  8574. t['Aring'] = 0x00C5;
  8575. t['Aringacute'] = 0x01FA;
  8576. t['Aringbelow'] = 0x1E00;
  8577. t['Aringsmall'] = 0xF7E5;
  8578. t['Asmall'] = 0xF761;
  8579. t['Atilde'] = 0x00C3;
  8580. t['Atildesmall'] = 0xF7E3;
  8581. t['Aybarmenian'] = 0x0531;
  8582. t['B'] = 0x0042;
  8583. t['Bcircle'] = 0x24B7;
  8584. t['Bdotaccent'] = 0x1E02;
  8585. t['Bdotbelow'] = 0x1E04;
  8586. t['Becyrillic'] = 0x0411;
  8587. t['Benarmenian'] = 0x0532;
  8588. t['Beta'] = 0x0392;
  8589. t['Bhook'] = 0x0181;
  8590. t['Blinebelow'] = 0x1E06;
  8591. t['Bmonospace'] = 0xFF22;
  8592. t['Brevesmall'] = 0xF6F4;
  8593. t['Bsmall'] = 0xF762;
  8594. t['Btopbar'] = 0x0182;
  8595. t['C'] = 0x0043;
  8596. t['Caarmenian'] = 0x053E;
  8597. t['Cacute'] = 0x0106;
  8598. t['Caron'] = 0xF6CA;
  8599. t['Caronsmall'] = 0xF6F5;
  8600. t['Ccaron'] = 0x010C;
  8601. t['Ccedilla'] = 0x00C7;
  8602. t['Ccedillaacute'] = 0x1E08;
  8603. t['Ccedillasmall'] = 0xF7E7;
  8604. t['Ccircle'] = 0x24B8;
  8605. t['Ccircumflex'] = 0x0108;
  8606. t['Cdot'] = 0x010A;
  8607. t['Cdotaccent'] = 0x010A;
  8608. t['Cedillasmall'] = 0xF7B8;
  8609. t['Chaarmenian'] = 0x0549;
  8610. t['Cheabkhasiancyrillic'] = 0x04BC;
  8611. t['Checyrillic'] = 0x0427;
  8612. t['Chedescenderabkhasiancyrillic'] = 0x04BE;
  8613. t['Chedescendercyrillic'] = 0x04B6;
  8614. t['Chedieresiscyrillic'] = 0x04F4;
  8615. t['Cheharmenian'] = 0x0543;
  8616. t['Chekhakassiancyrillic'] = 0x04CB;
  8617. t['Cheverticalstrokecyrillic'] = 0x04B8;
  8618. t['Chi'] = 0x03A7;
  8619. t['Chook'] = 0x0187;
  8620. t['Circumflexsmall'] = 0xF6F6;
  8621. t['Cmonospace'] = 0xFF23;
  8622. t['Coarmenian'] = 0x0551;
  8623. t['Csmall'] = 0xF763;
  8624. t['D'] = 0x0044;
  8625. t['DZ'] = 0x01F1;
  8626. t['DZcaron'] = 0x01C4;
  8627. t['Daarmenian'] = 0x0534;
  8628. t['Dafrican'] = 0x0189;
  8629. t['Dcaron'] = 0x010E;
  8630. t['Dcedilla'] = 0x1E10;
  8631. t['Dcircle'] = 0x24B9;
  8632. t['Dcircumflexbelow'] = 0x1E12;
  8633. t['Dcroat'] = 0x0110;
  8634. t['Ddotaccent'] = 0x1E0A;
  8635. t['Ddotbelow'] = 0x1E0C;
  8636. t['Decyrillic'] = 0x0414;
  8637. t['Deicoptic'] = 0x03EE;
  8638. t['Delta'] = 0x2206;
  8639. t['Deltagreek'] = 0x0394;
  8640. t['Dhook'] = 0x018A;
  8641. t['Dieresis'] = 0xF6CB;
  8642. t['DieresisAcute'] = 0xF6CC;
  8643. t['DieresisGrave'] = 0xF6CD;
  8644. t['Dieresissmall'] = 0xF7A8;
  8645. t['Digammagreek'] = 0x03DC;
  8646. t['Djecyrillic'] = 0x0402;
  8647. t['Dlinebelow'] = 0x1E0E;
  8648. t['Dmonospace'] = 0xFF24;
  8649. t['Dotaccentsmall'] = 0xF6F7;
  8650. t['Dslash'] = 0x0110;
  8651. t['Dsmall'] = 0xF764;
  8652. t['Dtopbar'] = 0x018B;
  8653. t['Dz'] = 0x01F2;
  8654. t['Dzcaron'] = 0x01C5;
  8655. t['Dzeabkhasiancyrillic'] = 0x04E0;
  8656. t['Dzecyrillic'] = 0x0405;
  8657. t['Dzhecyrillic'] = 0x040F;
  8658. t['E'] = 0x0045;
  8659. t['Eacute'] = 0x00C9;
  8660. t['Eacutesmall'] = 0xF7E9;
  8661. t['Ebreve'] = 0x0114;
  8662. t['Ecaron'] = 0x011A;
  8663. t['Ecedillabreve'] = 0x1E1C;
  8664. t['Echarmenian'] = 0x0535;
  8665. t['Ecircle'] = 0x24BA;
  8666. t['Ecircumflex'] = 0x00CA;
  8667. t['Ecircumflexacute'] = 0x1EBE;
  8668. t['Ecircumflexbelow'] = 0x1E18;
  8669. t['Ecircumflexdotbelow'] = 0x1EC6;
  8670. t['Ecircumflexgrave'] = 0x1EC0;
  8671. t['Ecircumflexhookabove'] = 0x1EC2;
  8672. t['Ecircumflexsmall'] = 0xF7EA;
  8673. t['Ecircumflextilde'] = 0x1EC4;
  8674. t['Ecyrillic'] = 0x0404;
  8675. t['Edblgrave'] = 0x0204;
  8676. t['Edieresis'] = 0x00CB;
  8677. t['Edieresissmall'] = 0xF7EB;
  8678. t['Edot'] = 0x0116;
  8679. t['Edotaccent'] = 0x0116;
  8680. t['Edotbelow'] = 0x1EB8;
  8681. t['Efcyrillic'] = 0x0424;
  8682. t['Egrave'] = 0x00C8;
  8683. t['Egravesmall'] = 0xF7E8;
  8684. t['Eharmenian'] = 0x0537;
  8685. t['Ehookabove'] = 0x1EBA;
  8686. t['Eightroman'] = 0x2167;
  8687. t['Einvertedbreve'] = 0x0206;
  8688. t['Eiotifiedcyrillic'] = 0x0464;
  8689. t['Elcyrillic'] = 0x041B;
  8690. t['Elevenroman'] = 0x216A;
  8691. t['Emacron'] = 0x0112;
  8692. t['Emacronacute'] = 0x1E16;
  8693. t['Emacrongrave'] = 0x1E14;
  8694. t['Emcyrillic'] = 0x041C;
  8695. t['Emonospace'] = 0xFF25;
  8696. t['Encyrillic'] = 0x041D;
  8697. t['Endescendercyrillic'] = 0x04A2;
  8698. t['Eng'] = 0x014A;
  8699. t['Enghecyrillic'] = 0x04A4;
  8700. t['Enhookcyrillic'] = 0x04C7;
  8701. t['Eogonek'] = 0x0118;
  8702. t['Eopen'] = 0x0190;
  8703. t['Epsilon'] = 0x0395;
  8704. t['Epsilontonos'] = 0x0388;
  8705. t['Ercyrillic'] = 0x0420;
  8706. t['Ereversed'] = 0x018E;
  8707. t['Ereversedcyrillic'] = 0x042D;
  8708. t['Escyrillic'] = 0x0421;
  8709. t['Esdescendercyrillic'] = 0x04AA;
  8710. t['Esh'] = 0x01A9;
  8711. t['Esmall'] = 0xF765;
  8712. t['Eta'] = 0x0397;
  8713. t['Etarmenian'] = 0x0538;
  8714. t['Etatonos'] = 0x0389;
  8715. t['Eth'] = 0x00D0;
  8716. t['Ethsmall'] = 0xF7F0;
  8717. t['Etilde'] = 0x1EBC;
  8718. t['Etildebelow'] = 0x1E1A;
  8719. t['Euro'] = 0x20AC;
  8720. t['Ezh'] = 0x01B7;
  8721. t['Ezhcaron'] = 0x01EE;
  8722. t['Ezhreversed'] = 0x01B8;
  8723. t['F'] = 0x0046;
  8724. t['Fcircle'] = 0x24BB;
  8725. t['Fdotaccent'] = 0x1E1E;
  8726. t['Feharmenian'] = 0x0556;
  8727. t['Feicoptic'] = 0x03E4;
  8728. t['Fhook'] = 0x0191;
  8729. t['Fitacyrillic'] = 0x0472;
  8730. t['Fiveroman'] = 0x2164;
  8731. t['Fmonospace'] = 0xFF26;
  8732. t['Fourroman'] = 0x2163;
  8733. t['Fsmall'] = 0xF766;
  8734. t['G'] = 0x0047;
  8735. t['GBsquare'] = 0x3387;
  8736. t['Gacute'] = 0x01F4;
  8737. t['Gamma'] = 0x0393;
  8738. t['Gammaafrican'] = 0x0194;
  8739. t['Gangiacoptic'] = 0x03EA;
  8740. t['Gbreve'] = 0x011E;
  8741. t['Gcaron'] = 0x01E6;
  8742. t['Gcedilla'] = 0x0122;
  8743. t['Gcircle'] = 0x24BC;
  8744. t['Gcircumflex'] = 0x011C;
  8745. t['Gcommaaccent'] = 0x0122;
  8746. t['Gdot'] = 0x0120;
  8747. t['Gdotaccent'] = 0x0120;
  8748. t['Gecyrillic'] = 0x0413;
  8749. t['Ghadarmenian'] = 0x0542;
  8750. t['Ghemiddlehookcyrillic'] = 0x0494;
  8751. t['Ghestrokecyrillic'] = 0x0492;
  8752. t['Gheupturncyrillic'] = 0x0490;
  8753. t['Ghook'] = 0x0193;
  8754. t['Gimarmenian'] = 0x0533;
  8755. t['Gjecyrillic'] = 0x0403;
  8756. t['Gmacron'] = 0x1E20;
  8757. t['Gmonospace'] = 0xFF27;
  8758. t['Grave'] = 0xF6CE;
  8759. t['Gravesmall'] = 0xF760;
  8760. t['Gsmall'] = 0xF767;
  8761. t['Gsmallhook'] = 0x029B;
  8762. t['Gstroke'] = 0x01E4;
  8763. t['H'] = 0x0048;
  8764. t['H18533'] = 0x25CF;
  8765. t['H18543'] = 0x25AA;
  8766. t['H18551'] = 0x25AB;
  8767. t['H22073'] = 0x25A1;
  8768. t['HPsquare'] = 0x33CB;
  8769. t['Haabkhasiancyrillic'] = 0x04A8;
  8770. t['Hadescendercyrillic'] = 0x04B2;
  8771. t['Hardsigncyrillic'] = 0x042A;
  8772. t['Hbar'] = 0x0126;
  8773. t['Hbrevebelow'] = 0x1E2A;
  8774. t['Hcedilla'] = 0x1E28;
  8775. t['Hcircle'] = 0x24BD;
  8776. t['Hcircumflex'] = 0x0124;
  8777. t['Hdieresis'] = 0x1E26;
  8778. t['Hdotaccent'] = 0x1E22;
  8779. t['Hdotbelow'] = 0x1E24;
  8780. t['Hmonospace'] = 0xFF28;
  8781. t['Hoarmenian'] = 0x0540;
  8782. t['Horicoptic'] = 0x03E8;
  8783. t['Hsmall'] = 0xF768;
  8784. t['Hungarumlaut'] = 0xF6CF;
  8785. t['Hungarumlautsmall'] = 0xF6F8;
  8786. t['Hzsquare'] = 0x3390;
  8787. t['I'] = 0x0049;
  8788. t['IAcyrillic'] = 0x042F;
  8789. t['IJ'] = 0x0132;
  8790. t['IUcyrillic'] = 0x042E;
  8791. t['Iacute'] = 0x00CD;
  8792. t['Iacutesmall'] = 0xF7ED;
  8793. t['Ibreve'] = 0x012C;
  8794. t['Icaron'] = 0x01CF;
  8795. t['Icircle'] = 0x24BE;
  8796. t['Icircumflex'] = 0x00CE;
  8797. t['Icircumflexsmall'] = 0xF7EE;
  8798. t['Icyrillic'] = 0x0406;
  8799. t['Idblgrave'] = 0x0208;
  8800. t['Idieresis'] = 0x00CF;
  8801. t['Idieresisacute'] = 0x1E2E;
  8802. t['Idieresiscyrillic'] = 0x04E4;
  8803. t['Idieresissmall'] = 0xF7EF;
  8804. t['Idot'] = 0x0130;
  8805. t['Idotaccent'] = 0x0130;
  8806. t['Idotbelow'] = 0x1ECA;
  8807. t['Iebrevecyrillic'] = 0x04D6;
  8808. t['Iecyrillic'] = 0x0415;
  8809. t['Ifraktur'] = 0x2111;
  8810. t['Igrave'] = 0x00CC;
  8811. t['Igravesmall'] = 0xF7EC;
  8812. t['Ihookabove'] = 0x1EC8;
  8813. t['Iicyrillic'] = 0x0418;
  8814. t['Iinvertedbreve'] = 0x020A;
  8815. t['Iishortcyrillic'] = 0x0419;
  8816. t['Imacron'] = 0x012A;
  8817. t['Imacroncyrillic'] = 0x04E2;
  8818. t['Imonospace'] = 0xFF29;
  8819. t['Iniarmenian'] = 0x053B;
  8820. t['Iocyrillic'] = 0x0401;
  8821. t['Iogonek'] = 0x012E;
  8822. t['Iota'] = 0x0399;
  8823. t['Iotaafrican'] = 0x0196;
  8824. t['Iotadieresis'] = 0x03AA;
  8825. t['Iotatonos'] = 0x038A;
  8826. t['Ismall'] = 0xF769;
  8827. t['Istroke'] = 0x0197;
  8828. t['Itilde'] = 0x0128;
  8829. t['Itildebelow'] = 0x1E2C;
  8830. t['Izhitsacyrillic'] = 0x0474;
  8831. t['Izhitsadblgravecyrillic'] = 0x0476;
  8832. t['J'] = 0x004A;
  8833. t['Jaarmenian'] = 0x0541;
  8834. t['Jcircle'] = 0x24BF;
  8835. t['Jcircumflex'] = 0x0134;
  8836. t['Jecyrillic'] = 0x0408;
  8837. t['Jheharmenian'] = 0x054B;
  8838. t['Jmonospace'] = 0xFF2A;
  8839. t['Jsmall'] = 0xF76A;
  8840. t['K'] = 0x004B;
  8841. t['KBsquare'] = 0x3385;
  8842. t['KKsquare'] = 0x33CD;
  8843. t['Kabashkircyrillic'] = 0x04A0;
  8844. t['Kacute'] = 0x1E30;
  8845. t['Kacyrillic'] = 0x041A;
  8846. t['Kadescendercyrillic'] = 0x049A;
  8847. t['Kahookcyrillic'] = 0x04C3;
  8848. t['Kappa'] = 0x039A;
  8849. t['Kastrokecyrillic'] = 0x049E;
  8850. t['Kaverticalstrokecyrillic'] = 0x049C;
  8851. t['Kcaron'] = 0x01E8;
  8852. t['Kcedilla'] = 0x0136;
  8853. t['Kcircle'] = 0x24C0;
  8854. t['Kcommaaccent'] = 0x0136;
  8855. t['Kdotbelow'] = 0x1E32;
  8856. t['Keharmenian'] = 0x0554;
  8857. t['Kenarmenian'] = 0x053F;
  8858. t['Khacyrillic'] = 0x0425;
  8859. t['Kheicoptic'] = 0x03E6;
  8860. t['Khook'] = 0x0198;
  8861. t['Kjecyrillic'] = 0x040C;
  8862. t['Klinebelow'] = 0x1E34;
  8863. t['Kmonospace'] = 0xFF2B;
  8864. t['Koppacyrillic'] = 0x0480;
  8865. t['Koppagreek'] = 0x03DE;
  8866. t['Ksicyrillic'] = 0x046E;
  8867. t['Ksmall'] = 0xF76B;
  8868. t['L'] = 0x004C;
  8869. t['LJ'] = 0x01C7;
  8870. t['LL'] = 0xF6BF;
  8871. t['Lacute'] = 0x0139;
  8872. t['Lambda'] = 0x039B;
  8873. t['Lcaron'] = 0x013D;
  8874. t['Lcedilla'] = 0x013B;
  8875. t['Lcircle'] = 0x24C1;
  8876. t['Lcircumflexbelow'] = 0x1E3C;
  8877. t['Lcommaaccent'] = 0x013B;
  8878. t['Ldot'] = 0x013F;
  8879. t['Ldotaccent'] = 0x013F;
  8880. t['Ldotbelow'] = 0x1E36;
  8881. t['Ldotbelowmacron'] = 0x1E38;
  8882. t['Liwnarmenian'] = 0x053C;
  8883. t['Lj'] = 0x01C8;
  8884. t['Ljecyrillic'] = 0x0409;
  8885. t['Llinebelow'] = 0x1E3A;
  8886. t['Lmonospace'] = 0xFF2C;
  8887. t['Lslash'] = 0x0141;
  8888. t['Lslashsmall'] = 0xF6F9;
  8889. t['Lsmall'] = 0xF76C;
  8890. t['M'] = 0x004D;
  8891. t['MBsquare'] = 0x3386;
  8892. t['Macron'] = 0xF6D0;
  8893. t['Macronsmall'] = 0xF7AF;
  8894. t['Macute'] = 0x1E3E;
  8895. t['Mcircle'] = 0x24C2;
  8896. t['Mdotaccent'] = 0x1E40;
  8897. t['Mdotbelow'] = 0x1E42;
  8898. t['Menarmenian'] = 0x0544;
  8899. t['Mmonospace'] = 0xFF2D;
  8900. t['Msmall'] = 0xF76D;
  8901. t['Mturned'] = 0x019C;
  8902. t['Mu'] = 0x039C;
  8903. t['N'] = 0x004E;
  8904. t['NJ'] = 0x01CA;
  8905. t['Nacute'] = 0x0143;
  8906. t['Ncaron'] = 0x0147;
  8907. t['Ncedilla'] = 0x0145;
  8908. t['Ncircle'] = 0x24C3;
  8909. t['Ncircumflexbelow'] = 0x1E4A;
  8910. t['Ncommaaccent'] = 0x0145;
  8911. t['Ndotaccent'] = 0x1E44;
  8912. t['Ndotbelow'] = 0x1E46;
  8913. t['Nhookleft'] = 0x019D;
  8914. t['Nineroman'] = 0x2168;
  8915. t['Nj'] = 0x01CB;
  8916. t['Njecyrillic'] = 0x040A;
  8917. t['Nlinebelow'] = 0x1E48;
  8918. t['Nmonospace'] = 0xFF2E;
  8919. t['Nowarmenian'] = 0x0546;
  8920. t['Nsmall'] = 0xF76E;
  8921. t['Ntilde'] = 0x00D1;
  8922. t['Ntildesmall'] = 0xF7F1;
  8923. t['Nu'] = 0x039D;
  8924. t['O'] = 0x004F;
  8925. t['OE'] = 0x0152;
  8926. t['OEsmall'] = 0xF6FA;
  8927. t['Oacute'] = 0x00D3;
  8928. t['Oacutesmall'] = 0xF7F3;
  8929. t['Obarredcyrillic'] = 0x04E8;
  8930. t['Obarreddieresiscyrillic'] = 0x04EA;
  8931. t['Obreve'] = 0x014E;
  8932. t['Ocaron'] = 0x01D1;
  8933. t['Ocenteredtilde'] = 0x019F;
  8934. t['Ocircle'] = 0x24C4;
  8935. t['Ocircumflex'] = 0x00D4;
  8936. t['Ocircumflexacute'] = 0x1ED0;
  8937. t['Ocircumflexdotbelow'] = 0x1ED8;
  8938. t['Ocircumflexgrave'] = 0x1ED2;
  8939. t['Ocircumflexhookabove'] = 0x1ED4;
  8940. t['Ocircumflexsmall'] = 0xF7F4;
  8941. t['Ocircumflextilde'] = 0x1ED6;
  8942. t['Ocyrillic'] = 0x041E;
  8943. t['Odblacute'] = 0x0150;
  8944. t['Odblgrave'] = 0x020C;
  8945. t['Odieresis'] = 0x00D6;
  8946. t['Odieresiscyrillic'] = 0x04E6;
  8947. t['Odieresissmall'] = 0xF7F6;
  8948. t['Odotbelow'] = 0x1ECC;
  8949. t['Ogoneksmall'] = 0xF6FB;
  8950. t['Ograve'] = 0x00D2;
  8951. t['Ogravesmall'] = 0xF7F2;
  8952. t['Oharmenian'] = 0x0555;
  8953. t['Ohm'] = 0x2126;
  8954. t['Ohookabove'] = 0x1ECE;
  8955. t['Ohorn'] = 0x01A0;
  8956. t['Ohornacute'] = 0x1EDA;
  8957. t['Ohorndotbelow'] = 0x1EE2;
  8958. t['Ohorngrave'] = 0x1EDC;
  8959. t['Ohornhookabove'] = 0x1EDE;
  8960. t['Ohorntilde'] = 0x1EE0;
  8961. t['Ohungarumlaut'] = 0x0150;
  8962. t['Oi'] = 0x01A2;
  8963. t['Oinvertedbreve'] = 0x020E;
  8964. t['Omacron'] = 0x014C;
  8965. t['Omacronacute'] = 0x1E52;
  8966. t['Omacrongrave'] = 0x1E50;
  8967. t['Omega'] = 0x2126;
  8968. t['Omegacyrillic'] = 0x0460;
  8969. t['Omegagreek'] = 0x03A9;
  8970. t['Omegaroundcyrillic'] = 0x047A;
  8971. t['Omegatitlocyrillic'] = 0x047C;
  8972. t['Omegatonos'] = 0x038F;
  8973. t['Omicron'] = 0x039F;
  8974. t['Omicrontonos'] = 0x038C;
  8975. t['Omonospace'] = 0xFF2F;
  8976. t['Oneroman'] = 0x2160;
  8977. t['Oogonek'] = 0x01EA;
  8978. t['Oogonekmacron'] = 0x01EC;
  8979. t['Oopen'] = 0x0186;
  8980. t['Oslash'] = 0x00D8;
  8981. t['Oslashacute'] = 0x01FE;
  8982. t['Oslashsmall'] = 0xF7F8;
  8983. t['Osmall'] = 0xF76F;
  8984. t['Ostrokeacute'] = 0x01FE;
  8985. t['Otcyrillic'] = 0x047E;
  8986. t['Otilde'] = 0x00D5;
  8987. t['Otildeacute'] = 0x1E4C;
  8988. t['Otildedieresis'] = 0x1E4E;
  8989. t['Otildesmall'] = 0xF7F5;
  8990. t['P'] = 0x0050;
  8991. t['Pacute'] = 0x1E54;
  8992. t['Pcircle'] = 0x24C5;
  8993. t['Pdotaccent'] = 0x1E56;
  8994. t['Pecyrillic'] = 0x041F;
  8995. t['Peharmenian'] = 0x054A;
  8996. t['Pemiddlehookcyrillic'] = 0x04A6;
  8997. t['Phi'] = 0x03A6;
  8998. t['Phook'] = 0x01A4;
  8999. t['Pi'] = 0x03A0;
  9000. t['Piwrarmenian'] = 0x0553;
  9001. t['Pmonospace'] = 0xFF30;
  9002. t['Psi'] = 0x03A8;
  9003. t['Psicyrillic'] = 0x0470;
  9004. t['Psmall'] = 0xF770;
  9005. t['Q'] = 0x0051;
  9006. t['Qcircle'] = 0x24C6;
  9007. t['Qmonospace'] = 0xFF31;
  9008. t['Qsmall'] = 0xF771;
  9009. t['R'] = 0x0052;
  9010. t['Raarmenian'] = 0x054C;
  9011. t['Racute'] = 0x0154;
  9012. t['Rcaron'] = 0x0158;
  9013. t['Rcedilla'] = 0x0156;
  9014. t['Rcircle'] = 0x24C7;
  9015. t['Rcommaaccent'] = 0x0156;
  9016. t['Rdblgrave'] = 0x0210;
  9017. t['Rdotaccent'] = 0x1E58;
  9018. t['Rdotbelow'] = 0x1E5A;
  9019. t['Rdotbelowmacron'] = 0x1E5C;
  9020. t['Reharmenian'] = 0x0550;
  9021. t['Rfraktur'] = 0x211C;
  9022. t['Rho'] = 0x03A1;
  9023. t['Ringsmall'] = 0xF6FC;
  9024. t['Rinvertedbreve'] = 0x0212;
  9025. t['Rlinebelow'] = 0x1E5E;
  9026. t['Rmonospace'] = 0xFF32;
  9027. t['Rsmall'] = 0xF772;
  9028. t['Rsmallinverted'] = 0x0281;
  9029. t['Rsmallinvertedsuperior'] = 0x02B6;
  9030. t['S'] = 0x0053;
  9031. t['SF010000'] = 0x250C;
  9032. t['SF020000'] = 0x2514;
  9033. t['SF030000'] = 0x2510;
  9034. t['SF040000'] = 0x2518;
  9035. t['SF050000'] = 0x253C;
  9036. t['SF060000'] = 0x252C;
  9037. t['SF070000'] = 0x2534;
  9038. t['SF080000'] = 0x251C;
  9039. t['SF090000'] = 0x2524;
  9040. t['SF100000'] = 0x2500;
  9041. t['SF110000'] = 0x2502;
  9042. t['SF190000'] = 0x2561;
  9043. t['SF200000'] = 0x2562;
  9044. t['SF210000'] = 0x2556;
  9045. t['SF220000'] = 0x2555;
  9046. t['SF230000'] = 0x2563;
  9047. t['SF240000'] = 0x2551;
  9048. t['SF250000'] = 0x2557;
  9049. t['SF260000'] = 0x255D;
  9050. t['SF270000'] = 0x255C;
  9051. t['SF280000'] = 0x255B;
  9052. t['SF360000'] = 0x255E;
  9053. t['SF370000'] = 0x255F;
  9054. t['SF380000'] = 0x255A;
  9055. t['SF390000'] = 0x2554;
  9056. t['SF400000'] = 0x2569;
  9057. t['SF410000'] = 0x2566;
  9058. t['SF420000'] = 0x2560;
  9059. t['SF430000'] = 0x2550;
  9060. t['SF440000'] = 0x256C;
  9061. t['SF450000'] = 0x2567;
  9062. t['SF460000'] = 0x2568;
  9063. t['SF470000'] = 0x2564;
  9064. t['SF480000'] = 0x2565;
  9065. t['SF490000'] = 0x2559;
  9066. t['SF500000'] = 0x2558;
  9067. t['SF510000'] = 0x2552;
  9068. t['SF520000'] = 0x2553;
  9069. t['SF530000'] = 0x256B;
  9070. t['SF540000'] = 0x256A;
  9071. t['Sacute'] = 0x015A;
  9072. t['Sacutedotaccent'] = 0x1E64;
  9073. t['Sampigreek'] = 0x03E0;
  9074. t['Scaron'] = 0x0160;
  9075. t['Scarondotaccent'] = 0x1E66;
  9076. t['Scaronsmall'] = 0xF6FD;
  9077. t['Scedilla'] = 0x015E;
  9078. t['Schwa'] = 0x018F;
  9079. t['Schwacyrillic'] = 0x04D8;
  9080. t['Schwadieresiscyrillic'] = 0x04DA;
  9081. t['Scircle'] = 0x24C8;
  9082. t['Scircumflex'] = 0x015C;
  9083. t['Scommaaccent'] = 0x0218;
  9084. t['Sdotaccent'] = 0x1E60;
  9085. t['Sdotbelow'] = 0x1E62;
  9086. t['Sdotbelowdotaccent'] = 0x1E68;
  9087. t['Seharmenian'] = 0x054D;
  9088. t['Sevenroman'] = 0x2166;
  9089. t['Shaarmenian'] = 0x0547;
  9090. t['Shacyrillic'] = 0x0428;
  9091. t['Shchacyrillic'] = 0x0429;
  9092. t['Sheicoptic'] = 0x03E2;
  9093. t['Shhacyrillic'] = 0x04BA;
  9094. t['Shimacoptic'] = 0x03EC;
  9095. t['Sigma'] = 0x03A3;
  9096. t['Sixroman'] = 0x2165;
  9097. t['Smonospace'] = 0xFF33;
  9098. t['Softsigncyrillic'] = 0x042C;
  9099. t['Ssmall'] = 0xF773;
  9100. t['Stigmagreek'] = 0x03DA;
  9101. t['T'] = 0x0054;
  9102. t['Tau'] = 0x03A4;
  9103. t['Tbar'] = 0x0166;
  9104. t['Tcaron'] = 0x0164;
  9105. t['Tcedilla'] = 0x0162;
  9106. t['Tcircle'] = 0x24C9;
  9107. t['Tcircumflexbelow'] = 0x1E70;
  9108. t['Tcommaaccent'] = 0x0162;
  9109. t['Tdotaccent'] = 0x1E6A;
  9110. t['Tdotbelow'] = 0x1E6C;
  9111. t['Tecyrillic'] = 0x0422;
  9112. t['Tedescendercyrillic'] = 0x04AC;
  9113. t['Tenroman'] = 0x2169;
  9114. t['Tetsecyrillic'] = 0x04B4;
  9115. t['Theta'] = 0x0398;
  9116. t['Thook'] = 0x01AC;
  9117. t['Thorn'] = 0x00DE;
  9118. t['Thornsmall'] = 0xF7FE;
  9119. t['Threeroman'] = 0x2162;
  9120. t['Tildesmall'] = 0xF6FE;
  9121. t['Tiwnarmenian'] = 0x054F;
  9122. t['Tlinebelow'] = 0x1E6E;
  9123. t['Tmonospace'] = 0xFF34;
  9124. t['Toarmenian'] = 0x0539;
  9125. t['Tonefive'] = 0x01BC;
  9126. t['Tonesix'] = 0x0184;
  9127. t['Tonetwo'] = 0x01A7;
  9128. t['Tretroflexhook'] = 0x01AE;
  9129. t['Tsecyrillic'] = 0x0426;
  9130. t['Tshecyrillic'] = 0x040B;
  9131. t['Tsmall'] = 0xF774;
  9132. t['Twelveroman'] = 0x216B;
  9133. t['Tworoman'] = 0x2161;
  9134. t['U'] = 0x0055;
  9135. t['Uacute'] = 0x00DA;
  9136. t['Uacutesmall'] = 0xF7FA;
  9137. t['Ubreve'] = 0x016C;
  9138. t['Ucaron'] = 0x01D3;
  9139. t['Ucircle'] = 0x24CA;
  9140. t['Ucircumflex'] = 0x00DB;
  9141. t['Ucircumflexbelow'] = 0x1E76;
  9142. t['Ucircumflexsmall'] = 0xF7FB;
  9143. t['Ucyrillic'] = 0x0423;
  9144. t['Udblacute'] = 0x0170;
  9145. t['Udblgrave'] = 0x0214;
  9146. t['Udieresis'] = 0x00DC;
  9147. t['Udieresisacute'] = 0x01D7;
  9148. t['Udieresisbelow'] = 0x1E72;
  9149. t['Udieresiscaron'] = 0x01D9;
  9150. t['Udieresiscyrillic'] = 0x04F0;
  9151. t['Udieresisgrave'] = 0x01DB;
  9152. t['Udieresismacron'] = 0x01D5;
  9153. t['Udieresissmall'] = 0xF7FC;
  9154. t['Udotbelow'] = 0x1EE4;
  9155. t['Ugrave'] = 0x00D9;
  9156. t['Ugravesmall'] = 0xF7F9;
  9157. t['Uhookabove'] = 0x1EE6;
  9158. t['Uhorn'] = 0x01AF;
  9159. t['Uhornacute'] = 0x1EE8;
  9160. t['Uhorndotbelow'] = 0x1EF0;
  9161. t['Uhorngrave'] = 0x1EEA;
  9162. t['Uhornhookabove'] = 0x1EEC;
  9163. t['Uhorntilde'] = 0x1EEE;
  9164. t['Uhungarumlaut'] = 0x0170;
  9165. t['Uhungarumlautcyrillic'] = 0x04F2;
  9166. t['Uinvertedbreve'] = 0x0216;
  9167. t['Ukcyrillic'] = 0x0478;
  9168. t['Umacron'] = 0x016A;
  9169. t['Umacroncyrillic'] = 0x04EE;
  9170. t['Umacrondieresis'] = 0x1E7A;
  9171. t['Umonospace'] = 0xFF35;
  9172. t['Uogonek'] = 0x0172;
  9173. t['Upsilon'] = 0x03A5;
  9174. t['Upsilon1'] = 0x03D2;
  9175. t['Upsilonacutehooksymbolgreek'] = 0x03D3;
  9176. t['Upsilonafrican'] = 0x01B1;
  9177. t['Upsilondieresis'] = 0x03AB;
  9178. t['Upsilondieresishooksymbolgreek'] = 0x03D4;
  9179. t['Upsilonhooksymbol'] = 0x03D2;
  9180. t['Upsilontonos'] = 0x038E;
  9181. t['Uring'] = 0x016E;
  9182. t['Ushortcyrillic'] = 0x040E;
  9183. t['Usmall'] = 0xF775;
  9184. t['Ustraightcyrillic'] = 0x04AE;
  9185. t['Ustraightstrokecyrillic'] = 0x04B0;
  9186. t['Utilde'] = 0x0168;
  9187. t['Utildeacute'] = 0x1E78;
  9188. t['Utildebelow'] = 0x1E74;
  9189. t['V'] = 0x0056;
  9190. t['Vcircle'] = 0x24CB;
  9191. t['Vdotbelow'] = 0x1E7E;
  9192. t['Vecyrillic'] = 0x0412;
  9193. t['Vewarmenian'] = 0x054E;
  9194. t['Vhook'] = 0x01B2;
  9195. t['Vmonospace'] = 0xFF36;
  9196. t['Voarmenian'] = 0x0548;
  9197. t['Vsmall'] = 0xF776;
  9198. t['Vtilde'] = 0x1E7C;
  9199. t['W'] = 0x0057;
  9200. t['Wacute'] = 0x1E82;
  9201. t['Wcircle'] = 0x24CC;
  9202. t['Wcircumflex'] = 0x0174;
  9203. t['Wdieresis'] = 0x1E84;
  9204. t['Wdotaccent'] = 0x1E86;
  9205. t['Wdotbelow'] = 0x1E88;
  9206. t['Wgrave'] = 0x1E80;
  9207. t['Wmonospace'] = 0xFF37;
  9208. t['Wsmall'] = 0xF777;
  9209. t['X'] = 0x0058;
  9210. t['Xcircle'] = 0x24CD;
  9211. t['Xdieresis'] = 0x1E8C;
  9212. t['Xdotaccent'] = 0x1E8A;
  9213. t['Xeharmenian'] = 0x053D;
  9214. t['Xi'] = 0x039E;
  9215. t['Xmonospace'] = 0xFF38;
  9216. t['Xsmall'] = 0xF778;
  9217. t['Y'] = 0x0059;
  9218. t['Yacute'] = 0x00DD;
  9219. t['Yacutesmall'] = 0xF7FD;
  9220. t['Yatcyrillic'] = 0x0462;
  9221. t['Ycircle'] = 0x24CE;
  9222. t['Ycircumflex'] = 0x0176;
  9223. t['Ydieresis'] = 0x0178;
  9224. t['Ydieresissmall'] = 0xF7FF;
  9225. t['Ydotaccent'] = 0x1E8E;
  9226. t['Ydotbelow'] = 0x1EF4;
  9227. t['Yericyrillic'] = 0x042B;
  9228. t['Yerudieresiscyrillic'] = 0x04F8;
  9229. t['Ygrave'] = 0x1EF2;
  9230. t['Yhook'] = 0x01B3;
  9231. t['Yhookabove'] = 0x1EF6;
  9232. t['Yiarmenian'] = 0x0545;
  9233. t['Yicyrillic'] = 0x0407;
  9234. t['Yiwnarmenian'] = 0x0552;
  9235. t['Ymonospace'] = 0xFF39;
  9236. t['Ysmall'] = 0xF779;
  9237. t['Ytilde'] = 0x1EF8;
  9238. t['Yusbigcyrillic'] = 0x046A;
  9239. t['Yusbigiotifiedcyrillic'] = 0x046C;
  9240. t['Yuslittlecyrillic'] = 0x0466;
  9241. t['Yuslittleiotifiedcyrillic'] = 0x0468;
  9242. t['Z'] = 0x005A;
  9243. t['Zaarmenian'] = 0x0536;
  9244. t['Zacute'] = 0x0179;
  9245. t['Zcaron'] = 0x017D;
  9246. t['Zcaronsmall'] = 0xF6FF;
  9247. t['Zcircle'] = 0x24CF;
  9248. t['Zcircumflex'] = 0x1E90;
  9249. t['Zdot'] = 0x017B;
  9250. t['Zdotaccent'] = 0x017B;
  9251. t['Zdotbelow'] = 0x1E92;
  9252. t['Zecyrillic'] = 0x0417;
  9253. t['Zedescendercyrillic'] = 0x0498;
  9254. t['Zedieresiscyrillic'] = 0x04DE;
  9255. t['Zeta'] = 0x0396;
  9256. t['Zhearmenian'] = 0x053A;
  9257. t['Zhebrevecyrillic'] = 0x04C1;
  9258. t['Zhecyrillic'] = 0x0416;
  9259. t['Zhedescendercyrillic'] = 0x0496;
  9260. t['Zhedieresiscyrillic'] = 0x04DC;
  9261. t['Zlinebelow'] = 0x1E94;
  9262. t['Zmonospace'] = 0xFF3A;
  9263. t['Zsmall'] = 0xF77A;
  9264. t['Zstroke'] = 0x01B5;
  9265. t['a'] = 0x0061;
  9266. t['aabengali'] = 0x0986;
  9267. t['aacute'] = 0x00E1;
  9268. t['aadeva'] = 0x0906;
  9269. t['aagujarati'] = 0x0A86;
  9270. t['aagurmukhi'] = 0x0A06;
  9271. t['aamatragurmukhi'] = 0x0A3E;
  9272. t['aarusquare'] = 0x3303;
  9273. t['aavowelsignbengali'] = 0x09BE;
  9274. t['aavowelsigndeva'] = 0x093E;
  9275. t['aavowelsigngujarati'] = 0x0ABE;
  9276. t['abbreviationmarkarmenian'] = 0x055F;
  9277. t['abbreviationsigndeva'] = 0x0970;
  9278. t['abengali'] = 0x0985;
  9279. t['abopomofo'] = 0x311A;
  9280. t['abreve'] = 0x0103;
  9281. t['abreveacute'] = 0x1EAF;
  9282. t['abrevecyrillic'] = 0x04D1;
  9283. t['abrevedotbelow'] = 0x1EB7;
  9284. t['abrevegrave'] = 0x1EB1;
  9285. t['abrevehookabove'] = 0x1EB3;
  9286. t['abrevetilde'] = 0x1EB5;
  9287. t['acaron'] = 0x01CE;
  9288. t['acircle'] = 0x24D0;
  9289. t['acircumflex'] = 0x00E2;
  9290. t['acircumflexacute'] = 0x1EA5;
  9291. t['acircumflexdotbelow'] = 0x1EAD;
  9292. t['acircumflexgrave'] = 0x1EA7;
  9293. t['acircumflexhookabove'] = 0x1EA9;
  9294. t['acircumflextilde'] = 0x1EAB;
  9295. t['acute'] = 0x00B4;
  9296. t['acutebelowcmb'] = 0x0317;
  9297. t['acutecmb'] = 0x0301;
  9298. t['acutecomb'] = 0x0301;
  9299. t['acutedeva'] = 0x0954;
  9300. t['acutelowmod'] = 0x02CF;
  9301. t['acutetonecmb'] = 0x0341;
  9302. t['acyrillic'] = 0x0430;
  9303. t['adblgrave'] = 0x0201;
  9304. t['addakgurmukhi'] = 0x0A71;
  9305. t['adeva'] = 0x0905;
  9306. t['adieresis'] = 0x00E4;
  9307. t['adieresiscyrillic'] = 0x04D3;
  9308. t['adieresismacron'] = 0x01DF;
  9309. t['adotbelow'] = 0x1EA1;
  9310. t['adotmacron'] = 0x01E1;
  9311. t['ae'] = 0x00E6;
  9312. t['aeacute'] = 0x01FD;
  9313. t['aekorean'] = 0x3150;
  9314. t['aemacron'] = 0x01E3;
  9315. t['afii00208'] = 0x2015;
  9316. t['afii08941'] = 0x20A4;
  9317. t['afii10017'] = 0x0410;
  9318. t['afii10018'] = 0x0411;
  9319. t['afii10019'] = 0x0412;
  9320. t['afii10020'] = 0x0413;
  9321. t['afii10021'] = 0x0414;
  9322. t['afii10022'] = 0x0415;
  9323. t['afii10023'] = 0x0401;
  9324. t['afii10024'] = 0x0416;
  9325. t['afii10025'] = 0x0417;
  9326. t['afii10026'] = 0x0418;
  9327. t['afii10027'] = 0x0419;
  9328. t['afii10028'] = 0x041A;
  9329. t['afii10029'] = 0x041B;
  9330. t['afii10030'] = 0x041C;
  9331. t['afii10031'] = 0x041D;
  9332. t['afii10032'] = 0x041E;
  9333. t['afii10033'] = 0x041F;
  9334. t['afii10034'] = 0x0420;
  9335. t['afii10035'] = 0x0421;
  9336. t['afii10036'] = 0x0422;
  9337. t['afii10037'] = 0x0423;
  9338. t['afii10038'] = 0x0424;
  9339. t['afii10039'] = 0x0425;
  9340. t['afii10040'] = 0x0426;
  9341. t['afii10041'] = 0x0427;
  9342. t['afii10042'] = 0x0428;
  9343. t['afii10043'] = 0x0429;
  9344. t['afii10044'] = 0x042A;
  9345. t['afii10045'] = 0x042B;
  9346. t['afii10046'] = 0x042C;
  9347. t['afii10047'] = 0x042D;
  9348. t['afii10048'] = 0x042E;
  9349. t['afii10049'] = 0x042F;
  9350. t['afii10050'] = 0x0490;
  9351. t['afii10051'] = 0x0402;
  9352. t['afii10052'] = 0x0403;
  9353. t['afii10053'] = 0x0404;
  9354. t['afii10054'] = 0x0405;
  9355. t['afii10055'] = 0x0406;
  9356. t['afii10056'] = 0x0407;
  9357. t['afii10057'] = 0x0408;
  9358. t['afii10058'] = 0x0409;
  9359. t['afii10059'] = 0x040A;
  9360. t['afii10060'] = 0x040B;
  9361. t['afii10061'] = 0x040C;
  9362. t['afii10062'] = 0x040E;
  9363. t['afii10063'] = 0xF6C4;
  9364. t['afii10064'] = 0xF6C5;
  9365. t['afii10065'] = 0x0430;
  9366. t['afii10066'] = 0x0431;
  9367. t['afii10067'] = 0x0432;
  9368. t['afii10068'] = 0x0433;
  9369. t['afii10069'] = 0x0434;
  9370. t['afii10070'] = 0x0435;
  9371. t['afii10071'] = 0x0451;
  9372. t['afii10072'] = 0x0436;
  9373. t['afii10073'] = 0x0437;
  9374. t['afii10074'] = 0x0438;
  9375. t['afii10075'] = 0x0439;
  9376. t['afii10076'] = 0x043A;
  9377. t['afii10077'] = 0x043B;
  9378. t['afii10078'] = 0x043C;
  9379. t['afii10079'] = 0x043D;
  9380. t['afii10080'] = 0x043E;
  9381. t['afii10081'] = 0x043F;
  9382. t['afii10082'] = 0x0440;
  9383. t['afii10083'] = 0x0441;
  9384. t['afii10084'] = 0x0442;
  9385. t['afii10085'] = 0x0443;
  9386. t['afii10086'] = 0x0444;
  9387. t['afii10087'] = 0x0445;
  9388. t['afii10088'] = 0x0446;
  9389. t['afii10089'] = 0x0447;
  9390. t['afii10090'] = 0x0448;
  9391. t['afii10091'] = 0x0449;
  9392. t['afii10092'] = 0x044A;
  9393. t['afii10093'] = 0x044B;
  9394. t['afii10094'] = 0x044C;
  9395. t['afii10095'] = 0x044D;
  9396. t['afii10096'] = 0x044E;
  9397. t['afii10097'] = 0x044F;
  9398. t['afii10098'] = 0x0491;
  9399. t['afii10099'] = 0x0452;
  9400. t['afii10100'] = 0x0453;
  9401. t['afii10101'] = 0x0454;
  9402. t['afii10102'] = 0x0455;
  9403. t['afii10103'] = 0x0456;
  9404. t['afii10104'] = 0x0457;
  9405. t['afii10105'] = 0x0458;
  9406. t['afii10106'] = 0x0459;
  9407. t['afii10107'] = 0x045A;
  9408. t['afii10108'] = 0x045B;
  9409. t['afii10109'] = 0x045C;
  9410. t['afii10110'] = 0x045E;
  9411. t['afii10145'] = 0x040F;
  9412. t['afii10146'] = 0x0462;
  9413. t['afii10147'] = 0x0472;
  9414. t['afii10148'] = 0x0474;
  9415. t['afii10192'] = 0xF6C6;
  9416. t['afii10193'] = 0x045F;
  9417. t['afii10194'] = 0x0463;
  9418. t['afii10195'] = 0x0473;
  9419. t['afii10196'] = 0x0475;
  9420. t['afii10831'] = 0xF6C7;
  9421. t['afii10832'] = 0xF6C8;
  9422. t['afii10846'] = 0x04D9;
  9423. t['afii299'] = 0x200E;
  9424. t['afii300'] = 0x200F;
  9425. t['afii301'] = 0x200D;
  9426. t['afii57381'] = 0x066A;
  9427. t['afii57388'] = 0x060C;
  9428. t['afii57392'] = 0x0660;
  9429. t['afii57393'] = 0x0661;
  9430. t['afii57394'] = 0x0662;
  9431. t['afii57395'] = 0x0663;
  9432. t['afii57396'] = 0x0664;
  9433. t['afii57397'] = 0x0665;
  9434. t['afii57398'] = 0x0666;
  9435. t['afii57399'] = 0x0667;
  9436. t['afii57400'] = 0x0668;
  9437. t['afii57401'] = 0x0669;
  9438. t['afii57403'] = 0x061B;
  9439. t['afii57407'] = 0x061F;
  9440. t['afii57409'] = 0x0621;
  9441. t['afii57410'] = 0x0622;
  9442. t['afii57411'] = 0x0623;
  9443. t['afii57412'] = 0x0624;
  9444. t['afii57413'] = 0x0625;
  9445. t['afii57414'] = 0x0626;
  9446. t['afii57415'] = 0x0627;
  9447. t['afii57416'] = 0x0628;
  9448. t['afii57417'] = 0x0629;
  9449. t['afii57418'] = 0x062A;
  9450. t['afii57419'] = 0x062B;
  9451. t['afii57420'] = 0x062C;
  9452. t['afii57421'] = 0x062D;
  9453. t['afii57422'] = 0x062E;
  9454. t['afii57423'] = 0x062F;
  9455. t['afii57424'] = 0x0630;
  9456. t['afii57425'] = 0x0631;
  9457. t['afii57426'] = 0x0632;
  9458. t['afii57427'] = 0x0633;
  9459. t['afii57428'] = 0x0634;
  9460. t['afii57429'] = 0x0635;
  9461. t['afii57430'] = 0x0636;
  9462. t['afii57431'] = 0x0637;
  9463. t['afii57432'] = 0x0638;
  9464. t['afii57433'] = 0x0639;
  9465. t['afii57434'] = 0x063A;
  9466. t['afii57440'] = 0x0640;
  9467. t['afii57441'] = 0x0641;
  9468. t['afii57442'] = 0x0642;
  9469. t['afii57443'] = 0x0643;
  9470. t['afii57444'] = 0x0644;
  9471. t['afii57445'] = 0x0645;
  9472. t['afii57446'] = 0x0646;
  9473. t['afii57448'] = 0x0648;
  9474. t['afii57449'] = 0x0649;
  9475. t['afii57450'] = 0x064A;
  9476. t['afii57451'] = 0x064B;
  9477. t['afii57452'] = 0x064C;
  9478. t['afii57453'] = 0x064D;
  9479. t['afii57454'] = 0x064E;
  9480. t['afii57455'] = 0x064F;
  9481. t['afii57456'] = 0x0650;
  9482. t['afii57457'] = 0x0651;
  9483. t['afii57458'] = 0x0652;
  9484. t['afii57470'] = 0x0647;
  9485. t['afii57505'] = 0x06A4;
  9486. t['afii57506'] = 0x067E;
  9487. t['afii57507'] = 0x0686;
  9488. t['afii57508'] = 0x0698;
  9489. t['afii57509'] = 0x06AF;
  9490. t['afii57511'] = 0x0679;
  9491. t['afii57512'] = 0x0688;
  9492. t['afii57513'] = 0x0691;
  9493. t['afii57514'] = 0x06BA;
  9494. t['afii57519'] = 0x06D2;
  9495. t['afii57534'] = 0x06D5;
  9496. t['afii57636'] = 0x20AA;
  9497. t['afii57645'] = 0x05BE;
  9498. t['afii57658'] = 0x05C3;
  9499. t['afii57664'] = 0x05D0;
  9500. t['afii57665'] = 0x05D1;
  9501. t['afii57666'] = 0x05D2;
  9502. t['afii57667'] = 0x05D3;
  9503. t['afii57668'] = 0x05D4;
  9504. t['afii57669'] = 0x05D5;
  9505. t['afii57670'] = 0x05D6;
  9506. t['afii57671'] = 0x05D7;
  9507. t['afii57672'] = 0x05D8;
  9508. t['afii57673'] = 0x05D9;
  9509. t['afii57674'] = 0x05DA;
  9510. t['afii57675'] = 0x05DB;
  9511. t['afii57676'] = 0x05DC;
  9512. t['afii57677'] = 0x05DD;
  9513. t['afii57678'] = 0x05DE;
  9514. t['afii57679'] = 0x05DF;
  9515. t['afii57680'] = 0x05E0;
  9516. t['afii57681'] = 0x05E1;
  9517. t['afii57682'] = 0x05E2;
  9518. t['afii57683'] = 0x05E3;
  9519. t['afii57684'] = 0x05E4;
  9520. t['afii57685'] = 0x05E5;
  9521. t['afii57686'] = 0x05E6;
  9522. t['afii57687'] = 0x05E7;
  9523. t['afii57688'] = 0x05E8;
  9524. t['afii57689'] = 0x05E9;
  9525. t['afii57690'] = 0x05EA;
  9526. t['afii57694'] = 0xFB2A;
  9527. t['afii57695'] = 0xFB2B;
  9528. t['afii57700'] = 0xFB4B;
  9529. t['afii57705'] = 0xFB1F;
  9530. t['afii57716'] = 0x05F0;
  9531. t['afii57717'] = 0x05F1;
  9532. t['afii57718'] = 0x05F2;
  9533. t['afii57723'] = 0xFB35;
  9534. t['afii57793'] = 0x05B4;
  9535. t['afii57794'] = 0x05B5;
  9536. t['afii57795'] = 0x05B6;
  9537. t['afii57796'] = 0x05BB;
  9538. t['afii57797'] = 0x05B8;
  9539. t['afii57798'] = 0x05B7;
  9540. t['afii57799'] = 0x05B0;
  9541. t['afii57800'] = 0x05B2;
  9542. t['afii57801'] = 0x05B1;
  9543. t['afii57802'] = 0x05B3;
  9544. t['afii57803'] = 0x05C2;
  9545. t['afii57804'] = 0x05C1;
  9546. t['afii57806'] = 0x05B9;
  9547. t['afii57807'] = 0x05BC;
  9548. t['afii57839'] = 0x05BD;
  9549. t['afii57841'] = 0x05BF;
  9550. t['afii57842'] = 0x05C0;
  9551. t['afii57929'] = 0x02BC;
  9552. t['afii61248'] = 0x2105;
  9553. t['afii61289'] = 0x2113;
  9554. t['afii61352'] = 0x2116;
  9555. t['afii61573'] = 0x202C;
  9556. t['afii61574'] = 0x202D;
  9557. t['afii61575'] = 0x202E;
  9558. t['afii61664'] = 0x200C;
  9559. t['afii63167'] = 0x066D;
  9560. t['afii64937'] = 0x02BD;
  9561. t['agrave'] = 0x00E0;
  9562. t['agujarati'] = 0x0A85;
  9563. t['agurmukhi'] = 0x0A05;
  9564. t['ahiragana'] = 0x3042;
  9565. t['ahookabove'] = 0x1EA3;
  9566. t['aibengali'] = 0x0990;
  9567. t['aibopomofo'] = 0x311E;
  9568. t['aideva'] = 0x0910;
  9569. t['aiecyrillic'] = 0x04D5;
  9570. t['aigujarati'] = 0x0A90;
  9571. t['aigurmukhi'] = 0x0A10;
  9572. t['aimatragurmukhi'] = 0x0A48;
  9573. t['ainarabic'] = 0x0639;
  9574. t['ainfinalarabic'] = 0xFECA;
  9575. t['aininitialarabic'] = 0xFECB;
  9576. t['ainmedialarabic'] = 0xFECC;
  9577. t['ainvertedbreve'] = 0x0203;
  9578. t['aivowelsignbengali'] = 0x09C8;
  9579. t['aivowelsigndeva'] = 0x0948;
  9580. t['aivowelsigngujarati'] = 0x0AC8;
  9581. t['akatakana'] = 0x30A2;
  9582. t['akatakanahalfwidth'] = 0xFF71;
  9583. t['akorean'] = 0x314F;
  9584. t['alef'] = 0x05D0;
  9585. t['alefarabic'] = 0x0627;
  9586. t['alefdageshhebrew'] = 0xFB30;
  9587. t['aleffinalarabic'] = 0xFE8E;
  9588. t['alefhamzaabovearabic'] = 0x0623;
  9589. t['alefhamzaabovefinalarabic'] = 0xFE84;
  9590. t['alefhamzabelowarabic'] = 0x0625;
  9591. t['alefhamzabelowfinalarabic'] = 0xFE88;
  9592. t['alefhebrew'] = 0x05D0;
  9593. t['aleflamedhebrew'] = 0xFB4F;
  9594. t['alefmaddaabovearabic'] = 0x0622;
  9595. t['alefmaddaabovefinalarabic'] = 0xFE82;
  9596. t['alefmaksuraarabic'] = 0x0649;
  9597. t['alefmaksurafinalarabic'] = 0xFEF0;
  9598. t['alefmaksurainitialarabic'] = 0xFEF3;
  9599. t['alefmaksuramedialarabic'] = 0xFEF4;
  9600. t['alefpatahhebrew'] = 0xFB2E;
  9601. t['alefqamatshebrew'] = 0xFB2F;
  9602. t['aleph'] = 0x2135;
  9603. t['allequal'] = 0x224C;
  9604. t['alpha'] = 0x03B1;
  9605. t['alphatonos'] = 0x03AC;
  9606. t['amacron'] = 0x0101;
  9607. t['amonospace'] = 0xFF41;
  9608. t['ampersand'] = 0x0026;
  9609. t['ampersandmonospace'] = 0xFF06;
  9610. t['ampersandsmall'] = 0xF726;
  9611. t['amsquare'] = 0x33C2;
  9612. t['anbopomofo'] = 0x3122;
  9613. t['angbopomofo'] = 0x3124;
  9614. t['angbracketleft'] = 0x3008;
  9615. t['angbracketright'] = 0x3009;
  9616. t['angkhankhuthai'] = 0x0E5A;
  9617. t['angle'] = 0x2220;
  9618. t['anglebracketleft'] = 0x3008;
  9619. t['anglebracketleftvertical'] = 0xFE3F;
  9620. t['anglebracketright'] = 0x3009;
  9621. t['anglebracketrightvertical'] = 0xFE40;
  9622. t['angleleft'] = 0x2329;
  9623. t['angleright'] = 0x232A;
  9624. t['angstrom'] = 0x212B;
  9625. t['anoteleia'] = 0x0387;
  9626. t['anudattadeva'] = 0x0952;
  9627. t['anusvarabengali'] = 0x0982;
  9628. t['anusvaradeva'] = 0x0902;
  9629. t['anusvaragujarati'] = 0x0A82;
  9630. t['aogonek'] = 0x0105;
  9631. t['apaatosquare'] = 0x3300;
  9632. t['aparen'] = 0x249C;
  9633. t['apostrophearmenian'] = 0x055A;
  9634. t['apostrophemod'] = 0x02BC;
  9635. t['apple'] = 0xF8FF;
  9636. t['approaches'] = 0x2250;
  9637. t['approxequal'] = 0x2248;
  9638. t['approxequalorimage'] = 0x2252;
  9639. t['approximatelyequal'] = 0x2245;
  9640. t['araeaekorean'] = 0x318E;
  9641. t['araeakorean'] = 0x318D;
  9642. t['arc'] = 0x2312;
  9643. t['arighthalfring'] = 0x1E9A;
  9644. t['aring'] = 0x00E5;
  9645. t['aringacute'] = 0x01FB;
  9646. t['aringbelow'] = 0x1E01;
  9647. t['arrowboth'] = 0x2194;
  9648. t['arrowdashdown'] = 0x21E3;
  9649. t['arrowdashleft'] = 0x21E0;
  9650. t['arrowdashright'] = 0x21E2;
  9651. t['arrowdashup'] = 0x21E1;
  9652. t['arrowdblboth'] = 0x21D4;
  9653. t['arrowdbldown'] = 0x21D3;
  9654. t['arrowdblleft'] = 0x21D0;
  9655. t['arrowdblright'] = 0x21D2;
  9656. t['arrowdblup'] = 0x21D1;
  9657. t['arrowdown'] = 0x2193;
  9658. t['arrowdownleft'] = 0x2199;
  9659. t['arrowdownright'] = 0x2198;
  9660. t['arrowdownwhite'] = 0x21E9;
  9661. t['arrowheaddownmod'] = 0x02C5;
  9662. t['arrowheadleftmod'] = 0x02C2;
  9663. t['arrowheadrightmod'] = 0x02C3;
  9664. t['arrowheadupmod'] = 0x02C4;
  9665. t['arrowhorizex'] = 0xF8E7;
  9666. t['arrowleft'] = 0x2190;
  9667. t['arrowleftdbl'] = 0x21D0;
  9668. t['arrowleftdblstroke'] = 0x21CD;
  9669. t['arrowleftoverright'] = 0x21C6;
  9670. t['arrowleftwhite'] = 0x21E6;
  9671. t['arrowright'] = 0x2192;
  9672. t['arrowrightdblstroke'] = 0x21CF;
  9673. t['arrowrightheavy'] = 0x279E;
  9674. t['arrowrightoverleft'] = 0x21C4;
  9675. t['arrowrightwhite'] = 0x21E8;
  9676. t['arrowtableft'] = 0x21E4;
  9677. t['arrowtabright'] = 0x21E5;
  9678. t['arrowup'] = 0x2191;
  9679. t['arrowupdn'] = 0x2195;
  9680. t['arrowupdnbse'] = 0x21A8;
  9681. t['arrowupdownbase'] = 0x21A8;
  9682. t['arrowupleft'] = 0x2196;
  9683. t['arrowupleftofdown'] = 0x21C5;
  9684. t['arrowupright'] = 0x2197;
  9685. t['arrowupwhite'] = 0x21E7;
  9686. t['arrowvertex'] = 0xF8E6;
  9687. t['asciicircum'] = 0x005E;
  9688. t['asciicircummonospace'] = 0xFF3E;
  9689. t['asciitilde'] = 0x007E;
  9690. t['asciitildemonospace'] = 0xFF5E;
  9691. t['ascript'] = 0x0251;
  9692. t['ascriptturned'] = 0x0252;
  9693. t['asmallhiragana'] = 0x3041;
  9694. t['asmallkatakana'] = 0x30A1;
  9695. t['asmallkatakanahalfwidth'] = 0xFF67;
  9696. t['asterisk'] = 0x002A;
  9697. t['asteriskaltonearabic'] = 0x066D;
  9698. t['asteriskarabic'] = 0x066D;
  9699. t['asteriskmath'] = 0x2217;
  9700. t['asteriskmonospace'] = 0xFF0A;
  9701. t['asterisksmall'] = 0xFE61;
  9702. t['asterism'] = 0x2042;
  9703. t['asuperior'] = 0xF6E9;
  9704. t['asymptoticallyequal'] = 0x2243;
  9705. t['at'] = 0x0040;
  9706. t['atilde'] = 0x00E3;
  9707. t['atmonospace'] = 0xFF20;
  9708. t['atsmall'] = 0xFE6B;
  9709. t['aturned'] = 0x0250;
  9710. t['aubengali'] = 0x0994;
  9711. t['aubopomofo'] = 0x3120;
  9712. t['audeva'] = 0x0914;
  9713. t['augujarati'] = 0x0A94;
  9714. t['augurmukhi'] = 0x0A14;
  9715. t['aulengthmarkbengali'] = 0x09D7;
  9716. t['aumatragurmukhi'] = 0x0A4C;
  9717. t['auvowelsignbengali'] = 0x09CC;
  9718. t['auvowelsigndeva'] = 0x094C;
  9719. t['auvowelsigngujarati'] = 0x0ACC;
  9720. t['avagrahadeva'] = 0x093D;
  9721. t['aybarmenian'] = 0x0561;
  9722. t['ayin'] = 0x05E2;
  9723. t['ayinaltonehebrew'] = 0xFB20;
  9724. t['ayinhebrew'] = 0x05E2;
  9725. t['b'] = 0x0062;
  9726. t['babengali'] = 0x09AC;
  9727. t['backslash'] = 0x005C;
  9728. t['backslashmonospace'] = 0xFF3C;
  9729. t['badeva'] = 0x092C;
  9730. t['bagujarati'] = 0x0AAC;
  9731. t['bagurmukhi'] = 0x0A2C;
  9732. t['bahiragana'] = 0x3070;
  9733. t['bahtthai'] = 0x0E3F;
  9734. t['bakatakana'] = 0x30D0;
  9735. t['bar'] = 0x007C;
  9736. t['barmonospace'] = 0xFF5C;
  9737. t['bbopomofo'] = 0x3105;
  9738. t['bcircle'] = 0x24D1;
  9739. t['bdotaccent'] = 0x1E03;
  9740. t['bdotbelow'] = 0x1E05;
  9741. t['beamedsixteenthnotes'] = 0x266C;
  9742. t['because'] = 0x2235;
  9743. t['becyrillic'] = 0x0431;
  9744. t['beharabic'] = 0x0628;
  9745. t['behfinalarabic'] = 0xFE90;
  9746. t['behinitialarabic'] = 0xFE91;
  9747. t['behiragana'] = 0x3079;
  9748. t['behmedialarabic'] = 0xFE92;
  9749. t['behmeeminitialarabic'] = 0xFC9F;
  9750. t['behmeemisolatedarabic'] = 0xFC08;
  9751. t['behnoonfinalarabic'] = 0xFC6D;
  9752. t['bekatakana'] = 0x30D9;
  9753. t['benarmenian'] = 0x0562;
  9754. t['bet'] = 0x05D1;
  9755. t['beta'] = 0x03B2;
  9756. t['betasymbolgreek'] = 0x03D0;
  9757. t['betdagesh'] = 0xFB31;
  9758. t['betdageshhebrew'] = 0xFB31;
  9759. t['bethebrew'] = 0x05D1;
  9760. t['betrafehebrew'] = 0xFB4C;
  9761. t['bhabengali'] = 0x09AD;
  9762. t['bhadeva'] = 0x092D;
  9763. t['bhagujarati'] = 0x0AAD;
  9764. t['bhagurmukhi'] = 0x0A2D;
  9765. t['bhook'] = 0x0253;
  9766. t['bihiragana'] = 0x3073;
  9767. t['bikatakana'] = 0x30D3;
  9768. t['bilabialclick'] = 0x0298;
  9769. t['bindigurmukhi'] = 0x0A02;
  9770. t['birusquare'] = 0x3331;
  9771. t['blackcircle'] = 0x25CF;
  9772. t['blackdiamond'] = 0x25C6;
  9773. t['blackdownpointingtriangle'] = 0x25BC;
  9774. t['blackleftpointingpointer'] = 0x25C4;
  9775. t['blackleftpointingtriangle'] = 0x25C0;
  9776. t['blacklenticularbracketleft'] = 0x3010;
  9777. t['blacklenticularbracketleftvertical'] = 0xFE3B;
  9778. t['blacklenticularbracketright'] = 0x3011;
  9779. t['blacklenticularbracketrightvertical'] = 0xFE3C;
  9780. t['blacklowerlefttriangle'] = 0x25E3;
  9781. t['blacklowerrighttriangle'] = 0x25E2;
  9782. t['blackrectangle'] = 0x25AC;
  9783. t['blackrightpointingpointer'] = 0x25BA;
  9784. t['blackrightpointingtriangle'] = 0x25B6;
  9785. t['blacksmallsquare'] = 0x25AA;
  9786. t['blacksmilingface'] = 0x263B;
  9787. t['blacksquare'] = 0x25A0;
  9788. t['blackstar'] = 0x2605;
  9789. t['blackupperlefttriangle'] = 0x25E4;
  9790. t['blackupperrighttriangle'] = 0x25E5;
  9791. t['blackuppointingsmalltriangle'] = 0x25B4;
  9792. t['blackuppointingtriangle'] = 0x25B2;
  9793. t['blank'] = 0x2423;
  9794. t['blinebelow'] = 0x1E07;
  9795. t['block'] = 0x2588;
  9796. t['bmonospace'] = 0xFF42;
  9797. t['bobaimaithai'] = 0x0E1A;
  9798. t['bohiragana'] = 0x307C;
  9799. t['bokatakana'] = 0x30DC;
  9800. t['bparen'] = 0x249D;
  9801. t['bqsquare'] = 0x33C3;
  9802. t['braceex'] = 0xF8F4;
  9803. t['braceleft'] = 0x007B;
  9804. t['braceleftbt'] = 0xF8F3;
  9805. t['braceleftmid'] = 0xF8F2;
  9806. t['braceleftmonospace'] = 0xFF5B;
  9807. t['braceleftsmall'] = 0xFE5B;
  9808. t['bracelefttp'] = 0xF8F1;
  9809. t['braceleftvertical'] = 0xFE37;
  9810. t['braceright'] = 0x007D;
  9811. t['bracerightbt'] = 0xF8FE;
  9812. t['bracerightmid'] = 0xF8FD;
  9813. t['bracerightmonospace'] = 0xFF5D;
  9814. t['bracerightsmall'] = 0xFE5C;
  9815. t['bracerighttp'] = 0xF8FC;
  9816. t['bracerightvertical'] = 0xFE38;
  9817. t['bracketleft'] = 0x005B;
  9818. t['bracketleftbt'] = 0xF8F0;
  9819. t['bracketleftex'] = 0xF8EF;
  9820. t['bracketleftmonospace'] = 0xFF3B;
  9821. t['bracketlefttp'] = 0xF8EE;
  9822. t['bracketright'] = 0x005D;
  9823. t['bracketrightbt'] = 0xF8FB;
  9824. t['bracketrightex'] = 0xF8FA;
  9825. t['bracketrightmonospace'] = 0xFF3D;
  9826. t['bracketrighttp'] = 0xF8F9;
  9827. t['breve'] = 0x02D8;
  9828. t['brevebelowcmb'] = 0x032E;
  9829. t['brevecmb'] = 0x0306;
  9830. t['breveinvertedbelowcmb'] = 0x032F;
  9831. t['breveinvertedcmb'] = 0x0311;
  9832. t['breveinverteddoublecmb'] = 0x0361;
  9833. t['bridgebelowcmb'] = 0x032A;
  9834. t['bridgeinvertedbelowcmb'] = 0x033A;
  9835. t['brokenbar'] = 0x00A6;
  9836. t['bstroke'] = 0x0180;
  9837. t['bsuperior'] = 0xF6EA;
  9838. t['btopbar'] = 0x0183;
  9839. t['buhiragana'] = 0x3076;
  9840. t['bukatakana'] = 0x30D6;
  9841. t['bullet'] = 0x2022;
  9842. t['bulletinverse'] = 0x25D8;
  9843. t['bulletoperator'] = 0x2219;
  9844. t['bullseye'] = 0x25CE;
  9845. t['c'] = 0x0063;
  9846. t['caarmenian'] = 0x056E;
  9847. t['cabengali'] = 0x099A;
  9848. t['cacute'] = 0x0107;
  9849. t['cadeva'] = 0x091A;
  9850. t['cagujarati'] = 0x0A9A;
  9851. t['cagurmukhi'] = 0x0A1A;
  9852. t['calsquare'] = 0x3388;
  9853. t['candrabindubengali'] = 0x0981;
  9854. t['candrabinducmb'] = 0x0310;
  9855. t['candrabindudeva'] = 0x0901;
  9856. t['candrabindugujarati'] = 0x0A81;
  9857. t['capslock'] = 0x21EA;
  9858. t['careof'] = 0x2105;
  9859. t['caron'] = 0x02C7;
  9860. t['caronbelowcmb'] = 0x032C;
  9861. t['caroncmb'] = 0x030C;
  9862. t['carriagereturn'] = 0x21B5;
  9863. t['cbopomofo'] = 0x3118;
  9864. t['ccaron'] = 0x010D;
  9865. t['ccedilla'] = 0x00E7;
  9866. t['ccedillaacute'] = 0x1E09;
  9867. t['ccircle'] = 0x24D2;
  9868. t['ccircumflex'] = 0x0109;
  9869. t['ccurl'] = 0x0255;
  9870. t['cdot'] = 0x010B;
  9871. t['cdotaccent'] = 0x010B;
  9872. t['cdsquare'] = 0x33C5;
  9873. t['cedilla'] = 0x00B8;
  9874. t['cedillacmb'] = 0x0327;
  9875. t['cent'] = 0x00A2;
  9876. t['centigrade'] = 0x2103;
  9877. t['centinferior'] = 0xF6DF;
  9878. t['centmonospace'] = 0xFFE0;
  9879. t['centoldstyle'] = 0xF7A2;
  9880. t['centsuperior'] = 0xF6E0;
  9881. t['chaarmenian'] = 0x0579;
  9882. t['chabengali'] = 0x099B;
  9883. t['chadeva'] = 0x091B;
  9884. t['chagujarati'] = 0x0A9B;
  9885. t['chagurmukhi'] = 0x0A1B;
  9886. t['chbopomofo'] = 0x3114;
  9887. t['cheabkhasiancyrillic'] = 0x04BD;
  9888. t['checkmark'] = 0x2713;
  9889. t['checyrillic'] = 0x0447;
  9890. t['chedescenderabkhasiancyrillic'] = 0x04BF;
  9891. t['chedescendercyrillic'] = 0x04B7;
  9892. t['chedieresiscyrillic'] = 0x04F5;
  9893. t['cheharmenian'] = 0x0573;
  9894. t['chekhakassiancyrillic'] = 0x04CC;
  9895. t['cheverticalstrokecyrillic'] = 0x04B9;
  9896. t['chi'] = 0x03C7;
  9897. t['chieuchacirclekorean'] = 0x3277;
  9898. t['chieuchaparenkorean'] = 0x3217;
  9899. t['chieuchcirclekorean'] = 0x3269;
  9900. t['chieuchkorean'] = 0x314A;
  9901. t['chieuchparenkorean'] = 0x3209;
  9902. t['chochangthai'] = 0x0E0A;
  9903. t['chochanthai'] = 0x0E08;
  9904. t['chochingthai'] = 0x0E09;
  9905. t['chochoethai'] = 0x0E0C;
  9906. t['chook'] = 0x0188;
  9907. t['cieucacirclekorean'] = 0x3276;
  9908. t['cieucaparenkorean'] = 0x3216;
  9909. t['cieuccirclekorean'] = 0x3268;
  9910. t['cieuckorean'] = 0x3148;
  9911. t['cieucparenkorean'] = 0x3208;
  9912. t['cieucuparenkorean'] = 0x321C;
  9913. t['circle'] = 0x25CB;
  9914. t['circlecopyrt'] = 0x00A9;
  9915. t['circlemultiply'] = 0x2297;
  9916. t['circleot'] = 0x2299;
  9917. t['circleplus'] = 0x2295;
  9918. t['circlepostalmark'] = 0x3036;
  9919. t['circlewithlefthalfblack'] = 0x25D0;
  9920. t['circlewithrighthalfblack'] = 0x25D1;
  9921. t['circumflex'] = 0x02C6;
  9922. t['circumflexbelowcmb'] = 0x032D;
  9923. t['circumflexcmb'] = 0x0302;
  9924. t['clear'] = 0x2327;
  9925. t['clickalveolar'] = 0x01C2;
  9926. t['clickdental'] = 0x01C0;
  9927. t['clicklateral'] = 0x01C1;
  9928. t['clickretroflex'] = 0x01C3;
  9929. t['club'] = 0x2663;
  9930. t['clubsuitblack'] = 0x2663;
  9931. t['clubsuitwhite'] = 0x2667;
  9932. t['cmcubedsquare'] = 0x33A4;
  9933. t['cmonospace'] = 0xFF43;
  9934. t['cmsquaredsquare'] = 0x33A0;
  9935. t['coarmenian'] = 0x0581;
  9936. t['colon'] = 0x003A;
  9937. t['colonmonetary'] = 0x20A1;
  9938. t['colonmonospace'] = 0xFF1A;
  9939. t['colonsign'] = 0x20A1;
  9940. t['colonsmall'] = 0xFE55;
  9941. t['colontriangularhalfmod'] = 0x02D1;
  9942. t['colontriangularmod'] = 0x02D0;
  9943. t['comma'] = 0x002C;
  9944. t['commaabovecmb'] = 0x0313;
  9945. t['commaaboverightcmb'] = 0x0315;
  9946. t['commaaccent'] = 0xF6C3;
  9947. t['commaarabic'] = 0x060C;
  9948. t['commaarmenian'] = 0x055D;
  9949. t['commainferior'] = 0xF6E1;
  9950. t['commamonospace'] = 0xFF0C;
  9951. t['commareversedabovecmb'] = 0x0314;
  9952. t['commareversedmod'] = 0x02BD;
  9953. t['commasmall'] = 0xFE50;
  9954. t['commasuperior'] = 0xF6E2;
  9955. t['commaturnedabovecmb'] = 0x0312;
  9956. t['commaturnedmod'] = 0x02BB;
  9957. t['compass'] = 0x263C;
  9958. t['congruent'] = 0x2245;
  9959. t['contourintegral'] = 0x222E;
  9960. t['control'] = 0x2303;
  9961. t['controlACK'] = 0x0006;
  9962. t['controlBEL'] = 0x0007;
  9963. t['controlBS'] = 0x0008;
  9964. t['controlCAN'] = 0x0018;
  9965. t['controlCR'] = 0x000D;
  9966. t['controlDC1'] = 0x0011;
  9967. t['controlDC2'] = 0x0012;
  9968. t['controlDC3'] = 0x0013;
  9969. t['controlDC4'] = 0x0014;
  9970. t['controlDEL'] = 0x007F;
  9971. t['controlDLE'] = 0x0010;
  9972. t['controlEM'] = 0x0019;
  9973. t['controlENQ'] = 0x0005;
  9974. t['controlEOT'] = 0x0004;
  9975. t['controlESC'] = 0x001B;
  9976. t['controlETB'] = 0x0017;
  9977. t['controlETX'] = 0x0003;
  9978. t['controlFF'] = 0x000C;
  9979. t['controlFS'] = 0x001C;
  9980. t['controlGS'] = 0x001D;
  9981. t['controlHT'] = 0x0009;
  9982. t['controlLF'] = 0x000A;
  9983. t['controlNAK'] = 0x0015;
  9984. t['controlRS'] = 0x001E;
  9985. t['controlSI'] = 0x000F;
  9986. t['controlSO'] = 0x000E;
  9987. t['controlSOT'] = 0x0002;
  9988. t['controlSTX'] = 0x0001;
  9989. t['controlSUB'] = 0x001A;
  9990. t['controlSYN'] = 0x0016;
  9991. t['controlUS'] = 0x001F;
  9992. t['controlVT'] = 0x000B;
  9993. t['copyright'] = 0x00A9;
  9994. t['copyrightsans'] = 0xF8E9;
  9995. t['copyrightserif'] = 0xF6D9;
  9996. t['cornerbracketleft'] = 0x300C;
  9997. t['cornerbracketlefthalfwidth'] = 0xFF62;
  9998. t['cornerbracketleftvertical'] = 0xFE41;
  9999. t['cornerbracketright'] = 0x300D;
  10000. t['cornerbracketrighthalfwidth'] = 0xFF63;
  10001. t['cornerbracketrightvertical'] = 0xFE42;
  10002. t['corporationsquare'] = 0x337F;
  10003. t['cosquare'] = 0x33C7;
  10004. t['coverkgsquare'] = 0x33C6;
  10005. t['cparen'] = 0x249E;
  10006. t['cruzeiro'] = 0x20A2;
  10007. t['cstretched'] = 0x0297;
  10008. t['curlyand'] = 0x22CF;
  10009. t['curlyor'] = 0x22CE;
  10010. t['currency'] = 0x00A4;
  10011. t['cyrBreve'] = 0xF6D1;
  10012. t['cyrFlex'] = 0xF6D2;
  10013. t['cyrbreve'] = 0xF6D4;
  10014. t['cyrflex'] = 0xF6D5;
  10015. t['d'] = 0x0064;
  10016. t['daarmenian'] = 0x0564;
  10017. t['dabengali'] = 0x09A6;
  10018. t['dadarabic'] = 0x0636;
  10019. t['dadeva'] = 0x0926;
  10020. t['dadfinalarabic'] = 0xFEBE;
  10021. t['dadinitialarabic'] = 0xFEBF;
  10022. t['dadmedialarabic'] = 0xFEC0;
  10023. t['dagesh'] = 0x05BC;
  10024. t['dageshhebrew'] = 0x05BC;
  10025. t['dagger'] = 0x2020;
  10026. t['daggerdbl'] = 0x2021;
  10027. t['dagujarati'] = 0x0AA6;
  10028. t['dagurmukhi'] = 0x0A26;
  10029. t['dahiragana'] = 0x3060;
  10030. t['dakatakana'] = 0x30C0;
  10031. t['dalarabic'] = 0x062F;
  10032. t['dalet'] = 0x05D3;
  10033. t['daletdagesh'] = 0xFB33;
  10034. t['daletdageshhebrew'] = 0xFB33;
  10035. t['dalethebrew'] = 0x05D3;
  10036. t['dalfinalarabic'] = 0xFEAA;
  10037. t['dammaarabic'] = 0x064F;
  10038. t['dammalowarabic'] = 0x064F;
  10039. t['dammatanaltonearabic'] = 0x064C;
  10040. t['dammatanarabic'] = 0x064C;
  10041. t['danda'] = 0x0964;
  10042. t['dargahebrew'] = 0x05A7;
  10043. t['dargalefthebrew'] = 0x05A7;
  10044. t['dasiapneumatacyrilliccmb'] = 0x0485;
  10045. t['dblGrave'] = 0xF6D3;
  10046. t['dblanglebracketleft'] = 0x300A;
  10047. t['dblanglebracketleftvertical'] = 0xFE3D;
  10048. t['dblanglebracketright'] = 0x300B;
  10049. t['dblanglebracketrightvertical'] = 0xFE3E;
  10050. t['dblarchinvertedbelowcmb'] = 0x032B;
  10051. t['dblarrowleft'] = 0x21D4;
  10052. t['dblarrowright'] = 0x21D2;
  10053. t['dbldanda'] = 0x0965;
  10054. t['dblgrave'] = 0xF6D6;
  10055. t['dblgravecmb'] = 0x030F;
  10056. t['dblintegral'] = 0x222C;
  10057. t['dbllowline'] = 0x2017;
  10058. t['dbllowlinecmb'] = 0x0333;
  10059. t['dbloverlinecmb'] = 0x033F;
  10060. t['dblprimemod'] = 0x02BA;
  10061. t['dblverticalbar'] = 0x2016;
  10062. t['dblverticallineabovecmb'] = 0x030E;
  10063. t['dbopomofo'] = 0x3109;
  10064. t['dbsquare'] = 0x33C8;
  10065. t['dcaron'] = 0x010F;
  10066. t['dcedilla'] = 0x1E11;
  10067. t['dcircle'] = 0x24D3;
  10068. t['dcircumflexbelow'] = 0x1E13;
  10069. t['dcroat'] = 0x0111;
  10070. t['ddabengali'] = 0x09A1;
  10071. t['ddadeva'] = 0x0921;
  10072. t['ddagujarati'] = 0x0AA1;
  10073. t['ddagurmukhi'] = 0x0A21;
  10074. t['ddalarabic'] = 0x0688;
  10075. t['ddalfinalarabic'] = 0xFB89;
  10076. t['dddhadeva'] = 0x095C;
  10077. t['ddhabengali'] = 0x09A2;
  10078. t['ddhadeva'] = 0x0922;
  10079. t['ddhagujarati'] = 0x0AA2;
  10080. t['ddhagurmukhi'] = 0x0A22;
  10081. t['ddotaccent'] = 0x1E0B;
  10082. t['ddotbelow'] = 0x1E0D;
  10083. t['decimalseparatorarabic'] = 0x066B;
  10084. t['decimalseparatorpersian'] = 0x066B;
  10085. t['decyrillic'] = 0x0434;
  10086. t['degree'] = 0x00B0;
  10087. t['dehihebrew'] = 0x05AD;
  10088. t['dehiragana'] = 0x3067;
  10089. t['deicoptic'] = 0x03EF;
  10090. t['dekatakana'] = 0x30C7;
  10091. t['deleteleft'] = 0x232B;
  10092. t['deleteright'] = 0x2326;
  10093. t['delta'] = 0x03B4;
  10094. t['deltaturned'] = 0x018D;
  10095. t['denominatorminusonenumeratorbengali'] = 0x09F8;
  10096. t['dezh'] = 0x02A4;
  10097. t['dhabengali'] = 0x09A7;
  10098. t['dhadeva'] = 0x0927;
  10099. t['dhagujarati'] = 0x0AA7;
  10100. t['dhagurmukhi'] = 0x0A27;
  10101. t['dhook'] = 0x0257;
  10102. t['dialytikatonos'] = 0x0385;
  10103. t['dialytikatonoscmb'] = 0x0344;
  10104. t['diamond'] = 0x2666;
  10105. t['diamondsuitwhite'] = 0x2662;
  10106. t['dieresis'] = 0x00A8;
  10107. t['dieresisacute'] = 0xF6D7;
  10108. t['dieresisbelowcmb'] = 0x0324;
  10109. t['dieresiscmb'] = 0x0308;
  10110. t['dieresisgrave'] = 0xF6D8;
  10111. t['dieresistonos'] = 0x0385;
  10112. t['dihiragana'] = 0x3062;
  10113. t['dikatakana'] = 0x30C2;
  10114. t['dittomark'] = 0x3003;
  10115. t['divide'] = 0x00F7;
  10116. t['divides'] = 0x2223;
  10117. t['divisionslash'] = 0x2215;
  10118. t['djecyrillic'] = 0x0452;
  10119. t['dkshade'] = 0x2593;
  10120. t['dlinebelow'] = 0x1E0F;
  10121. t['dlsquare'] = 0x3397;
  10122. t['dmacron'] = 0x0111;
  10123. t['dmonospace'] = 0xFF44;
  10124. t['dnblock'] = 0x2584;
  10125. t['dochadathai'] = 0x0E0E;
  10126. t['dodekthai'] = 0x0E14;
  10127. t['dohiragana'] = 0x3069;
  10128. t['dokatakana'] = 0x30C9;
  10129. t['dollar'] = 0x0024;
  10130. t['dollarinferior'] = 0xF6E3;
  10131. t['dollarmonospace'] = 0xFF04;
  10132. t['dollaroldstyle'] = 0xF724;
  10133. t['dollarsmall'] = 0xFE69;
  10134. t['dollarsuperior'] = 0xF6E4;
  10135. t['dong'] = 0x20AB;
  10136. t['dorusquare'] = 0x3326;
  10137. t['dotaccent'] = 0x02D9;
  10138. t['dotaccentcmb'] = 0x0307;
  10139. t['dotbelowcmb'] = 0x0323;
  10140. t['dotbelowcomb'] = 0x0323;
  10141. t['dotkatakana'] = 0x30FB;
  10142. t['dotlessi'] = 0x0131;
  10143. t['dotlessj'] = 0xF6BE;
  10144. t['dotlessjstrokehook'] = 0x0284;
  10145. t['dotmath'] = 0x22C5;
  10146. t['dottedcircle'] = 0x25CC;
  10147. t['doubleyodpatah'] = 0xFB1F;
  10148. t['doubleyodpatahhebrew'] = 0xFB1F;
  10149. t['downtackbelowcmb'] = 0x031E;
  10150. t['downtackmod'] = 0x02D5;
  10151. t['dparen'] = 0x249F;
  10152. t['dsuperior'] = 0xF6EB;
  10153. t['dtail'] = 0x0256;
  10154. t['dtopbar'] = 0x018C;
  10155. t['duhiragana'] = 0x3065;
  10156. t['dukatakana'] = 0x30C5;
  10157. t['dz'] = 0x01F3;
  10158. t['dzaltone'] = 0x02A3;
  10159. t['dzcaron'] = 0x01C6;
  10160. t['dzcurl'] = 0x02A5;
  10161. t['dzeabkhasiancyrillic'] = 0x04E1;
  10162. t['dzecyrillic'] = 0x0455;
  10163. t['dzhecyrillic'] = 0x045F;
  10164. t['e'] = 0x0065;
  10165. t['eacute'] = 0x00E9;
  10166. t['earth'] = 0x2641;
  10167. t['ebengali'] = 0x098F;
  10168. t['ebopomofo'] = 0x311C;
  10169. t['ebreve'] = 0x0115;
  10170. t['ecandradeva'] = 0x090D;
  10171. t['ecandragujarati'] = 0x0A8D;
  10172. t['ecandravowelsigndeva'] = 0x0945;
  10173. t['ecandravowelsigngujarati'] = 0x0AC5;
  10174. t['ecaron'] = 0x011B;
  10175. t['ecedillabreve'] = 0x1E1D;
  10176. t['echarmenian'] = 0x0565;
  10177. t['echyiwnarmenian'] = 0x0587;
  10178. t['ecircle'] = 0x24D4;
  10179. t['ecircumflex'] = 0x00EA;
  10180. t['ecircumflexacute'] = 0x1EBF;
  10181. t['ecircumflexbelow'] = 0x1E19;
  10182. t['ecircumflexdotbelow'] = 0x1EC7;
  10183. t['ecircumflexgrave'] = 0x1EC1;
  10184. t['ecircumflexhookabove'] = 0x1EC3;
  10185. t['ecircumflextilde'] = 0x1EC5;
  10186. t['ecyrillic'] = 0x0454;
  10187. t['edblgrave'] = 0x0205;
  10188. t['edeva'] = 0x090F;
  10189. t['edieresis'] = 0x00EB;
  10190. t['edot'] = 0x0117;
  10191. t['edotaccent'] = 0x0117;
  10192. t['edotbelow'] = 0x1EB9;
  10193. t['eegurmukhi'] = 0x0A0F;
  10194. t['eematragurmukhi'] = 0x0A47;
  10195. t['efcyrillic'] = 0x0444;
  10196. t['egrave'] = 0x00E8;
  10197. t['egujarati'] = 0x0A8F;
  10198. t['eharmenian'] = 0x0567;
  10199. t['ehbopomofo'] = 0x311D;
  10200. t['ehiragana'] = 0x3048;
  10201. t['ehookabove'] = 0x1EBB;
  10202. t['eibopomofo'] = 0x311F;
  10203. t['eight'] = 0x0038;
  10204. t['eightarabic'] = 0x0668;
  10205. t['eightbengali'] = 0x09EE;
  10206. t['eightcircle'] = 0x2467;
  10207. t['eightcircleinversesansserif'] = 0x2791;
  10208. t['eightdeva'] = 0x096E;
  10209. t['eighteencircle'] = 0x2471;
  10210. t['eighteenparen'] = 0x2485;
  10211. t['eighteenperiod'] = 0x2499;
  10212. t['eightgujarati'] = 0x0AEE;
  10213. t['eightgurmukhi'] = 0x0A6E;
  10214. t['eighthackarabic'] = 0x0668;
  10215. t['eighthangzhou'] = 0x3028;
  10216. t['eighthnotebeamed'] = 0x266B;
  10217. t['eightideographicparen'] = 0x3227;
  10218. t['eightinferior'] = 0x2088;
  10219. t['eightmonospace'] = 0xFF18;
  10220. t['eightoldstyle'] = 0xF738;
  10221. t['eightparen'] = 0x247B;
  10222. t['eightperiod'] = 0x248F;
  10223. t['eightpersian'] = 0x06F8;
  10224. t['eightroman'] = 0x2177;
  10225. t['eightsuperior'] = 0x2078;
  10226. t['eightthai'] = 0x0E58;
  10227. t['einvertedbreve'] = 0x0207;
  10228. t['eiotifiedcyrillic'] = 0x0465;
  10229. t['ekatakana'] = 0x30A8;
  10230. t['ekatakanahalfwidth'] = 0xFF74;
  10231. t['ekonkargurmukhi'] = 0x0A74;
  10232. t['ekorean'] = 0x3154;
  10233. t['elcyrillic'] = 0x043B;
  10234. t['element'] = 0x2208;
  10235. t['elevencircle'] = 0x246A;
  10236. t['elevenparen'] = 0x247E;
  10237. t['elevenperiod'] = 0x2492;
  10238. t['elevenroman'] = 0x217A;
  10239. t['ellipsis'] = 0x2026;
  10240. t['ellipsisvertical'] = 0x22EE;
  10241. t['emacron'] = 0x0113;
  10242. t['emacronacute'] = 0x1E17;
  10243. t['emacrongrave'] = 0x1E15;
  10244. t['emcyrillic'] = 0x043C;
  10245. t['emdash'] = 0x2014;
  10246. t['emdashvertical'] = 0xFE31;
  10247. t['emonospace'] = 0xFF45;
  10248. t['emphasismarkarmenian'] = 0x055B;
  10249. t['emptyset'] = 0x2205;
  10250. t['enbopomofo'] = 0x3123;
  10251. t['encyrillic'] = 0x043D;
  10252. t['endash'] = 0x2013;
  10253. t['endashvertical'] = 0xFE32;
  10254. t['endescendercyrillic'] = 0x04A3;
  10255. t['eng'] = 0x014B;
  10256. t['engbopomofo'] = 0x3125;
  10257. t['enghecyrillic'] = 0x04A5;
  10258. t['enhookcyrillic'] = 0x04C8;
  10259. t['enspace'] = 0x2002;
  10260. t['eogonek'] = 0x0119;
  10261. t['eokorean'] = 0x3153;
  10262. t['eopen'] = 0x025B;
  10263. t['eopenclosed'] = 0x029A;
  10264. t['eopenreversed'] = 0x025C;
  10265. t['eopenreversedclosed'] = 0x025E;
  10266. t['eopenreversedhook'] = 0x025D;
  10267. t['eparen'] = 0x24A0;
  10268. t['epsilon'] = 0x03B5;
  10269. t['epsilontonos'] = 0x03AD;
  10270. t['equal'] = 0x003D;
  10271. t['equalmonospace'] = 0xFF1D;
  10272. t['equalsmall'] = 0xFE66;
  10273. t['equalsuperior'] = 0x207C;
  10274. t['equivalence'] = 0x2261;
  10275. t['erbopomofo'] = 0x3126;
  10276. t['ercyrillic'] = 0x0440;
  10277. t['ereversed'] = 0x0258;
  10278. t['ereversedcyrillic'] = 0x044D;
  10279. t['escyrillic'] = 0x0441;
  10280. t['esdescendercyrillic'] = 0x04AB;
  10281. t['esh'] = 0x0283;
  10282. t['eshcurl'] = 0x0286;
  10283. t['eshortdeva'] = 0x090E;
  10284. t['eshortvowelsigndeva'] = 0x0946;
  10285. t['eshreversedloop'] = 0x01AA;
  10286. t['eshsquatreversed'] = 0x0285;
  10287. t['esmallhiragana'] = 0x3047;
  10288. t['esmallkatakana'] = 0x30A7;
  10289. t['esmallkatakanahalfwidth'] = 0xFF6A;
  10290. t['estimated'] = 0x212E;
  10291. t['esuperior'] = 0xF6EC;
  10292. t['eta'] = 0x03B7;
  10293. t['etarmenian'] = 0x0568;
  10294. t['etatonos'] = 0x03AE;
  10295. t['eth'] = 0x00F0;
  10296. t['etilde'] = 0x1EBD;
  10297. t['etildebelow'] = 0x1E1B;
  10298. t['etnahtafoukhhebrew'] = 0x0591;
  10299. t['etnahtafoukhlefthebrew'] = 0x0591;
  10300. t['etnahtahebrew'] = 0x0591;
  10301. t['etnahtalefthebrew'] = 0x0591;
  10302. t['eturned'] = 0x01DD;
  10303. t['eukorean'] = 0x3161;
  10304. t['euro'] = 0x20AC;
  10305. t['evowelsignbengali'] = 0x09C7;
  10306. t['evowelsigndeva'] = 0x0947;
  10307. t['evowelsigngujarati'] = 0x0AC7;
  10308. t['exclam'] = 0x0021;
  10309. t['exclamarmenian'] = 0x055C;
  10310. t['exclamdbl'] = 0x203C;
  10311. t['exclamdown'] = 0x00A1;
  10312. t['exclamdownsmall'] = 0xF7A1;
  10313. t['exclammonospace'] = 0xFF01;
  10314. t['exclamsmall'] = 0xF721;
  10315. t['existential'] = 0x2203;
  10316. t['ezh'] = 0x0292;
  10317. t['ezhcaron'] = 0x01EF;
  10318. t['ezhcurl'] = 0x0293;
  10319. t['ezhreversed'] = 0x01B9;
  10320. t['ezhtail'] = 0x01BA;
  10321. t['f'] = 0x0066;
  10322. t['fadeva'] = 0x095E;
  10323. t['fagurmukhi'] = 0x0A5E;
  10324. t['fahrenheit'] = 0x2109;
  10325. t['fathaarabic'] = 0x064E;
  10326. t['fathalowarabic'] = 0x064E;
  10327. t['fathatanarabic'] = 0x064B;
  10328. t['fbopomofo'] = 0x3108;
  10329. t['fcircle'] = 0x24D5;
  10330. t['fdotaccent'] = 0x1E1F;
  10331. t['feharabic'] = 0x0641;
  10332. t['feharmenian'] = 0x0586;
  10333. t['fehfinalarabic'] = 0xFED2;
  10334. t['fehinitialarabic'] = 0xFED3;
  10335. t['fehmedialarabic'] = 0xFED4;
  10336. t['feicoptic'] = 0x03E5;
  10337. t['female'] = 0x2640;
  10338. t['ff'] = 0xFB00;
  10339. t['ffi'] = 0xFB03;
  10340. t['ffl'] = 0xFB04;
  10341. t['fi'] = 0xFB01;
  10342. t['fifteencircle'] = 0x246E;
  10343. t['fifteenparen'] = 0x2482;
  10344. t['fifteenperiod'] = 0x2496;
  10345. t['figuredash'] = 0x2012;
  10346. t['filledbox'] = 0x25A0;
  10347. t['filledrect'] = 0x25AC;
  10348. t['finalkaf'] = 0x05DA;
  10349. t['finalkafdagesh'] = 0xFB3A;
  10350. t['finalkafdageshhebrew'] = 0xFB3A;
  10351. t['finalkafhebrew'] = 0x05DA;
  10352. t['finalmem'] = 0x05DD;
  10353. t['finalmemhebrew'] = 0x05DD;
  10354. t['finalnun'] = 0x05DF;
  10355. t['finalnunhebrew'] = 0x05DF;
  10356. t['finalpe'] = 0x05E3;
  10357. t['finalpehebrew'] = 0x05E3;
  10358. t['finaltsadi'] = 0x05E5;
  10359. t['finaltsadihebrew'] = 0x05E5;
  10360. t['firsttonechinese'] = 0x02C9;
  10361. t['fisheye'] = 0x25C9;
  10362. t['fitacyrillic'] = 0x0473;
  10363. t['five'] = 0x0035;
  10364. t['fivearabic'] = 0x0665;
  10365. t['fivebengali'] = 0x09EB;
  10366. t['fivecircle'] = 0x2464;
  10367. t['fivecircleinversesansserif'] = 0x278E;
  10368. t['fivedeva'] = 0x096B;
  10369. t['fiveeighths'] = 0x215D;
  10370. t['fivegujarati'] = 0x0AEB;
  10371. t['fivegurmukhi'] = 0x0A6B;
  10372. t['fivehackarabic'] = 0x0665;
  10373. t['fivehangzhou'] = 0x3025;
  10374. t['fiveideographicparen'] = 0x3224;
  10375. t['fiveinferior'] = 0x2085;
  10376. t['fivemonospace'] = 0xFF15;
  10377. t['fiveoldstyle'] = 0xF735;
  10378. t['fiveparen'] = 0x2478;
  10379. t['fiveperiod'] = 0x248C;
  10380. t['fivepersian'] = 0x06F5;
  10381. t['fiveroman'] = 0x2174;
  10382. t['fivesuperior'] = 0x2075;
  10383. t['fivethai'] = 0x0E55;
  10384. t['fl'] = 0xFB02;
  10385. t['florin'] = 0x0192;
  10386. t['fmonospace'] = 0xFF46;
  10387. t['fmsquare'] = 0x3399;
  10388. t['fofanthai'] = 0x0E1F;
  10389. t['fofathai'] = 0x0E1D;
  10390. t['fongmanthai'] = 0x0E4F;
  10391. t['forall'] = 0x2200;
  10392. t['four'] = 0x0034;
  10393. t['fourarabic'] = 0x0664;
  10394. t['fourbengali'] = 0x09EA;
  10395. t['fourcircle'] = 0x2463;
  10396. t['fourcircleinversesansserif'] = 0x278D;
  10397. t['fourdeva'] = 0x096A;
  10398. t['fourgujarati'] = 0x0AEA;
  10399. t['fourgurmukhi'] = 0x0A6A;
  10400. t['fourhackarabic'] = 0x0664;
  10401. t['fourhangzhou'] = 0x3024;
  10402. t['fourideographicparen'] = 0x3223;
  10403. t['fourinferior'] = 0x2084;
  10404. t['fourmonospace'] = 0xFF14;
  10405. t['fournumeratorbengali'] = 0x09F7;
  10406. t['fouroldstyle'] = 0xF734;
  10407. t['fourparen'] = 0x2477;
  10408. t['fourperiod'] = 0x248B;
  10409. t['fourpersian'] = 0x06F4;
  10410. t['fourroman'] = 0x2173;
  10411. t['foursuperior'] = 0x2074;
  10412. t['fourteencircle'] = 0x246D;
  10413. t['fourteenparen'] = 0x2481;
  10414. t['fourteenperiod'] = 0x2495;
  10415. t['fourthai'] = 0x0E54;
  10416. t['fourthtonechinese'] = 0x02CB;
  10417. t['fparen'] = 0x24A1;
  10418. t['fraction'] = 0x2044;
  10419. t['franc'] = 0x20A3;
  10420. t['g'] = 0x0067;
  10421. t['gabengali'] = 0x0997;
  10422. t['gacute'] = 0x01F5;
  10423. t['gadeva'] = 0x0917;
  10424. t['gafarabic'] = 0x06AF;
  10425. t['gaffinalarabic'] = 0xFB93;
  10426. t['gafinitialarabic'] = 0xFB94;
  10427. t['gafmedialarabic'] = 0xFB95;
  10428. t['gagujarati'] = 0x0A97;
  10429. t['gagurmukhi'] = 0x0A17;
  10430. t['gahiragana'] = 0x304C;
  10431. t['gakatakana'] = 0x30AC;
  10432. t['gamma'] = 0x03B3;
  10433. t['gammalatinsmall'] = 0x0263;
  10434. t['gammasuperior'] = 0x02E0;
  10435. t['gangiacoptic'] = 0x03EB;
  10436. t['gbopomofo'] = 0x310D;
  10437. t['gbreve'] = 0x011F;
  10438. t['gcaron'] = 0x01E7;
  10439. t['gcedilla'] = 0x0123;
  10440. t['gcircle'] = 0x24D6;
  10441. t['gcircumflex'] = 0x011D;
  10442. t['gcommaaccent'] = 0x0123;
  10443. t['gdot'] = 0x0121;
  10444. t['gdotaccent'] = 0x0121;
  10445. t['gecyrillic'] = 0x0433;
  10446. t['gehiragana'] = 0x3052;
  10447. t['gekatakana'] = 0x30B2;
  10448. t['geometricallyequal'] = 0x2251;
  10449. t['gereshaccenthebrew'] = 0x059C;
  10450. t['gereshhebrew'] = 0x05F3;
  10451. t['gereshmuqdamhebrew'] = 0x059D;
  10452. t['germandbls'] = 0x00DF;
  10453. t['gershayimaccenthebrew'] = 0x059E;
  10454. t['gershayimhebrew'] = 0x05F4;
  10455. t['getamark'] = 0x3013;
  10456. t['ghabengali'] = 0x0998;
  10457. t['ghadarmenian'] = 0x0572;
  10458. t['ghadeva'] = 0x0918;
  10459. t['ghagujarati'] = 0x0A98;
  10460. t['ghagurmukhi'] = 0x0A18;
  10461. t['ghainarabic'] = 0x063A;
  10462. t['ghainfinalarabic'] = 0xFECE;
  10463. t['ghaininitialarabic'] = 0xFECF;
  10464. t['ghainmedialarabic'] = 0xFED0;
  10465. t['ghemiddlehookcyrillic'] = 0x0495;
  10466. t['ghestrokecyrillic'] = 0x0493;
  10467. t['gheupturncyrillic'] = 0x0491;
  10468. t['ghhadeva'] = 0x095A;
  10469. t['ghhagurmukhi'] = 0x0A5A;
  10470. t['ghook'] = 0x0260;
  10471. t['ghzsquare'] = 0x3393;
  10472. t['gihiragana'] = 0x304E;
  10473. t['gikatakana'] = 0x30AE;
  10474. t['gimarmenian'] = 0x0563;
  10475. t['gimel'] = 0x05D2;
  10476. t['gimeldagesh'] = 0xFB32;
  10477. t['gimeldageshhebrew'] = 0xFB32;
  10478. t['gimelhebrew'] = 0x05D2;
  10479. t['gjecyrillic'] = 0x0453;
  10480. t['glottalinvertedstroke'] = 0x01BE;
  10481. t['glottalstop'] = 0x0294;
  10482. t['glottalstopinverted'] = 0x0296;
  10483. t['glottalstopmod'] = 0x02C0;
  10484. t['glottalstopreversed'] = 0x0295;
  10485. t['glottalstopreversedmod'] = 0x02C1;
  10486. t['glottalstopreversedsuperior'] = 0x02E4;
  10487. t['glottalstopstroke'] = 0x02A1;
  10488. t['glottalstopstrokereversed'] = 0x02A2;
  10489. t['gmacron'] = 0x1E21;
  10490. t['gmonospace'] = 0xFF47;
  10491. t['gohiragana'] = 0x3054;
  10492. t['gokatakana'] = 0x30B4;
  10493. t['gparen'] = 0x24A2;
  10494. t['gpasquare'] = 0x33AC;
  10495. t['gradient'] = 0x2207;
  10496. t['grave'] = 0x0060;
  10497. t['gravebelowcmb'] = 0x0316;
  10498. t['gravecmb'] = 0x0300;
  10499. t['gravecomb'] = 0x0300;
  10500. t['gravedeva'] = 0x0953;
  10501. t['gravelowmod'] = 0x02CE;
  10502. t['gravemonospace'] = 0xFF40;
  10503. t['gravetonecmb'] = 0x0340;
  10504. t['greater'] = 0x003E;
  10505. t['greaterequal'] = 0x2265;
  10506. t['greaterequalorless'] = 0x22DB;
  10507. t['greatermonospace'] = 0xFF1E;
  10508. t['greaterorequivalent'] = 0x2273;
  10509. t['greaterorless'] = 0x2277;
  10510. t['greateroverequal'] = 0x2267;
  10511. t['greatersmall'] = 0xFE65;
  10512. t['gscript'] = 0x0261;
  10513. t['gstroke'] = 0x01E5;
  10514. t['guhiragana'] = 0x3050;
  10515. t['guillemotleft'] = 0x00AB;
  10516. t['guillemotright'] = 0x00BB;
  10517. t['guilsinglleft'] = 0x2039;
  10518. t['guilsinglright'] = 0x203A;
  10519. t['gukatakana'] = 0x30B0;
  10520. t['guramusquare'] = 0x3318;
  10521. t['gysquare'] = 0x33C9;
  10522. t['h'] = 0x0068;
  10523. t['haabkhasiancyrillic'] = 0x04A9;
  10524. t['haaltonearabic'] = 0x06C1;
  10525. t['habengali'] = 0x09B9;
  10526. t['hadescendercyrillic'] = 0x04B3;
  10527. t['hadeva'] = 0x0939;
  10528. t['hagujarati'] = 0x0AB9;
  10529. t['hagurmukhi'] = 0x0A39;
  10530. t['haharabic'] = 0x062D;
  10531. t['hahfinalarabic'] = 0xFEA2;
  10532. t['hahinitialarabic'] = 0xFEA3;
  10533. t['hahiragana'] = 0x306F;
  10534. t['hahmedialarabic'] = 0xFEA4;
  10535. t['haitusquare'] = 0x332A;
  10536. t['hakatakana'] = 0x30CF;
  10537. t['hakatakanahalfwidth'] = 0xFF8A;
  10538. t['halantgurmukhi'] = 0x0A4D;
  10539. t['hamzaarabic'] = 0x0621;
  10540. t['hamzalowarabic'] = 0x0621;
  10541. t['hangulfiller'] = 0x3164;
  10542. t['hardsigncyrillic'] = 0x044A;
  10543. t['harpoonleftbarbup'] = 0x21BC;
  10544. t['harpoonrightbarbup'] = 0x21C0;
  10545. t['hasquare'] = 0x33CA;
  10546. t['hatafpatah'] = 0x05B2;
  10547. t['hatafpatah16'] = 0x05B2;
  10548. t['hatafpatah23'] = 0x05B2;
  10549. t['hatafpatah2f'] = 0x05B2;
  10550. t['hatafpatahhebrew'] = 0x05B2;
  10551. t['hatafpatahnarrowhebrew'] = 0x05B2;
  10552. t['hatafpatahquarterhebrew'] = 0x05B2;
  10553. t['hatafpatahwidehebrew'] = 0x05B2;
  10554. t['hatafqamats'] = 0x05B3;
  10555. t['hatafqamats1b'] = 0x05B3;
  10556. t['hatafqamats28'] = 0x05B3;
  10557. t['hatafqamats34'] = 0x05B3;
  10558. t['hatafqamatshebrew'] = 0x05B3;
  10559. t['hatafqamatsnarrowhebrew'] = 0x05B3;
  10560. t['hatafqamatsquarterhebrew'] = 0x05B3;
  10561. t['hatafqamatswidehebrew'] = 0x05B3;
  10562. t['hatafsegol'] = 0x05B1;
  10563. t['hatafsegol17'] = 0x05B1;
  10564. t['hatafsegol24'] = 0x05B1;
  10565. t['hatafsegol30'] = 0x05B1;
  10566. t['hatafsegolhebrew'] = 0x05B1;
  10567. t['hatafsegolnarrowhebrew'] = 0x05B1;
  10568. t['hatafsegolquarterhebrew'] = 0x05B1;
  10569. t['hatafsegolwidehebrew'] = 0x05B1;
  10570. t['hbar'] = 0x0127;
  10571. t['hbopomofo'] = 0x310F;
  10572. t['hbrevebelow'] = 0x1E2B;
  10573. t['hcedilla'] = 0x1E29;
  10574. t['hcircle'] = 0x24D7;
  10575. t['hcircumflex'] = 0x0125;
  10576. t['hdieresis'] = 0x1E27;
  10577. t['hdotaccent'] = 0x1E23;
  10578. t['hdotbelow'] = 0x1E25;
  10579. t['he'] = 0x05D4;
  10580. t['heart'] = 0x2665;
  10581. t['heartsuitblack'] = 0x2665;
  10582. t['heartsuitwhite'] = 0x2661;
  10583. t['hedagesh'] = 0xFB34;
  10584. t['hedageshhebrew'] = 0xFB34;
  10585. t['hehaltonearabic'] = 0x06C1;
  10586. t['heharabic'] = 0x0647;
  10587. t['hehebrew'] = 0x05D4;
  10588. t['hehfinalaltonearabic'] = 0xFBA7;
  10589. t['hehfinalalttwoarabic'] = 0xFEEA;
  10590. t['hehfinalarabic'] = 0xFEEA;
  10591. t['hehhamzaabovefinalarabic'] = 0xFBA5;
  10592. t['hehhamzaaboveisolatedarabic'] = 0xFBA4;
  10593. t['hehinitialaltonearabic'] = 0xFBA8;
  10594. t['hehinitialarabic'] = 0xFEEB;
  10595. t['hehiragana'] = 0x3078;
  10596. t['hehmedialaltonearabic'] = 0xFBA9;
  10597. t['hehmedialarabic'] = 0xFEEC;
  10598. t['heiseierasquare'] = 0x337B;
  10599. t['hekatakana'] = 0x30D8;
  10600. t['hekatakanahalfwidth'] = 0xFF8D;
  10601. t['hekutaarusquare'] = 0x3336;
  10602. t['henghook'] = 0x0267;
  10603. t['herutusquare'] = 0x3339;
  10604. t['het'] = 0x05D7;
  10605. t['hethebrew'] = 0x05D7;
  10606. t['hhook'] = 0x0266;
  10607. t['hhooksuperior'] = 0x02B1;
  10608. t['hieuhacirclekorean'] = 0x327B;
  10609. t['hieuhaparenkorean'] = 0x321B;
  10610. t['hieuhcirclekorean'] = 0x326D;
  10611. t['hieuhkorean'] = 0x314E;
  10612. t['hieuhparenkorean'] = 0x320D;
  10613. t['hihiragana'] = 0x3072;
  10614. t['hikatakana'] = 0x30D2;
  10615. t['hikatakanahalfwidth'] = 0xFF8B;
  10616. t['hiriq'] = 0x05B4;
  10617. t['hiriq14'] = 0x05B4;
  10618. t['hiriq21'] = 0x05B4;
  10619. t['hiriq2d'] = 0x05B4;
  10620. t['hiriqhebrew'] = 0x05B4;
  10621. t['hiriqnarrowhebrew'] = 0x05B4;
  10622. t['hiriqquarterhebrew'] = 0x05B4;
  10623. t['hiriqwidehebrew'] = 0x05B4;
  10624. t['hlinebelow'] = 0x1E96;
  10625. t['hmonospace'] = 0xFF48;
  10626. t['hoarmenian'] = 0x0570;
  10627. t['hohipthai'] = 0x0E2B;
  10628. t['hohiragana'] = 0x307B;
  10629. t['hokatakana'] = 0x30DB;
  10630. t['hokatakanahalfwidth'] = 0xFF8E;
  10631. t['holam'] = 0x05B9;
  10632. t['holam19'] = 0x05B9;
  10633. t['holam26'] = 0x05B9;
  10634. t['holam32'] = 0x05B9;
  10635. t['holamhebrew'] = 0x05B9;
  10636. t['holamnarrowhebrew'] = 0x05B9;
  10637. t['holamquarterhebrew'] = 0x05B9;
  10638. t['holamwidehebrew'] = 0x05B9;
  10639. t['honokhukthai'] = 0x0E2E;
  10640. t['hookabovecomb'] = 0x0309;
  10641. t['hookcmb'] = 0x0309;
  10642. t['hookpalatalizedbelowcmb'] = 0x0321;
  10643. t['hookretroflexbelowcmb'] = 0x0322;
  10644. t['hoonsquare'] = 0x3342;
  10645. t['horicoptic'] = 0x03E9;
  10646. t['horizontalbar'] = 0x2015;
  10647. t['horncmb'] = 0x031B;
  10648. t['hotsprings'] = 0x2668;
  10649. t['house'] = 0x2302;
  10650. t['hparen'] = 0x24A3;
  10651. t['hsuperior'] = 0x02B0;
  10652. t['hturned'] = 0x0265;
  10653. t['huhiragana'] = 0x3075;
  10654. t['huiitosquare'] = 0x3333;
  10655. t['hukatakana'] = 0x30D5;
  10656. t['hukatakanahalfwidth'] = 0xFF8C;
  10657. t['hungarumlaut'] = 0x02DD;
  10658. t['hungarumlautcmb'] = 0x030B;
  10659. t['hv'] = 0x0195;
  10660. t['hyphen'] = 0x002D;
  10661. t['hypheninferior'] = 0xF6E5;
  10662. t['hyphenmonospace'] = 0xFF0D;
  10663. t['hyphensmall'] = 0xFE63;
  10664. t['hyphensuperior'] = 0xF6E6;
  10665. t['hyphentwo'] = 0x2010;
  10666. t['i'] = 0x0069;
  10667. t['iacute'] = 0x00ED;
  10668. t['iacyrillic'] = 0x044F;
  10669. t['ibengali'] = 0x0987;
  10670. t['ibopomofo'] = 0x3127;
  10671. t['ibreve'] = 0x012D;
  10672. t['icaron'] = 0x01D0;
  10673. t['icircle'] = 0x24D8;
  10674. t['icircumflex'] = 0x00EE;
  10675. t['icyrillic'] = 0x0456;
  10676. t['idblgrave'] = 0x0209;
  10677. t['ideographearthcircle'] = 0x328F;
  10678. t['ideographfirecircle'] = 0x328B;
  10679. t['ideographicallianceparen'] = 0x323F;
  10680. t['ideographiccallparen'] = 0x323A;
  10681. t['ideographiccentrecircle'] = 0x32A5;
  10682. t['ideographicclose'] = 0x3006;
  10683. t['ideographiccomma'] = 0x3001;
  10684. t['ideographiccommaleft'] = 0xFF64;
  10685. t['ideographiccongratulationparen'] = 0x3237;
  10686. t['ideographiccorrectcircle'] = 0x32A3;
  10687. t['ideographicearthparen'] = 0x322F;
  10688. t['ideographicenterpriseparen'] = 0x323D;
  10689. t['ideographicexcellentcircle'] = 0x329D;
  10690. t['ideographicfestivalparen'] = 0x3240;
  10691. t['ideographicfinancialcircle'] = 0x3296;
  10692. t['ideographicfinancialparen'] = 0x3236;
  10693. t['ideographicfireparen'] = 0x322B;
  10694. t['ideographichaveparen'] = 0x3232;
  10695. t['ideographichighcircle'] = 0x32A4;
  10696. t['ideographiciterationmark'] = 0x3005;
  10697. t['ideographiclaborcircle'] = 0x3298;
  10698. t['ideographiclaborparen'] = 0x3238;
  10699. t['ideographicleftcircle'] = 0x32A7;
  10700. t['ideographiclowcircle'] = 0x32A6;
  10701. t['ideographicmedicinecircle'] = 0x32A9;
  10702. t['ideographicmetalparen'] = 0x322E;
  10703. t['ideographicmoonparen'] = 0x322A;
  10704. t['ideographicnameparen'] = 0x3234;
  10705. t['ideographicperiod'] = 0x3002;
  10706. t['ideographicprintcircle'] = 0x329E;
  10707. t['ideographicreachparen'] = 0x3243;
  10708. t['ideographicrepresentparen'] = 0x3239;
  10709. t['ideographicresourceparen'] = 0x323E;
  10710. t['ideographicrightcircle'] = 0x32A8;
  10711. t['ideographicsecretcircle'] = 0x3299;
  10712. t['ideographicselfparen'] = 0x3242;
  10713. t['ideographicsocietyparen'] = 0x3233;
  10714. t['ideographicspace'] = 0x3000;
  10715. t['ideographicspecialparen'] = 0x3235;
  10716. t['ideographicstockparen'] = 0x3231;
  10717. t['ideographicstudyparen'] = 0x323B;
  10718. t['ideographicsunparen'] = 0x3230;
  10719. t['ideographicsuperviseparen'] = 0x323C;
  10720. t['ideographicwaterparen'] = 0x322C;
  10721. t['ideographicwoodparen'] = 0x322D;
  10722. t['ideographiczero'] = 0x3007;
  10723. t['ideographmetalcircle'] = 0x328E;
  10724. t['ideographmooncircle'] = 0x328A;
  10725. t['ideographnamecircle'] = 0x3294;
  10726. t['ideographsuncircle'] = 0x3290;
  10727. t['ideographwatercircle'] = 0x328C;
  10728. t['ideographwoodcircle'] = 0x328D;
  10729. t['ideva'] = 0x0907;
  10730. t['idieresis'] = 0x00EF;
  10731. t['idieresisacute'] = 0x1E2F;
  10732. t['idieresiscyrillic'] = 0x04E5;
  10733. t['idotbelow'] = 0x1ECB;
  10734. t['iebrevecyrillic'] = 0x04D7;
  10735. t['iecyrillic'] = 0x0435;
  10736. t['ieungacirclekorean'] = 0x3275;
  10737. t['ieungaparenkorean'] = 0x3215;
  10738. t['ieungcirclekorean'] = 0x3267;
  10739. t['ieungkorean'] = 0x3147;
  10740. t['ieungparenkorean'] = 0x3207;
  10741. t['igrave'] = 0x00EC;
  10742. t['igujarati'] = 0x0A87;
  10743. t['igurmukhi'] = 0x0A07;
  10744. t['ihiragana'] = 0x3044;
  10745. t['ihookabove'] = 0x1EC9;
  10746. t['iibengali'] = 0x0988;
  10747. t['iicyrillic'] = 0x0438;
  10748. t['iideva'] = 0x0908;
  10749. t['iigujarati'] = 0x0A88;
  10750. t['iigurmukhi'] = 0x0A08;
  10751. t['iimatragurmukhi'] = 0x0A40;
  10752. t['iinvertedbreve'] = 0x020B;
  10753. t['iishortcyrillic'] = 0x0439;
  10754. t['iivowelsignbengali'] = 0x09C0;
  10755. t['iivowelsigndeva'] = 0x0940;
  10756. t['iivowelsigngujarati'] = 0x0AC0;
  10757. t['ij'] = 0x0133;
  10758. t['ikatakana'] = 0x30A4;
  10759. t['ikatakanahalfwidth'] = 0xFF72;
  10760. t['ikorean'] = 0x3163;
  10761. t['ilde'] = 0x02DC;
  10762. t['iluyhebrew'] = 0x05AC;
  10763. t['imacron'] = 0x012B;
  10764. t['imacroncyrillic'] = 0x04E3;
  10765. t['imageorapproximatelyequal'] = 0x2253;
  10766. t['imatragurmukhi'] = 0x0A3F;
  10767. t['imonospace'] = 0xFF49;
  10768. t['increment'] = 0x2206;
  10769. t['infinity'] = 0x221E;
  10770. t['iniarmenian'] = 0x056B;
  10771. t['integral'] = 0x222B;
  10772. t['integralbottom'] = 0x2321;
  10773. t['integralbt'] = 0x2321;
  10774. t['integralex'] = 0xF8F5;
  10775. t['integraltop'] = 0x2320;
  10776. t['integraltp'] = 0x2320;
  10777. t['intersection'] = 0x2229;
  10778. t['intisquare'] = 0x3305;
  10779. t['invbullet'] = 0x25D8;
  10780. t['invcircle'] = 0x25D9;
  10781. t['invsmileface'] = 0x263B;
  10782. t['iocyrillic'] = 0x0451;
  10783. t['iogonek'] = 0x012F;
  10784. t['iota'] = 0x03B9;
  10785. t['iotadieresis'] = 0x03CA;
  10786. t['iotadieresistonos'] = 0x0390;
  10787. t['iotalatin'] = 0x0269;
  10788. t['iotatonos'] = 0x03AF;
  10789. t['iparen'] = 0x24A4;
  10790. t['irigurmukhi'] = 0x0A72;
  10791. t['ismallhiragana'] = 0x3043;
  10792. t['ismallkatakana'] = 0x30A3;
  10793. t['ismallkatakanahalfwidth'] = 0xFF68;
  10794. t['issharbengali'] = 0x09FA;
  10795. t['istroke'] = 0x0268;
  10796. t['isuperior'] = 0xF6ED;
  10797. t['iterationhiragana'] = 0x309D;
  10798. t['iterationkatakana'] = 0x30FD;
  10799. t['itilde'] = 0x0129;
  10800. t['itildebelow'] = 0x1E2D;
  10801. t['iubopomofo'] = 0x3129;
  10802. t['iucyrillic'] = 0x044E;
  10803. t['ivowelsignbengali'] = 0x09BF;
  10804. t['ivowelsigndeva'] = 0x093F;
  10805. t['ivowelsigngujarati'] = 0x0ABF;
  10806. t['izhitsacyrillic'] = 0x0475;
  10807. t['izhitsadblgravecyrillic'] = 0x0477;
  10808. t['j'] = 0x006A;
  10809. t['jaarmenian'] = 0x0571;
  10810. t['jabengali'] = 0x099C;
  10811. t['jadeva'] = 0x091C;
  10812. t['jagujarati'] = 0x0A9C;
  10813. t['jagurmukhi'] = 0x0A1C;
  10814. t['jbopomofo'] = 0x3110;
  10815. t['jcaron'] = 0x01F0;
  10816. t['jcircle'] = 0x24D9;
  10817. t['jcircumflex'] = 0x0135;
  10818. t['jcrossedtail'] = 0x029D;
  10819. t['jdotlessstroke'] = 0x025F;
  10820. t['jecyrillic'] = 0x0458;
  10821. t['jeemarabic'] = 0x062C;
  10822. t['jeemfinalarabic'] = 0xFE9E;
  10823. t['jeeminitialarabic'] = 0xFE9F;
  10824. t['jeemmedialarabic'] = 0xFEA0;
  10825. t['jeharabic'] = 0x0698;
  10826. t['jehfinalarabic'] = 0xFB8B;
  10827. t['jhabengali'] = 0x099D;
  10828. t['jhadeva'] = 0x091D;
  10829. t['jhagujarati'] = 0x0A9D;
  10830. t['jhagurmukhi'] = 0x0A1D;
  10831. t['jheharmenian'] = 0x057B;
  10832. t['jis'] = 0x3004;
  10833. t['jmonospace'] = 0xFF4A;
  10834. t['jparen'] = 0x24A5;
  10835. t['jsuperior'] = 0x02B2;
  10836. t['k'] = 0x006B;
  10837. t['kabashkircyrillic'] = 0x04A1;
  10838. t['kabengali'] = 0x0995;
  10839. t['kacute'] = 0x1E31;
  10840. t['kacyrillic'] = 0x043A;
  10841. t['kadescendercyrillic'] = 0x049B;
  10842. t['kadeva'] = 0x0915;
  10843. t['kaf'] = 0x05DB;
  10844. t['kafarabic'] = 0x0643;
  10845. t['kafdagesh'] = 0xFB3B;
  10846. t['kafdageshhebrew'] = 0xFB3B;
  10847. t['kaffinalarabic'] = 0xFEDA;
  10848. t['kafhebrew'] = 0x05DB;
  10849. t['kafinitialarabic'] = 0xFEDB;
  10850. t['kafmedialarabic'] = 0xFEDC;
  10851. t['kafrafehebrew'] = 0xFB4D;
  10852. t['kagujarati'] = 0x0A95;
  10853. t['kagurmukhi'] = 0x0A15;
  10854. t['kahiragana'] = 0x304B;
  10855. t['kahookcyrillic'] = 0x04C4;
  10856. t['kakatakana'] = 0x30AB;
  10857. t['kakatakanahalfwidth'] = 0xFF76;
  10858. t['kappa'] = 0x03BA;
  10859. t['kappasymbolgreek'] = 0x03F0;
  10860. t['kapyeounmieumkorean'] = 0x3171;
  10861. t['kapyeounphieuphkorean'] = 0x3184;
  10862. t['kapyeounpieupkorean'] = 0x3178;
  10863. t['kapyeounssangpieupkorean'] = 0x3179;
  10864. t['karoriisquare'] = 0x330D;
  10865. t['kashidaautoarabic'] = 0x0640;
  10866. t['kashidaautonosidebearingarabic'] = 0x0640;
  10867. t['kasmallkatakana'] = 0x30F5;
  10868. t['kasquare'] = 0x3384;
  10869. t['kasraarabic'] = 0x0650;
  10870. t['kasratanarabic'] = 0x064D;
  10871. t['kastrokecyrillic'] = 0x049F;
  10872. t['katahiraprolongmarkhalfwidth'] = 0xFF70;
  10873. t['kaverticalstrokecyrillic'] = 0x049D;
  10874. t['kbopomofo'] = 0x310E;
  10875. t['kcalsquare'] = 0x3389;
  10876. t['kcaron'] = 0x01E9;
  10877. t['kcedilla'] = 0x0137;
  10878. t['kcircle'] = 0x24DA;
  10879. t['kcommaaccent'] = 0x0137;
  10880. t['kdotbelow'] = 0x1E33;
  10881. t['keharmenian'] = 0x0584;
  10882. t['kehiragana'] = 0x3051;
  10883. t['kekatakana'] = 0x30B1;
  10884. t['kekatakanahalfwidth'] = 0xFF79;
  10885. t['kenarmenian'] = 0x056F;
  10886. t['kesmallkatakana'] = 0x30F6;
  10887. t['kgreenlandic'] = 0x0138;
  10888. t['khabengali'] = 0x0996;
  10889. t['khacyrillic'] = 0x0445;
  10890. t['khadeva'] = 0x0916;
  10891. t['khagujarati'] = 0x0A96;
  10892. t['khagurmukhi'] = 0x0A16;
  10893. t['khaharabic'] = 0x062E;
  10894. t['khahfinalarabic'] = 0xFEA6;
  10895. t['khahinitialarabic'] = 0xFEA7;
  10896. t['khahmedialarabic'] = 0xFEA8;
  10897. t['kheicoptic'] = 0x03E7;
  10898. t['khhadeva'] = 0x0959;
  10899. t['khhagurmukhi'] = 0x0A59;
  10900. t['khieukhacirclekorean'] = 0x3278;
  10901. t['khieukhaparenkorean'] = 0x3218;
  10902. t['khieukhcirclekorean'] = 0x326A;
  10903. t['khieukhkorean'] = 0x314B;
  10904. t['khieukhparenkorean'] = 0x320A;
  10905. t['khokhaithai'] = 0x0E02;
  10906. t['khokhonthai'] = 0x0E05;
  10907. t['khokhuatthai'] = 0x0E03;
  10908. t['khokhwaithai'] = 0x0E04;
  10909. t['khomutthai'] = 0x0E5B;
  10910. t['khook'] = 0x0199;
  10911. t['khorakhangthai'] = 0x0E06;
  10912. t['khzsquare'] = 0x3391;
  10913. t['kihiragana'] = 0x304D;
  10914. t['kikatakana'] = 0x30AD;
  10915. t['kikatakanahalfwidth'] = 0xFF77;
  10916. t['kiroguramusquare'] = 0x3315;
  10917. t['kiromeetorusquare'] = 0x3316;
  10918. t['kirosquare'] = 0x3314;
  10919. t['kiyeokacirclekorean'] = 0x326E;
  10920. t['kiyeokaparenkorean'] = 0x320E;
  10921. t['kiyeokcirclekorean'] = 0x3260;
  10922. t['kiyeokkorean'] = 0x3131;
  10923. t['kiyeokparenkorean'] = 0x3200;
  10924. t['kiyeoksioskorean'] = 0x3133;
  10925. t['kjecyrillic'] = 0x045C;
  10926. t['klinebelow'] = 0x1E35;
  10927. t['klsquare'] = 0x3398;
  10928. t['kmcubedsquare'] = 0x33A6;
  10929. t['kmonospace'] = 0xFF4B;
  10930. t['kmsquaredsquare'] = 0x33A2;
  10931. t['kohiragana'] = 0x3053;
  10932. t['kohmsquare'] = 0x33C0;
  10933. t['kokaithai'] = 0x0E01;
  10934. t['kokatakana'] = 0x30B3;
  10935. t['kokatakanahalfwidth'] = 0xFF7A;
  10936. t['kooposquare'] = 0x331E;
  10937. t['koppacyrillic'] = 0x0481;
  10938. t['koreanstandardsymbol'] = 0x327F;
  10939. t['koroniscmb'] = 0x0343;
  10940. t['kparen'] = 0x24A6;
  10941. t['kpasquare'] = 0x33AA;
  10942. t['ksicyrillic'] = 0x046F;
  10943. t['ktsquare'] = 0x33CF;
  10944. t['kturned'] = 0x029E;
  10945. t['kuhiragana'] = 0x304F;
  10946. t['kukatakana'] = 0x30AF;
  10947. t['kukatakanahalfwidth'] = 0xFF78;
  10948. t['kvsquare'] = 0x33B8;
  10949. t['kwsquare'] = 0x33BE;
  10950. t['l'] = 0x006C;
  10951. t['labengali'] = 0x09B2;
  10952. t['lacute'] = 0x013A;
  10953. t['ladeva'] = 0x0932;
  10954. t['lagujarati'] = 0x0AB2;
  10955. t['lagurmukhi'] = 0x0A32;
  10956. t['lakkhangyaothai'] = 0x0E45;
  10957. t['lamaleffinalarabic'] = 0xFEFC;
  10958. t['lamalefhamzaabovefinalarabic'] = 0xFEF8;
  10959. t['lamalefhamzaaboveisolatedarabic'] = 0xFEF7;
  10960. t['lamalefhamzabelowfinalarabic'] = 0xFEFA;
  10961. t['lamalefhamzabelowisolatedarabic'] = 0xFEF9;
  10962. t['lamalefisolatedarabic'] = 0xFEFB;
  10963. t['lamalefmaddaabovefinalarabic'] = 0xFEF6;
  10964. t['lamalefmaddaaboveisolatedarabic'] = 0xFEF5;
  10965. t['lamarabic'] = 0x0644;
  10966. t['lambda'] = 0x03BB;
  10967. t['lambdastroke'] = 0x019B;
  10968. t['lamed'] = 0x05DC;
  10969. t['lameddagesh'] = 0xFB3C;
  10970. t['lameddageshhebrew'] = 0xFB3C;
  10971. t['lamedhebrew'] = 0x05DC;
  10972. t['lamfinalarabic'] = 0xFEDE;
  10973. t['lamhahinitialarabic'] = 0xFCCA;
  10974. t['laminitialarabic'] = 0xFEDF;
  10975. t['lamjeeminitialarabic'] = 0xFCC9;
  10976. t['lamkhahinitialarabic'] = 0xFCCB;
  10977. t['lamlamhehisolatedarabic'] = 0xFDF2;
  10978. t['lammedialarabic'] = 0xFEE0;
  10979. t['lammeemhahinitialarabic'] = 0xFD88;
  10980. t['lammeeminitialarabic'] = 0xFCCC;
  10981. t['largecircle'] = 0x25EF;
  10982. t['lbar'] = 0x019A;
  10983. t['lbelt'] = 0x026C;
  10984. t['lbopomofo'] = 0x310C;
  10985. t['lcaron'] = 0x013E;
  10986. t['lcedilla'] = 0x013C;
  10987. t['lcircle'] = 0x24DB;
  10988. t['lcircumflexbelow'] = 0x1E3D;
  10989. t['lcommaaccent'] = 0x013C;
  10990. t['ldot'] = 0x0140;
  10991. t['ldotaccent'] = 0x0140;
  10992. t['ldotbelow'] = 0x1E37;
  10993. t['ldotbelowmacron'] = 0x1E39;
  10994. t['leftangleabovecmb'] = 0x031A;
  10995. t['lefttackbelowcmb'] = 0x0318;
  10996. t['less'] = 0x003C;
  10997. t['lessequal'] = 0x2264;
  10998. t['lessequalorgreater'] = 0x22DA;
  10999. t['lessmonospace'] = 0xFF1C;
  11000. t['lessorequivalent'] = 0x2272;
  11001. t['lessorgreater'] = 0x2276;
  11002. t['lessoverequal'] = 0x2266;
  11003. t['lesssmall'] = 0xFE64;
  11004. t['lezh'] = 0x026E;
  11005. t['lfblock'] = 0x258C;
  11006. t['lhookretroflex'] = 0x026D;
  11007. t['lira'] = 0x20A4;
  11008. t['liwnarmenian'] = 0x056C;
  11009. t['lj'] = 0x01C9;
  11010. t['ljecyrillic'] = 0x0459;
  11011. t['ll'] = 0xF6C0;
  11012. t['lladeva'] = 0x0933;
  11013. t['llagujarati'] = 0x0AB3;
  11014. t['llinebelow'] = 0x1E3B;
  11015. t['llladeva'] = 0x0934;
  11016. t['llvocalicbengali'] = 0x09E1;
  11017. t['llvocalicdeva'] = 0x0961;
  11018. t['llvocalicvowelsignbengali'] = 0x09E3;
  11019. t['llvocalicvowelsigndeva'] = 0x0963;
  11020. t['lmiddletilde'] = 0x026B;
  11021. t['lmonospace'] = 0xFF4C;
  11022. t['lmsquare'] = 0x33D0;
  11023. t['lochulathai'] = 0x0E2C;
  11024. t['logicaland'] = 0x2227;
  11025. t['logicalnot'] = 0x00AC;
  11026. t['logicalnotreversed'] = 0x2310;
  11027. t['logicalor'] = 0x2228;
  11028. t['lolingthai'] = 0x0E25;
  11029. t['longs'] = 0x017F;
  11030. t['lowlinecenterline'] = 0xFE4E;
  11031. t['lowlinecmb'] = 0x0332;
  11032. t['lowlinedashed'] = 0xFE4D;
  11033. t['lozenge'] = 0x25CA;
  11034. t['lparen'] = 0x24A7;
  11035. t['lslash'] = 0x0142;
  11036. t['lsquare'] = 0x2113;
  11037. t['lsuperior'] = 0xF6EE;
  11038. t['ltshade'] = 0x2591;
  11039. t['luthai'] = 0x0E26;
  11040. t['lvocalicbengali'] = 0x098C;
  11041. t['lvocalicdeva'] = 0x090C;
  11042. t['lvocalicvowelsignbengali'] = 0x09E2;
  11043. t['lvocalicvowelsigndeva'] = 0x0962;
  11044. t['lxsquare'] = 0x33D3;
  11045. t['m'] = 0x006D;
  11046. t['mabengali'] = 0x09AE;
  11047. t['macron'] = 0x00AF;
  11048. t['macronbelowcmb'] = 0x0331;
  11049. t['macroncmb'] = 0x0304;
  11050. t['macronlowmod'] = 0x02CD;
  11051. t['macronmonospace'] = 0xFFE3;
  11052. t['macute'] = 0x1E3F;
  11053. t['madeva'] = 0x092E;
  11054. t['magujarati'] = 0x0AAE;
  11055. t['magurmukhi'] = 0x0A2E;
  11056. t['mahapakhhebrew'] = 0x05A4;
  11057. t['mahapakhlefthebrew'] = 0x05A4;
  11058. t['mahiragana'] = 0x307E;
  11059. t['maichattawalowleftthai'] = 0xF895;
  11060. t['maichattawalowrightthai'] = 0xF894;
  11061. t['maichattawathai'] = 0x0E4B;
  11062. t['maichattawaupperleftthai'] = 0xF893;
  11063. t['maieklowleftthai'] = 0xF88C;
  11064. t['maieklowrightthai'] = 0xF88B;
  11065. t['maiekthai'] = 0x0E48;
  11066. t['maiekupperleftthai'] = 0xF88A;
  11067. t['maihanakatleftthai'] = 0xF884;
  11068. t['maihanakatthai'] = 0x0E31;
  11069. t['maitaikhuleftthai'] = 0xF889;
  11070. t['maitaikhuthai'] = 0x0E47;
  11071. t['maitholowleftthai'] = 0xF88F;
  11072. t['maitholowrightthai'] = 0xF88E;
  11073. t['maithothai'] = 0x0E49;
  11074. t['maithoupperleftthai'] = 0xF88D;
  11075. t['maitrilowleftthai'] = 0xF892;
  11076. t['maitrilowrightthai'] = 0xF891;
  11077. t['maitrithai'] = 0x0E4A;
  11078. t['maitriupperleftthai'] = 0xF890;
  11079. t['maiyamokthai'] = 0x0E46;
  11080. t['makatakana'] = 0x30DE;
  11081. t['makatakanahalfwidth'] = 0xFF8F;
  11082. t['male'] = 0x2642;
  11083. t['mansyonsquare'] = 0x3347;
  11084. t['maqafhebrew'] = 0x05BE;
  11085. t['mars'] = 0x2642;
  11086. t['masoracirclehebrew'] = 0x05AF;
  11087. t['masquare'] = 0x3383;
  11088. t['mbopomofo'] = 0x3107;
  11089. t['mbsquare'] = 0x33D4;
  11090. t['mcircle'] = 0x24DC;
  11091. t['mcubedsquare'] = 0x33A5;
  11092. t['mdotaccent'] = 0x1E41;
  11093. t['mdotbelow'] = 0x1E43;
  11094. t['meemarabic'] = 0x0645;
  11095. t['meemfinalarabic'] = 0xFEE2;
  11096. t['meeminitialarabic'] = 0xFEE3;
  11097. t['meemmedialarabic'] = 0xFEE4;
  11098. t['meemmeeminitialarabic'] = 0xFCD1;
  11099. t['meemmeemisolatedarabic'] = 0xFC48;
  11100. t['meetorusquare'] = 0x334D;
  11101. t['mehiragana'] = 0x3081;
  11102. t['meizierasquare'] = 0x337E;
  11103. t['mekatakana'] = 0x30E1;
  11104. t['mekatakanahalfwidth'] = 0xFF92;
  11105. t['mem'] = 0x05DE;
  11106. t['memdagesh'] = 0xFB3E;
  11107. t['memdageshhebrew'] = 0xFB3E;
  11108. t['memhebrew'] = 0x05DE;
  11109. t['menarmenian'] = 0x0574;
  11110. t['merkhahebrew'] = 0x05A5;
  11111. t['merkhakefulahebrew'] = 0x05A6;
  11112. t['merkhakefulalefthebrew'] = 0x05A6;
  11113. t['merkhalefthebrew'] = 0x05A5;
  11114. t['mhook'] = 0x0271;
  11115. t['mhzsquare'] = 0x3392;
  11116. t['middledotkatakanahalfwidth'] = 0xFF65;
  11117. t['middot'] = 0x00B7;
  11118. t['mieumacirclekorean'] = 0x3272;
  11119. t['mieumaparenkorean'] = 0x3212;
  11120. t['mieumcirclekorean'] = 0x3264;
  11121. t['mieumkorean'] = 0x3141;
  11122. t['mieumpansioskorean'] = 0x3170;
  11123. t['mieumparenkorean'] = 0x3204;
  11124. t['mieumpieupkorean'] = 0x316E;
  11125. t['mieumsioskorean'] = 0x316F;
  11126. t['mihiragana'] = 0x307F;
  11127. t['mikatakana'] = 0x30DF;
  11128. t['mikatakanahalfwidth'] = 0xFF90;
  11129. t['minus'] = 0x2212;
  11130. t['minusbelowcmb'] = 0x0320;
  11131. t['minuscircle'] = 0x2296;
  11132. t['minusmod'] = 0x02D7;
  11133. t['minusplus'] = 0x2213;
  11134. t['minute'] = 0x2032;
  11135. t['miribaarusquare'] = 0x334A;
  11136. t['mirisquare'] = 0x3349;
  11137. t['mlonglegturned'] = 0x0270;
  11138. t['mlsquare'] = 0x3396;
  11139. t['mmcubedsquare'] = 0x33A3;
  11140. t['mmonospace'] = 0xFF4D;
  11141. t['mmsquaredsquare'] = 0x339F;
  11142. t['mohiragana'] = 0x3082;
  11143. t['mohmsquare'] = 0x33C1;
  11144. t['mokatakana'] = 0x30E2;
  11145. t['mokatakanahalfwidth'] = 0xFF93;
  11146. t['molsquare'] = 0x33D6;
  11147. t['momathai'] = 0x0E21;
  11148. t['moverssquare'] = 0x33A7;
  11149. t['moverssquaredsquare'] = 0x33A8;
  11150. t['mparen'] = 0x24A8;
  11151. t['mpasquare'] = 0x33AB;
  11152. t['mssquare'] = 0x33B3;
  11153. t['msuperior'] = 0xF6EF;
  11154. t['mturned'] = 0x026F;
  11155. t['mu'] = 0x00B5;
  11156. t['mu1'] = 0x00B5;
  11157. t['muasquare'] = 0x3382;
  11158. t['muchgreater'] = 0x226B;
  11159. t['muchless'] = 0x226A;
  11160. t['mufsquare'] = 0x338C;
  11161. t['mugreek'] = 0x03BC;
  11162. t['mugsquare'] = 0x338D;
  11163. t['muhiragana'] = 0x3080;
  11164. t['mukatakana'] = 0x30E0;
  11165. t['mukatakanahalfwidth'] = 0xFF91;
  11166. t['mulsquare'] = 0x3395;
  11167. t['multiply'] = 0x00D7;
  11168. t['mumsquare'] = 0x339B;
  11169. t['munahhebrew'] = 0x05A3;
  11170. t['munahlefthebrew'] = 0x05A3;
  11171. t['musicalnote'] = 0x266A;
  11172. t['musicalnotedbl'] = 0x266B;
  11173. t['musicflatsign'] = 0x266D;
  11174. t['musicsharpsign'] = 0x266F;
  11175. t['mussquare'] = 0x33B2;
  11176. t['muvsquare'] = 0x33B6;
  11177. t['muwsquare'] = 0x33BC;
  11178. t['mvmegasquare'] = 0x33B9;
  11179. t['mvsquare'] = 0x33B7;
  11180. t['mwmegasquare'] = 0x33BF;
  11181. t['mwsquare'] = 0x33BD;
  11182. t['n'] = 0x006E;
  11183. t['nabengali'] = 0x09A8;
  11184. t['nabla'] = 0x2207;
  11185. t['nacute'] = 0x0144;
  11186. t['nadeva'] = 0x0928;
  11187. t['nagujarati'] = 0x0AA8;
  11188. t['nagurmukhi'] = 0x0A28;
  11189. t['nahiragana'] = 0x306A;
  11190. t['nakatakana'] = 0x30CA;
  11191. t['nakatakanahalfwidth'] = 0xFF85;
  11192. t['napostrophe'] = 0x0149;
  11193. t['nasquare'] = 0x3381;
  11194. t['nbopomofo'] = 0x310B;
  11195. t['nbspace'] = 0x00A0;
  11196. t['ncaron'] = 0x0148;
  11197. t['ncedilla'] = 0x0146;
  11198. t['ncircle'] = 0x24DD;
  11199. t['ncircumflexbelow'] = 0x1E4B;
  11200. t['ncommaaccent'] = 0x0146;
  11201. t['ndotaccent'] = 0x1E45;
  11202. t['ndotbelow'] = 0x1E47;
  11203. t['nehiragana'] = 0x306D;
  11204. t['nekatakana'] = 0x30CD;
  11205. t['nekatakanahalfwidth'] = 0xFF88;
  11206. t['newsheqelsign'] = 0x20AA;
  11207. t['nfsquare'] = 0x338B;
  11208. t['ngabengali'] = 0x0999;
  11209. t['ngadeva'] = 0x0919;
  11210. t['ngagujarati'] = 0x0A99;
  11211. t['ngagurmukhi'] = 0x0A19;
  11212. t['ngonguthai'] = 0x0E07;
  11213. t['nhiragana'] = 0x3093;
  11214. t['nhookleft'] = 0x0272;
  11215. t['nhookretroflex'] = 0x0273;
  11216. t['nieunacirclekorean'] = 0x326F;
  11217. t['nieunaparenkorean'] = 0x320F;
  11218. t['nieuncieuckorean'] = 0x3135;
  11219. t['nieuncirclekorean'] = 0x3261;
  11220. t['nieunhieuhkorean'] = 0x3136;
  11221. t['nieunkorean'] = 0x3134;
  11222. t['nieunpansioskorean'] = 0x3168;
  11223. t['nieunparenkorean'] = 0x3201;
  11224. t['nieunsioskorean'] = 0x3167;
  11225. t['nieuntikeutkorean'] = 0x3166;
  11226. t['nihiragana'] = 0x306B;
  11227. t['nikatakana'] = 0x30CB;
  11228. t['nikatakanahalfwidth'] = 0xFF86;
  11229. t['nikhahitleftthai'] = 0xF899;
  11230. t['nikhahitthai'] = 0x0E4D;
  11231. t['nine'] = 0x0039;
  11232. t['ninearabic'] = 0x0669;
  11233. t['ninebengali'] = 0x09EF;
  11234. t['ninecircle'] = 0x2468;
  11235. t['ninecircleinversesansserif'] = 0x2792;
  11236. t['ninedeva'] = 0x096F;
  11237. t['ninegujarati'] = 0x0AEF;
  11238. t['ninegurmukhi'] = 0x0A6F;
  11239. t['ninehackarabic'] = 0x0669;
  11240. t['ninehangzhou'] = 0x3029;
  11241. t['nineideographicparen'] = 0x3228;
  11242. t['nineinferior'] = 0x2089;
  11243. t['ninemonospace'] = 0xFF19;
  11244. t['nineoldstyle'] = 0xF739;
  11245. t['nineparen'] = 0x247C;
  11246. t['nineperiod'] = 0x2490;
  11247. t['ninepersian'] = 0x06F9;
  11248. t['nineroman'] = 0x2178;
  11249. t['ninesuperior'] = 0x2079;
  11250. t['nineteencircle'] = 0x2472;
  11251. t['nineteenparen'] = 0x2486;
  11252. t['nineteenperiod'] = 0x249A;
  11253. t['ninethai'] = 0x0E59;
  11254. t['nj'] = 0x01CC;
  11255. t['njecyrillic'] = 0x045A;
  11256. t['nkatakana'] = 0x30F3;
  11257. t['nkatakanahalfwidth'] = 0xFF9D;
  11258. t['nlegrightlong'] = 0x019E;
  11259. t['nlinebelow'] = 0x1E49;
  11260. t['nmonospace'] = 0xFF4E;
  11261. t['nmsquare'] = 0x339A;
  11262. t['nnabengali'] = 0x09A3;
  11263. t['nnadeva'] = 0x0923;
  11264. t['nnagujarati'] = 0x0AA3;
  11265. t['nnagurmukhi'] = 0x0A23;
  11266. t['nnnadeva'] = 0x0929;
  11267. t['nohiragana'] = 0x306E;
  11268. t['nokatakana'] = 0x30CE;
  11269. t['nokatakanahalfwidth'] = 0xFF89;
  11270. t['nonbreakingspace'] = 0x00A0;
  11271. t['nonenthai'] = 0x0E13;
  11272. t['nonuthai'] = 0x0E19;
  11273. t['noonarabic'] = 0x0646;
  11274. t['noonfinalarabic'] = 0xFEE6;
  11275. t['noonghunnaarabic'] = 0x06BA;
  11276. t['noonghunnafinalarabic'] = 0xFB9F;
  11277. t['nooninitialarabic'] = 0xFEE7;
  11278. t['noonjeeminitialarabic'] = 0xFCD2;
  11279. t['noonjeemisolatedarabic'] = 0xFC4B;
  11280. t['noonmedialarabic'] = 0xFEE8;
  11281. t['noonmeeminitialarabic'] = 0xFCD5;
  11282. t['noonmeemisolatedarabic'] = 0xFC4E;
  11283. t['noonnoonfinalarabic'] = 0xFC8D;
  11284. t['notcontains'] = 0x220C;
  11285. t['notelement'] = 0x2209;
  11286. t['notelementof'] = 0x2209;
  11287. t['notequal'] = 0x2260;
  11288. t['notgreater'] = 0x226F;
  11289. t['notgreaternorequal'] = 0x2271;
  11290. t['notgreaternorless'] = 0x2279;
  11291. t['notidentical'] = 0x2262;
  11292. t['notless'] = 0x226E;
  11293. t['notlessnorequal'] = 0x2270;
  11294. t['notparallel'] = 0x2226;
  11295. t['notprecedes'] = 0x2280;
  11296. t['notsubset'] = 0x2284;
  11297. t['notsucceeds'] = 0x2281;
  11298. t['notsuperset'] = 0x2285;
  11299. t['nowarmenian'] = 0x0576;
  11300. t['nparen'] = 0x24A9;
  11301. t['nssquare'] = 0x33B1;
  11302. t['nsuperior'] = 0x207F;
  11303. t['ntilde'] = 0x00F1;
  11304. t['nu'] = 0x03BD;
  11305. t['nuhiragana'] = 0x306C;
  11306. t['nukatakana'] = 0x30CC;
  11307. t['nukatakanahalfwidth'] = 0xFF87;
  11308. t['nuktabengali'] = 0x09BC;
  11309. t['nuktadeva'] = 0x093C;
  11310. t['nuktagujarati'] = 0x0ABC;
  11311. t['nuktagurmukhi'] = 0x0A3C;
  11312. t['numbersign'] = 0x0023;
  11313. t['numbersignmonospace'] = 0xFF03;
  11314. t['numbersignsmall'] = 0xFE5F;
  11315. t['numeralsigngreek'] = 0x0374;
  11316. t['numeralsignlowergreek'] = 0x0375;
  11317. t['numero'] = 0x2116;
  11318. t['nun'] = 0x05E0;
  11319. t['nundagesh'] = 0xFB40;
  11320. t['nundageshhebrew'] = 0xFB40;
  11321. t['nunhebrew'] = 0x05E0;
  11322. t['nvsquare'] = 0x33B5;
  11323. t['nwsquare'] = 0x33BB;
  11324. t['nyabengali'] = 0x099E;
  11325. t['nyadeva'] = 0x091E;
  11326. t['nyagujarati'] = 0x0A9E;
  11327. t['nyagurmukhi'] = 0x0A1E;
  11328. t['o'] = 0x006F;
  11329. t['oacute'] = 0x00F3;
  11330. t['oangthai'] = 0x0E2D;
  11331. t['obarred'] = 0x0275;
  11332. t['obarredcyrillic'] = 0x04E9;
  11333. t['obarreddieresiscyrillic'] = 0x04EB;
  11334. t['obengali'] = 0x0993;
  11335. t['obopomofo'] = 0x311B;
  11336. t['obreve'] = 0x014F;
  11337. t['ocandradeva'] = 0x0911;
  11338. t['ocandragujarati'] = 0x0A91;
  11339. t['ocandravowelsigndeva'] = 0x0949;
  11340. t['ocandravowelsigngujarati'] = 0x0AC9;
  11341. t['ocaron'] = 0x01D2;
  11342. t['ocircle'] = 0x24DE;
  11343. t['ocircumflex'] = 0x00F4;
  11344. t['ocircumflexacute'] = 0x1ED1;
  11345. t['ocircumflexdotbelow'] = 0x1ED9;
  11346. t['ocircumflexgrave'] = 0x1ED3;
  11347. t['ocircumflexhookabove'] = 0x1ED5;
  11348. t['ocircumflextilde'] = 0x1ED7;
  11349. t['ocyrillic'] = 0x043E;
  11350. t['odblacute'] = 0x0151;
  11351. t['odblgrave'] = 0x020D;
  11352. t['odeva'] = 0x0913;
  11353. t['odieresis'] = 0x00F6;
  11354. t['odieresiscyrillic'] = 0x04E7;
  11355. t['odotbelow'] = 0x1ECD;
  11356. t['oe'] = 0x0153;
  11357. t['oekorean'] = 0x315A;
  11358. t['ogonek'] = 0x02DB;
  11359. t['ogonekcmb'] = 0x0328;
  11360. t['ograve'] = 0x00F2;
  11361. t['ogujarati'] = 0x0A93;
  11362. t['oharmenian'] = 0x0585;
  11363. t['ohiragana'] = 0x304A;
  11364. t['ohookabove'] = 0x1ECF;
  11365. t['ohorn'] = 0x01A1;
  11366. t['ohornacute'] = 0x1EDB;
  11367. t['ohorndotbelow'] = 0x1EE3;
  11368. t['ohorngrave'] = 0x1EDD;
  11369. t['ohornhookabove'] = 0x1EDF;
  11370. t['ohorntilde'] = 0x1EE1;
  11371. t['ohungarumlaut'] = 0x0151;
  11372. t['oi'] = 0x01A3;
  11373. t['oinvertedbreve'] = 0x020F;
  11374. t['okatakana'] = 0x30AA;
  11375. t['okatakanahalfwidth'] = 0xFF75;
  11376. t['okorean'] = 0x3157;
  11377. t['olehebrew'] = 0x05AB;
  11378. t['omacron'] = 0x014D;
  11379. t['omacronacute'] = 0x1E53;
  11380. t['omacrongrave'] = 0x1E51;
  11381. t['omdeva'] = 0x0950;
  11382. t['omega'] = 0x03C9;
  11383. t['omega1'] = 0x03D6;
  11384. t['omegacyrillic'] = 0x0461;
  11385. t['omegalatinclosed'] = 0x0277;
  11386. t['omegaroundcyrillic'] = 0x047B;
  11387. t['omegatitlocyrillic'] = 0x047D;
  11388. t['omegatonos'] = 0x03CE;
  11389. t['omgujarati'] = 0x0AD0;
  11390. t['omicron'] = 0x03BF;
  11391. t['omicrontonos'] = 0x03CC;
  11392. t['omonospace'] = 0xFF4F;
  11393. t['one'] = 0x0031;
  11394. t['onearabic'] = 0x0661;
  11395. t['onebengali'] = 0x09E7;
  11396. t['onecircle'] = 0x2460;
  11397. t['onecircleinversesansserif'] = 0x278A;
  11398. t['onedeva'] = 0x0967;
  11399. t['onedotenleader'] = 0x2024;
  11400. t['oneeighth'] = 0x215B;
  11401. t['onefitted'] = 0xF6DC;
  11402. t['onegujarati'] = 0x0AE7;
  11403. t['onegurmukhi'] = 0x0A67;
  11404. t['onehackarabic'] = 0x0661;
  11405. t['onehalf'] = 0x00BD;
  11406. t['onehangzhou'] = 0x3021;
  11407. t['oneideographicparen'] = 0x3220;
  11408. t['oneinferior'] = 0x2081;
  11409. t['onemonospace'] = 0xFF11;
  11410. t['onenumeratorbengali'] = 0x09F4;
  11411. t['oneoldstyle'] = 0xF731;
  11412. t['oneparen'] = 0x2474;
  11413. t['oneperiod'] = 0x2488;
  11414. t['onepersian'] = 0x06F1;
  11415. t['onequarter'] = 0x00BC;
  11416. t['oneroman'] = 0x2170;
  11417. t['onesuperior'] = 0x00B9;
  11418. t['onethai'] = 0x0E51;
  11419. t['onethird'] = 0x2153;
  11420. t['oogonek'] = 0x01EB;
  11421. t['oogonekmacron'] = 0x01ED;
  11422. t['oogurmukhi'] = 0x0A13;
  11423. t['oomatragurmukhi'] = 0x0A4B;
  11424. t['oopen'] = 0x0254;
  11425. t['oparen'] = 0x24AA;
  11426. t['openbullet'] = 0x25E6;
  11427. t['option'] = 0x2325;
  11428. t['ordfeminine'] = 0x00AA;
  11429. t['ordmasculine'] = 0x00BA;
  11430. t['orthogonal'] = 0x221F;
  11431. t['oshortdeva'] = 0x0912;
  11432. t['oshortvowelsigndeva'] = 0x094A;
  11433. t['oslash'] = 0x00F8;
  11434. t['oslashacute'] = 0x01FF;
  11435. t['osmallhiragana'] = 0x3049;
  11436. t['osmallkatakana'] = 0x30A9;
  11437. t['osmallkatakanahalfwidth'] = 0xFF6B;
  11438. t['ostrokeacute'] = 0x01FF;
  11439. t['osuperior'] = 0xF6F0;
  11440. t['otcyrillic'] = 0x047F;
  11441. t['otilde'] = 0x00F5;
  11442. t['otildeacute'] = 0x1E4D;
  11443. t['otildedieresis'] = 0x1E4F;
  11444. t['oubopomofo'] = 0x3121;
  11445. t['overline'] = 0x203E;
  11446. t['overlinecenterline'] = 0xFE4A;
  11447. t['overlinecmb'] = 0x0305;
  11448. t['overlinedashed'] = 0xFE49;
  11449. t['overlinedblwavy'] = 0xFE4C;
  11450. t['overlinewavy'] = 0xFE4B;
  11451. t['overscore'] = 0x00AF;
  11452. t['ovowelsignbengali'] = 0x09CB;
  11453. t['ovowelsigndeva'] = 0x094B;
  11454. t['ovowelsigngujarati'] = 0x0ACB;
  11455. t['p'] = 0x0070;
  11456. t['paampssquare'] = 0x3380;
  11457. t['paasentosquare'] = 0x332B;
  11458. t['pabengali'] = 0x09AA;
  11459. t['pacute'] = 0x1E55;
  11460. t['padeva'] = 0x092A;
  11461. t['pagedown'] = 0x21DF;
  11462. t['pageup'] = 0x21DE;
  11463. t['pagujarati'] = 0x0AAA;
  11464. t['pagurmukhi'] = 0x0A2A;
  11465. t['pahiragana'] = 0x3071;
  11466. t['paiyannoithai'] = 0x0E2F;
  11467. t['pakatakana'] = 0x30D1;
  11468. t['palatalizationcyrilliccmb'] = 0x0484;
  11469. t['palochkacyrillic'] = 0x04C0;
  11470. t['pansioskorean'] = 0x317F;
  11471. t['paragraph'] = 0x00B6;
  11472. t['parallel'] = 0x2225;
  11473. t['parenleft'] = 0x0028;
  11474. t['parenleftaltonearabic'] = 0xFD3E;
  11475. t['parenleftbt'] = 0xF8ED;
  11476. t['parenleftex'] = 0xF8EC;
  11477. t['parenleftinferior'] = 0x208D;
  11478. t['parenleftmonospace'] = 0xFF08;
  11479. t['parenleftsmall'] = 0xFE59;
  11480. t['parenleftsuperior'] = 0x207D;
  11481. t['parenlefttp'] = 0xF8EB;
  11482. t['parenleftvertical'] = 0xFE35;
  11483. t['parenright'] = 0x0029;
  11484. t['parenrightaltonearabic'] = 0xFD3F;
  11485. t['parenrightbt'] = 0xF8F8;
  11486. t['parenrightex'] = 0xF8F7;
  11487. t['parenrightinferior'] = 0x208E;
  11488. t['parenrightmonospace'] = 0xFF09;
  11489. t['parenrightsmall'] = 0xFE5A;
  11490. t['parenrightsuperior'] = 0x207E;
  11491. t['parenrighttp'] = 0xF8F6;
  11492. t['parenrightvertical'] = 0xFE36;
  11493. t['partialdiff'] = 0x2202;
  11494. t['paseqhebrew'] = 0x05C0;
  11495. t['pashtahebrew'] = 0x0599;
  11496. t['pasquare'] = 0x33A9;
  11497. t['patah'] = 0x05B7;
  11498. t['patah11'] = 0x05B7;
  11499. t['patah1d'] = 0x05B7;
  11500. t['patah2a'] = 0x05B7;
  11501. t['patahhebrew'] = 0x05B7;
  11502. t['patahnarrowhebrew'] = 0x05B7;
  11503. t['patahquarterhebrew'] = 0x05B7;
  11504. t['patahwidehebrew'] = 0x05B7;
  11505. t['pazerhebrew'] = 0x05A1;
  11506. t['pbopomofo'] = 0x3106;
  11507. t['pcircle'] = 0x24DF;
  11508. t['pdotaccent'] = 0x1E57;
  11509. t['pe'] = 0x05E4;
  11510. t['pecyrillic'] = 0x043F;
  11511. t['pedagesh'] = 0xFB44;
  11512. t['pedageshhebrew'] = 0xFB44;
  11513. t['peezisquare'] = 0x333B;
  11514. t['pefinaldageshhebrew'] = 0xFB43;
  11515. t['peharabic'] = 0x067E;
  11516. t['peharmenian'] = 0x057A;
  11517. t['pehebrew'] = 0x05E4;
  11518. t['pehfinalarabic'] = 0xFB57;
  11519. t['pehinitialarabic'] = 0xFB58;
  11520. t['pehiragana'] = 0x307A;
  11521. t['pehmedialarabic'] = 0xFB59;
  11522. t['pekatakana'] = 0x30DA;
  11523. t['pemiddlehookcyrillic'] = 0x04A7;
  11524. t['perafehebrew'] = 0xFB4E;
  11525. t['percent'] = 0x0025;
  11526. t['percentarabic'] = 0x066A;
  11527. t['percentmonospace'] = 0xFF05;
  11528. t['percentsmall'] = 0xFE6A;
  11529. t['period'] = 0x002E;
  11530. t['periodarmenian'] = 0x0589;
  11531. t['periodcentered'] = 0x00B7;
  11532. t['periodhalfwidth'] = 0xFF61;
  11533. t['periodinferior'] = 0xF6E7;
  11534. t['periodmonospace'] = 0xFF0E;
  11535. t['periodsmall'] = 0xFE52;
  11536. t['periodsuperior'] = 0xF6E8;
  11537. t['perispomenigreekcmb'] = 0x0342;
  11538. t['perpendicular'] = 0x22A5;
  11539. t['perthousand'] = 0x2030;
  11540. t['peseta'] = 0x20A7;
  11541. t['pfsquare'] = 0x338A;
  11542. t['phabengali'] = 0x09AB;
  11543. t['phadeva'] = 0x092B;
  11544. t['phagujarati'] = 0x0AAB;
  11545. t['phagurmukhi'] = 0x0A2B;
  11546. t['phi'] = 0x03C6;
  11547. t['phi1'] = 0x03D5;
  11548. t['phieuphacirclekorean'] = 0x327A;
  11549. t['phieuphaparenkorean'] = 0x321A;
  11550. t['phieuphcirclekorean'] = 0x326C;
  11551. t['phieuphkorean'] = 0x314D;
  11552. t['phieuphparenkorean'] = 0x320C;
  11553. t['philatin'] = 0x0278;
  11554. t['phinthuthai'] = 0x0E3A;
  11555. t['phisymbolgreek'] = 0x03D5;
  11556. t['phook'] = 0x01A5;
  11557. t['phophanthai'] = 0x0E1E;
  11558. t['phophungthai'] = 0x0E1C;
  11559. t['phosamphaothai'] = 0x0E20;
  11560. t['pi'] = 0x03C0;
  11561. t['pieupacirclekorean'] = 0x3273;
  11562. t['pieupaparenkorean'] = 0x3213;
  11563. t['pieupcieuckorean'] = 0x3176;
  11564. t['pieupcirclekorean'] = 0x3265;
  11565. t['pieupkiyeokkorean'] = 0x3172;
  11566. t['pieupkorean'] = 0x3142;
  11567. t['pieupparenkorean'] = 0x3205;
  11568. t['pieupsioskiyeokkorean'] = 0x3174;
  11569. t['pieupsioskorean'] = 0x3144;
  11570. t['pieupsiostikeutkorean'] = 0x3175;
  11571. t['pieupthieuthkorean'] = 0x3177;
  11572. t['pieuptikeutkorean'] = 0x3173;
  11573. t['pihiragana'] = 0x3074;
  11574. t['pikatakana'] = 0x30D4;
  11575. t['pisymbolgreek'] = 0x03D6;
  11576. t['piwrarmenian'] = 0x0583;
  11577. t['plus'] = 0x002B;
  11578. t['plusbelowcmb'] = 0x031F;
  11579. t['pluscircle'] = 0x2295;
  11580. t['plusminus'] = 0x00B1;
  11581. t['plusmod'] = 0x02D6;
  11582. t['plusmonospace'] = 0xFF0B;
  11583. t['plussmall'] = 0xFE62;
  11584. t['plussuperior'] = 0x207A;
  11585. t['pmonospace'] = 0xFF50;
  11586. t['pmsquare'] = 0x33D8;
  11587. t['pohiragana'] = 0x307D;
  11588. t['pointingindexdownwhite'] = 0x261F;
  11589. t['pointingindexleftwhite'] = 0x261C;
  11590. t['pointingindexrightwhite'] = 0x261E;
  11591. t['pointingindexupwhite'] = 0x261D;
  11592. t['pokatakana'] = 0x30DD;
  11593. t['poplathai'] = 0x0E1B;
  11594. t['postalmark'] = 0x3012;
  11595. t['postalmarkface'] = 0x3020;
  11596. t['pparen'] = 0x24AB;
  11597. t['precedes'] = 0x227A;
  11598. t['prescription'] = 0x211E;
  11599. t['primemod'] = 0x02B9;
  11600. t['primereversed'] = 0x2035;
  11601. t['product'] = 0x220F;
  11602. t['projective'] = 0x2305;
  11603. t['prolongedkana'] = 0x30FC;
  11604. t['propellor'] = 0x2318;
  11605. t['propersubset'] = 0x2282;
  11606. t['propersuperset'] = 0x2283;
  11607. t['proportion'] = 0x2237;
  11608. t['proportional'] = 0x221D;
  11609. t['psi'] = 0x03C8;
  11610. t['psicyrillic'] = 0x0471;
  11611. t['psilipneumatacyrilliccmb'] = 0x0486;
  11612. t['pssquare'] = 0x33B0;
  11613. t['puhiragana'] = 0x3077;
  11614. t['pukatakana'] = 0x30D7;
  11615. t['pvsquare'] = 0x33B4;
  11616. t['pwsquare'] = 0x33BA;
  11617. t['q'] = 0x0071;
  11618. t['qadeva'] = 0x0958;
  11619. t['qadmahebrew'] = 0x05A8;
  11620. t['qafarabic'] = 0x0642;
  11621. t['qaffinalarabic'] = 0xFED6;
  11622. t['qafinitialarabic'] = 0xFED7;
  11623. t['qafmedialarabic'] = 0xFED8;
  11624. t['qamats'] = 0x05B8;
  11625. t['qamats10'] = 0x05B8;
  11626. t['qamats1a'] = 0x05B8;
  11627. t['qamats1c'] = 0x05B8;
  11628. t['qamats27'] = 0x05B8;
  11629. t['qamats29'] = 0x05B8;
  11630. t['qamats33'] = 0x05B8;
  11631. t['qamatsde'] = 0x05B8;
  11632. t['qamatshebrew'] = 0x05B8;
  11633. t['qamatsnarrowhebrew'] = 0x05B8;
  11634. t['qamatsqatanhebrew'] = 0x05B8;
  11635. t['qamatsqatannarrowhebrew'] = 0x05B8;
  11636. t['qamatsqatanquarterhebrew'] = 0x05B8;
  11637. t['qamatsqatanwidehebrew'] = 0x05B8;
  11638. t['qamatsquarterhebrew'] = 0x05B8;
  11639. t['qamatswidehebrew'] = 0x05B8;
  11640. t['qarneyparahebrew'] = 0x059F;
  11641. t['qbopomofo'] = 0x3111;
  11642. t['qcircle'] = 0x24E0;
  11643. t['qhook'] = 0x02A0;
  11644. t['qmonospace'] = 0xFF51;
  11645. t['qof'] = 0x05E7;
  11646. t['qofdagesh'] = 0xFB47;
  11647. t['qofdageshhebrew'] = 0xFB47;
  11648. t['qofhebrew'] = 0x05E7;
  11649. t['qparen'] = 0x24AC;
  11650. t['quarternote'] = 0x2669;
  11651. t['qubuts'] = 0x05BB;
  11652. t['qubuts18'] = 0x05BB;
  11653. t['qubuts25'] = 0x05BB;
  11654. t['qubuts31'] = 0x05BB;
  11655. t['qubutshebrew'] = 0x05BB;
  11656. t['qubutsnarrowhebrew'] = 0x05BB;
  11657. t['qubutsquarterhebrew'] = 0x05BB;
  11658. t['qubutswidehebrew'] = 0x05BB;
  11659. t['question'] = 0x003F;
  11660. t['questionarabic'] = 0x061F;
  11661. t['questionarmenian'] = 0x055E;
  11662. t['questiondown'] = 0x00BF;
  11663. t['questiondownsmall'] = 0xF7BF;
  11664. t['questiongreek'] = 0x037E;
  11665. t['questionmonospace'] = 0xFF1F;
  11666. t['questionsmall'] = 0xF73F;
  11667. t['quotedbl'] = 0x0022;
  11668. t['quotedblbase'] = 0x201E;
  11669. t['quotedblleft'] = 0x201C;
  11670. t['quotedblmonospace'] = 0xFF02;
  11671. t['quotedblprime'] = 0x301E;
  11672. t['quotedblprimereversed'] = 0x301D;
  11673. t['quotedblright'] = 0x201D;
  11674. t['quoteleft'] = 0x2018;
  11675. t['quoteleftreversed'] = 0x201B;
  11676. t['quotereversed'] = 0x201B;
  11677. t['quoteright'] = 0x2019;
  11678. t['quoterightn'] = 0x0149;
  11679. t['quotesinglbase'] = 0x201A;
  11680. t['quotesingle'] = 0x0027;
  11681. t['quotesinglemonospace'] = 0xFF07;
  11682. t['r'] = 0x0072;
  11683. t['raarmenian'] = 0x057C;
  11684. t['rabengali'] = 0x09B0;
  11685. t['racute'] = 0x0155;
  11686. t['radeva'] = 0x0930;
  11687. t['radical'] = 0x221A;
  11688. t['radicalex'] = 0xF8E5;
  11689. t['radoverssquare'] = 0x33AE;
  11690. t['radoverssquaredsquare'] = 0x33AF;
  11691. t['radsquare'] = 0x33AD;
  11692. t['rafe'] = 0x05BF;
  11693. t['rafehebrew'] = 0x05BF;
  11694. t['ragujarati'] = 0x0AB0;
  11695. t['ragurmukhi'] = 0x0A30;
  11696. t['rahiragana'] = 0x3089;
  11697. t['rakatakana'] = 0x30E9;
  11698. t['rakatakanahalfwidth'] = 0xFF97;
  11699. t['ralowerdiagonalbengali'] = 0x09F1;
  11700. t['ramiddlediagonalbengali'] = 0x09F0;
  11701. t['ramshorn'] = 0x0264;
  11702. t['ratio'] = 0x2236;
  11703. t['rbopomofo'] = 0x3116;
  11704. t['rcaron'] = 0x0159;
  11705. t['rcedilla'] = 0x0157;
  11706. t['rcircle'] = 0x24E1;
  11707. t['rcommaaccent'] = 0x0157;
  11708. t['rdblgrave'] = 0x0211;
  11709. t['rdotaccent'] = 0x1E59;
  11710. t['rdotbelow'] = 0x1E5B;
  11711. t['rdotbelowmacron'] = 0x1E5D;
  11712. t['referencemark'] = 0x203B;
  11713. t['reflexsubset'] = 0x2286;
  11714. t['reflexsuperset'] = 0x2287;
  11715. t['registered'] = 0x00AE;
  11716. t['registersans'] = 0xF8E8;
  11717. t['registerserif'] = 0xF6DA;
  11718. t['reharabic'] = 0x0631;
  11719. t['reharmenian'] = 0x0580;
  11720. t['rehfinalarabic'] = 0xFEAE;
  11721. t['rehiragana'] = 0x308C;
  11722. t['rekatakana'] = 0x30EC;
  11723. t['rekatakanahalfwidth'] = 0xFF9A;
  11724. t['resh'] = 0x05E8;
  11725. t['reshdageshhebrew'] = 0xFB48;
  11726. t['reshhebrew'] = 0x05E8;
  11727. t['reversedtilde'] = 0x223D;
  11728. t['reviahebrew'] = 0x0597;
  11729. t['reviamugrashhebrew'] = 0x0597;
  11730. t['revlogicalnot'] = 0x2310;
  11731. t['rfishhook'] = 0x027E;
  11732. t['rfishhookreversed'] = 0x027F;
  11733. t['rhabengali'] = 0x09DD;
  11734. t['rhadeva'] = 0x095D;
  11735. t['rho'] = 0x03C1;
  11736. t['rhook'] = 0x027D;
  11737. t['rhookturned'] = 0x027B;
  11738. t['rhookturnedsuperior'] = 0x02B5;
  11739. t['rhosymbolgreek'] = 0x03F1;
  11740. t['rhotichookmod'] = 0x02DE;
  11741. t['rieulacirclekorean'] = 0x3271;
  11742. t['rieulaparenkorean'] = 0x3211;
  11743. t['rieulcirclekorean'] = 0x3263;
  11744. t['rieulhieuhkorean'] = 0x3140;
  11745. t['rieulkiyeokkorean'] = 0x313A;
  11746. t['rieulkiyeoksioskorean'] = 0x3169;
  11747. t['rieulkorean'] = 0x3139;
  11748. t['rieulmieumkorean'] = 0x313B;
  11749. t['rieulpansioskorean'] = 0x316C;
  11750. t['rieulparenkorean'] = 0x3203;
  11751. t['rieulphieuphkorean'] = 0x313F;
  11752. t['rieulpieupkorean'] = 0x313C;
  11753. t['rieulpieupsioskorean'] = 0x316B;
  11754. t['rieulsioskorean'] = 0x313D;
  11755. t['rieulthieuthkorean'] = 0x313E;
  11756. t['rieultikeutkorean'] = 0x316A;
  11757. t['rieulyeorinhieuhkorean'] = 0x316D;
  11758. t['rightangle'] = 0x221F;
  11759. t['righttackbelowcmb'] = 0x0319;
  11760. t['righttriangle'] = 0x22BF;
  11761. t['rihiragana'] = 0x308A;
  11762. t['rikatakana'] = 0x30EA;
  11763. t['rikatakanahalfwidth'] = 0xFF98;
  11764. t['ring'] = 0x02DA;
  11765. t['ringbelowcmb'] = 0x0325;
  11766. t['ringcmb'] = 0x030A;
  11767. t['ringhalfleft'] = 0x02BF;
  11768. t['ringhalfleftarmenian'] = 0x0559;
  11769. t['ringhalfleftbelowcmb'] = 0x031C;
  11770. t['ringhalfleftcentered'] = 0x02D3;
  11771. t['ringhalfright'] = 0x02BE;
  11772. t['ringhalfrightbelowcmb'] = 0x0339;
  11773. t['ringhalfrightcentered'] = 0x02D2;
  11774. t['rinvertedbreve'] = 0x0213;
  11775. t['rittorusquare'] = 0x3351;
  11776. t['rlinebelow'] = 0x1E5F;
  11777. t['rlongleg'] = 0x027C;
  11778. t['rlonglegturned'] = 0x027A;
  11779. t['rmonospace'] = 0xFF52;
  11780. t['rohiragana'] = 0x308D;
  11781. t['rokatakana'] = 0x30ED;
  11782. t['rokatakanahalfwidth'] = 0xFF9B;
  11783. t['roruathai'] = 0x0E23;
  11784. t['rparen'] = 0x24AD;
  11785. t['rrabengali'] = 0x09DC;
  11786. t['rradeva'] = 0x0931;
  11787. t['rragurmukhi'] = 0x0A5C;
  11788. t['rreharabic'] = 0x0691;
  11789. t['rrehfinalarabic'] = 0xFB8D;
  11790. t['rrvocalicbengali'] = 0x09E0;
  11791. t['rrvocalicdeva'] = 0x0960;
  11792. t['rrvocalicgujarati'] = 0x0AE0;
  11793. t['rrvocalicvowelsignbengali'] = 0x09C4;
  11794. t['rrvocalicvowelsigndeva'] = 0x0944;
  11795. t['rrvocalicvowelsigngujarati'] = 0x0AC4;
  11796. t['rsuperior'] = 0xF6F1;
  11797. t['rtblock'] = 0x2590;
  11798. t['rturned'] = 0x0279;
  11799. t['rturnedsuperior'] = 0x02B4;
  11800. t['ruhiragana'] = 0x308B;
  11801. t['rukatakana'] = 0x30EB;
  11802. t['rukatakanahalfwidth'] = 0xFF99;
  11803. t['rupeemarkbengali'] = 0x09F2;
  11804. t['rupeesignbengali'] = 0x09F3;
  11805. t['rupiah'] = 0xF6DD;
  11806. t['ruthai'] = 0x0E24;
  11807. t['rvocalicbengali'] = 0x098B;
  11808. t['rvocalicdeva'] = 0x090B;
  11809. t['rvocalicgujarati'] = 0x0A8B;
  11810. t['rvocalicvowelsignbengali'] = 0x09C3;
  11811. t['rvocalicvowelsigndeva'] = 0x0943;
  11812. t['rvocalicvowelsigngujarati'] = 0x0AC3;
  11813. t['s'] = 0x0073;
  11814. t['sabengali'] = 0x09B8;
  11815. t['sacute'] = 0x015B;
  11816. t['sacutedotaccent'] = 0x1E65;
  11817. t['sadarabic'] = 0x0635;
  11818. t['sadeva'] = 0x0938;
  11819. t['sadfinalarabic'] = 0xFEBA;
  11820. t['sadinitialarabic'] = 0xFEBB;
  11821. t['sadmedialarabic'] = 0xFEBC;
  11822. t['sagujarati'] = 0x0AB8;
  11823. t['sagurmukhi'] = 0x0A38;
  11824. t['sahiragana'] = 0x3055;
  11825. t['sakatakana'] = 0x30B5;
  11826. t['sakatakanahalfwidth'] = 0xFF7B;
  11827. t['sallallahoualayhewasallamarabic'] = 0xFDFA;
  11828. t['samekh'] = 0x05E1;
  11829. t['samekhdagesh'] = 0xFB41;
  11830. t['samekhdageshhebrew'] = 0xFB41;
  11831. t['samekhhebrew'] = 0x05E1;
  11832. t['saraaathai'] = 0x0E32;
  11833. t['saraaethai'] = 0x0E41;
  11834. t['saraaimaimalaithai'] = 0x0E44;
  11835. t['saraaimaimuanthai'] = 0x0E43;
  11836. t['saraamthai'] = 0x0E33;
  11837. t['saraathai'] = 0x0E30;
  11838. t['saraethai'] = 0x0E40;
  11839. t['saraiileftthai'] = 0xF886;
  11840. t['saraiithai'] = 0x0E35;
  11841. t['saraileftthai'] = 0xF885;
  11842. t['saraithai'] = 0x0E34;
  11843. t['saraothai'] = 0x0E42;
  11844. t['saraueeleftthai'] = 0xF888;
  11845. t['saraueethai'] = 0x0E37;
  11846. t['saraueleftthai'] = 0xF887;
  11847. t['sarauethai'] = 0x0E36;
  11848. t['sarauthai'] = 0x0E38;
  11849. t['sarauuthai'] = 0x0E39;
  11850. t['sbopomofo'] = 0x3119;
  11851. t['scaron'] = 0x0161;
  11852. t['scarondotaccent'] = 0x1E67;
  11853. t['scedilla'] = 0x015F;
  11854. t['schwa'] = 0x0259;
  11855. t['schwacyrillic'] = 0x04D9;
  11856. t['schwadieresiscyrillic'] = 0x04DB;
  11857. t['schwahook'] = 0x025A;
  11858. t['scircle'] = 0x24E2;
  11859. t['scircumflex'] = 0x015D;
  11860. t['scommaaccent'] = 0x0219;
  11861. t['sdotaccent'] = 0x1E61;
  11862. t['sdotbelow'] = 0x1E63;
  11863. t['sdotbelowdotaccent'] = 0x1E69;
  11864. t['seagullbelowcmb'] = 0x033C;
  11865. t['second'] = 0x2033;
  11866. t['secondtonechinese'] = 0x02CA;
  11867. t['section'] = 0x00A7;
  11868. t['seenarabic'] = 0x0633;
  11869. t['seenfinalarabic'] = 0xFEB2;
  11870. t['seeninitialarabic'] = 0xFEB3;
  11871. t['seenmedialarabic'] = 0xFEB4;
  11872. t['segol'] = 0x05B6;
  11873. t['segol13'] = 0x05B6;
  11874. t['segol1f'] = 0x05B6;
  11875. t['segol2c'] = 0x05B6;
  11876. t['segolhebrew'] = 0x05B6;
  11877. t['segolnarrowhebrew'] = 0x05B6;
  11878. t['segolquarterhebrew'] = 0x05B6;
  11879. t['segoltahebrew'] = 0x0592;
  11880. t['segolwidehebrew'] = 0x05B6;
  11881. t['seharmenian'] = 0x057D;
  11882. t['sehiragana'] = 0x305B;
  11883. t['sekatakana'] = 0x30BB;
  11884. t['sekatakanahalfwidth'] = 0xFF7E;
  11885. t['semicolon'] = 0x003B;
  11886. t['semicolonarabic'] = 0x061B;
  11887. t['semicolonmonospace'] = 0xFF1B;
  11888. t['semicolonsmall'] = 0xFE54;
  11889. t['semivoicedmarkkana'] = 0x309C;
  11890. t['semivoicedmarkkanahalfwidth'] = 0xFF9F;
  11891. t['sentisquare'] = 0x3322;
  11892. t['sentosquare'] = 0x3323;
  11893. t['seven'] = 0x0037;
  11894. t['sevenarabic'] = 0x0667;
  11895. t['sevenbengali'] = 0x09ED;
  11896. t['sevencircle'] = 0x2466;
  11897. t['sevencircleinversesansserif'] = 0x2790;
  11898. t['sevendeva'] = 0x096D;
  11899. t['seveneighths'] = 0x215E;
  11900. t['sevengujarati'] = 0x0AED;
  11901. t['sevengurmukhi'] = 0x0A6D;
  11902. t['sevenhackarabic'] = 0x0667;
  11903. t['sevenhangzhou'] = 0x3027;
  11904. t['sevenideographicparen'] = 0x3226;
  11905. t['seveninferior'] = 0x2087;
  11906. t['sevenmonospace'] = 0xFF17;
  11907. t['sevenoldstyle'] = 0xF737;
  11908. t['sevenparen'] = 0x247A;
  11909. t['sevenperiod'] = 0x248E;
  11910. t['sevenpersian'] = 0x06F7;
  11911. t['sevenroman'] = 0x2176;
  11912. t['sevensuperior'] = 0x2077;
  11913. t['seventeencircle'] = 0x2470;
  11914. t['seventeenparen'] = 0x2484;
  11915. t['seventeenperiod'] = 0x2498;
  11916. t['seventhai'] = 0x0E57;
  11917. t['sfthyphen'] = 0x00AD;
  11918. t['shaarmenian'] = 0x0577;
  11919. t['shabengali'] = 0x09B6;
  11920. t['shacyrillic'] = 0x0448;
  11921. t['shaddaarabic'] = 0x0651;
  11922. t['shaddadammaarabic'] = 0xFC61;
  11923. t['shaddadammatanarabic'] = 0xFC5E;
  11924. t['shaddafathaarabic'] = 0xFC60;
  11925. t['shaddakasraarabic'] = 0xFC62;
  11926. t['shaddakasratanarabic'] = 0xFC5F;
  11927. t['shade'] = 0x2592;
  11928. t['shadedark'] = 0x2593;
  11929. t['shadelight'] = 0x2591;
  11930. t['shademedium'] = 0x2592;
  11931. t['shadeva'] = 0x0936;
  11932. t['shagujarati'] = 0x0AB6;
  11933. t['shagurmukhi'] = 0x0A36;
  11934. t['shalshelethebrew'] = 0x0593;
  11935. t['shbopomofo'] = 0x3115;
  11936. t['shchacyrillic'] = 0x0449;
  11937. t['sheenarabic'] = 0x0634;
  11938. t['sheenfinalarabic'] = 0xFEB6;
  11939. t['sheeninitialarabic'] = 0xFEB7;
  11940. t['sheenmedialarabic'] = 0xFEB8;
  11941. t['sheicoptic'] = 0x03E3;
  11942. t['sheqel'] = 0x20AA;
  11943. t['sheqelhebrew'] = 0x20AA;
  11944. t['sheva'] = 0x05B0;
  11945. t['sheva115'] = 0x05B0;
  11946. t['sheva15'] = 0x05B0;
  11947. t['sheva22'] = 0x05B0;
  11948. t['sheva2e'] = 0x05B0;
  11949. t['shevahebrew'] = 0x05B0;
  11950. t['shevanarrowhebrew'] = 0x05B0;
  11951. t['shevaquarterhebrew'] = 0x05B0;
  11952. t['shevawidehebrew'] = 0x05B0;
  11953. t['shhacyrillic'] = 0x04BB;
  11954. t['shimacoptic'] = 0x03ED;
  11955. t['shin'] = 0x05E9;
  11956. t['shindagesh'] = 0xFB49;
  11957. t['shindageshhebrew'] = 0xFB49;
  11958. t['shindageshshindot'] = 0xFB2C;
  11959. t['shindageshshindothebrew'] = 0xFB2C;
  11960. t['shindageshsindot'] = 0xFB2D;
  11961. t['shindageshsindothebrew'] = 0xFB2D;
  11962. t['shindothebrew'] = 0x05C1;
  11963. t['shinhebrew'] = 0x05E9;
  11964. t['shinshindot'] = 0xFB2A;
  11965. t['shinshindothebrew'] = 0xFB2A;
  11966. t['shinsindot'] = 0xFB2B;
  11967. t['shinsindothebrew'] = 0xFB2B;
  11968. t['shook'] = 0x0282;
  11969. t['sigma'] = 0x03C3;
  11970. t['sigma1'] = 0x03C2;
  11971. t['sigmafinal'] = 0x03C2;
  11972. t['sigmalunatesymbolgreek'] = 0x03F2;
  11973. t['sihiragana'] = 0x3057;
  11974. t['sikatakana'] = 0x30B7;
  11975. t['sikatakanahalfwidth'] = 0xFF7C;
  11976. t['siluqhebrew'] = 0x05BD;
  11977. t['siluqlefthebrew'] = 0x05BD;
  11978. t['similar'] = 0x223C;
  11979. t['sindothebrew'] = 0x05C2;
  11980. t['siosacirclekorean'] = 0x3274;
  11981. t['siosaparenkorean'] = 0x3214;
  11982. t['sioscieuckorean'] = 0x317E;
  11983. t['sioscirclekorean'] = 0x3266;
  11984. t['sioskiyeokkorean'] = 0x317A;
  11985. t['sioskorean'] = 0x3145;
  11986. t['siosnieunkorean'] = 0x317B;
  11987. t['siosparenkorean'] = 0x3206;
  11988. t['siospieupkorean'] = 0x317D;
  11989. t['siostikeutkorean'] = 0x317C;
  11990. t['six'] = 0x0036;
  11991. t['sixarabic'] = 0x0666;
  11992. t['sixbengali'] = 0x09EC;
  11993. t['sixcircle'] = 0x2465;
  11994. t['sixcircleinversesansserif'] = 0x278F;
  11995. t['sixdeva'] = 0x096C;
  11996. t['sixgujarati'] = 0x0AEC;
  11997. t['sixgurmukhi'] = 0x0A6C;
  11998. t['sixhackarabic'] = 0x0666;
  11999. t['sixhangzhou'] = 0x3026;
  12000. t['sixideographicparen'] = 0x3225;
  12001. t['sixinferior'] = 0x2086;
  12002. t['sixmonospace'] = 0xFF16;
  12003. t['sixoldstyle'] = 0xF736;
  12004. t['sixparen'] = 0x2479;
  12005. t['sixperiod'] = 0x248D;
  12006. t['sixpersian'] = 0x06F6;
  12007. t['sixroman'] = 0x2175;
  12008. t['sixsuperior'] = 0x2076;
  12009. t['sixteencircle'] = 0x246F;
  12010. t['sixteencurrencydenominatorbengali'] = 0x09F9;
  12011. t['sixteenparen'] = 0x2483;
  12012. t['sixteenperiod'] = 0x2497;
  12013. t['sixthai'] = 0x0E56;
  12014. t['slash'] = 0x002F;
  12015. t['slashmonospace'] = 0xFF0F;
  12016. t['slong'] = 0x017F;
  12017. t['slongdotaccent'] = 0x1E9B;
  12018. t['smileface'] = 0x263A;
  12019. t['smonospace'] = 0xFF53;
  12020. t['sofpasuqhebrew'] = 0x05C3;
  12021. t['softhyphen'] = 0x00AD;
  12022. t['softsigncyrillic'] = 0x044C;
  12023. t['sohiragana'] = 0x305D;
  12024. t['sokatakana'] = 0x30BD;
  12025. t['sokatakanahalfwidth'] = 0xFF7F;
  12026. t['soliduslongoverlaycmb'] = 0x0338;
  12027. t['solidusshortoverlaycmb'] = 0x0337;
  12028. t['sorusithai'] = 0x0E29;
  12029. t['sosalathai'] = 0x0E28;
  12030. t['sosothai'] = 0x0E0B;
  12031. t['sosuathai'] = 0x0E2A;
  12032. t['space'] = 0x0020;
  12033. t['spacehackarabic'] = 0x0020;
  12034. t['spade'] = 0x2660;
  12035. t['spadesuitblack'] = 0x2660;
  12036. t['spadesuitwhite'] = 0x2664;
  12037. t['sparen'] = 0x24AE;
  12038. t['squarebelowcmb'] = 0x033B;
  12039. t['squarecc'] = 0x33C4;
  12040. t['squarecm'] = 0x339D;
  12041. t['squarediagonalcrosshatchfill'] = 0x25A9;
  12042. t['squarehorizontalfill'] = 0x25A4;
  12043. t['squarekg'] = 0x338F;
  12044. t['squarekm'] = 0x339E;
  12045. t['squarekmcapital'] = 0x33CE;
  12046. t['squareln'] = 0x33D1;
  12047. t['squarelog'] = 0x33D2;
  12048. t['squaremg'] = 0x338E;
  12049. t['squaremil'] = 0x33D5;
  12050. t['squaremm'] = 0x339C;
  12051. t['squaremsquared'] = 0x33A1;
  12052. t['squareorthogonalcrosshatchfill'] = 0x25A6;
  12053. t['squareupperlefttolowerrightfill'] = 0x25A7;
  12054. t['squareupperrighttolowerleftfill'] = 0x25A8;
  12055. t['squareverticalfill'] = 0x25A5;
  12056. t['squarewhitewithsmallblack'] = 0x25A3;
  12057. t['srsquare'] = 0x33DB;
  12058. t['ssabengali'] = 0x09B7;
  12059. t['ssadeva'] = 0x0937;
  12060. t['ssagujarati'] = 0x0AB7;
  12061. t['ssangcieuckorean'] = 0x3149;
  12062. t['ssanghieuhkorean'] = 0x3185;
  12063. t['ssangieungkorean'] = 0x3180;
  12064. t['ssangkiyeokkorean'] = 0x3132;
  12065. t['ssangnieunkorean'] = 0x3165;
  12066. t['ssangpieupkorean'] = 0x3143;
  12067. t['ssangsioskorean'] = 0x3146;
  12068. t['ssangtikeutkorean'] = 0x3138;
  12069. t['ssuperior'] = 0xF6F2;
  12070. t['sterling'] = 0x00A3;
  12071. t['sterlingmonospace'] = 0xFFE1;
  12072. t['strokelongoverlaycmb'] = 0x0336;
  12073. t['strokeshortoverlaycmb'] = 0x0335;
  12074. t['subset'] = 0x2282;
  12075. t['subsetnotequal'] = 0x228A;
  12076. t['subsetorequal'] = 0x2286;
  12077. t['succeeds'] = 0x227B;
  12078. t['suchthat'] = 0x220B;
  12079. t['suhiragana'] = 0x3059;
  12080. t['sukatakana'] = 0x30B9;
  12081. t['sukatakanahalfwidth'] = 0xFF7D;
  12082. t['sukunarabic'] = 0x0652;
  12083. t['summation'] = 0x2211;
  12084. t['sun'] = 0x263C;
  12085. t['superset'] = 0x2283;
  12086. t['supersetnotequal'] = 0x228B;
  12087. t['supersetorequal'] = 0x2287;
  12088. t['svsquare'] = 0x33DC;
  12089. t['syouwaerasquare'] = 0x337C;
  12090. t['t'] = 0x0074;
  12091. t['tabengali'] = 0x09A4;
  12092. t['tackdown'] = 0x22A4;
  12093. t['tackleft'] = 0x22A3;
  12094. t['tadeva'] = 0x0924;
  12095. t['tagujarati'] = 0x0AA4;
  12096. t['tagurmukhi'] = 0x0A24;
  12097. t['taharabic'] = 0x0637;
  12098. t['tahfinalarabic'] = 0xFEC2;
  12099. t['tahinitialarabic'] = 0xFEC3;
  12100. t['tahiragana'] = 0x305F;
  12101. t['tahmedialarabic'] = 0xFEC4;
  12102. t['taisyouerasquare'] = 0x337D;
  12103. t['takatakana'] = 0x30BF;
  12104. t['takatakanahalfwidth'] = 0xFF80;
  12105. t['tatweelarabic'] = 0x0640;
  12106. t['tau'] = 0x03C4;
  12107. t['tav'] = 0x05EA;
  12108. t['tavdages'] = 0xFB4A;
  12109. t['tavdagesh'] = 0xFB4A;
  12110. t['tavdageshhebrew'] = 0xFB4A;
  12111. t['tavhebrew'] = 0x05EA;
  12112. t['tbar'] = 0x0167;
  12113. t['tbopomofo'] = 0x310A;
  12114. t['tcaron'] = 0x0165;
  12115. t['tccurl'] = 0x02A8;
  12116. t['tcedilla'] = 0x0163;
  12117. t['tcheharabic'] = 0x0686;
  12118. t['tchehfinalarabic'] = 0xFB7B;
  12119. t['tchehinitialarabic'] = 0xFB7C;
  12120. t['tchehmedialarabic'] = 0xFB7D;
  12121. t['tcircle'] = 0x24E3;
  12122. t['tcircumflexbelow'] = 0x1E71;
  12123. t['tcommaaccent'] = 0x0163;
  12124. t['tdieresis'] = 0x1E97;
  12125. t['tdotaccent'] = 0x1E6B;
  12126. t['tdotbelow'] = 0x1E6D;
  12127. t['tecyrillic'] = 0x0442;
  12128. t['tedescendercyrillic'] = 0x04AD;
  12129. t['teharabic'] = 0x062A;
  12130. t['tehfinalarabic'] = 0xFE96;
  12131. t['tehhahinitialarabic'] = 0xFCA2;
  12132. t['tehhahisolatedarabic'] = 0xFC0C;
  12133. t['tehinitialarabic'] = 0xFE97;
  12134. t['tehiragana'] = 0x3066;
  12135. t['tehjeeminitialarabic'] = 0xFCA1;
  12136. t['tehjeemisolatedarabic'] = 0xFC0B;
  12137. t['tehmarbutaarabic'] = 0x0629;
  12138. t['tehmarbutafinalarabic'] = 0xFE94;
  12139. t['tehmedialarabic'] = 0xFE98;
  12140. t['tehmeeminitialarabic'] = 0xFCA4;
  12141. t['tehmeemisolatedarabic'] = 0xFC0E;
  12142. t['tehnoonfinalarabic'] = 0xFC73;
  12143. t['tekatakana'] = 0x30C6;
  12144. t['tekatakanahalfwidth'] = 0xFF83;
  12145. t['telephone'] = 0x2121;
  12146. t['telephoneblack'] = 0x260E;
  12147. t['telishagedolahebrew'] = 0x05A0;
  12148. t['telishaqetanahebrew'] = 0x05A9;
  12149. t['tencircle'] = 0x2469;
  12150. t['tenideographicparen'] = 0x3229;
  12151. t['tenparen'] = 0x247D;
  12152. t['tenperiod'] = 0x2491;
  12153. t['tenroman'] = 0x2179;
  12154. t['tesh'] = 0x02A7;
  12155. t['tet'] = 0x05D8;
  12156. t['tetdagesh'] = 0xFB38;
  12157. t['tetdageshhebrew'] = 0xFB38;
  12158. t['tethebrew'] = 0x05D8;
  12159. t['tetsecyrillic'] = 0x04B5;
  12160. t['tevirhebrew'] = 0x059B;
  12161. t['tevirlefthebrew'] = 0x059B;
  12162. t['thabengali'] = 0x09A5;
  12163. t['thadeva'] = 0x0925;
  12164. t['thagujarati'] = 0x0AA5;
  12165. t['thagurmukhi'] = 0x0A25;
  12166. t['thalarabic'] = 0x0630;
  12167. t['thalfinalarabic'] = 0xFEAC;
  12168. t['thanthakhatlowleftthai'] = 0xF898;
  12169. t['thanthakhatlowrightthai'] = 0xF897;
  12170. t['thanthakhatthai'] = 0x0E4C;
  12171. t['thanthakhatupperleftthai'] = 0xF896;
  12172. t['theharabic'] = 0x062B;
  12173. t['thehfinalarabic'] = 0xFE9A;
  12174. t['thehinitialarabic'] = 0xFE9B;
  12175. t['thehmedialarabic'] = 0xFE9C;
  12176. t['thereexists'] = 0x2203;
  12177. t['therefore'] = 0x2234;
  12178. t['theta'] = 0x03B8;
  12179. t['theta1'] = 0x03D1;
  12180. t['thetasymbolgreek'] = 0x03D1;
  12181. t['thieuthacirclekorean'] = 0x3279;
  12182. t['thieuthaparenkorean'] = 0x3219;
  12183. t['thieuthcirclekorean'] = 0x326B;
  12184. t['thieuthkorean'] = 0x314C;
  12185. t['thieuthparenkorean'] = 0x320B;
  12186. t['thirteencircle'] = 0x246C;
  12187. t['thirteenparen'] = 0x2480;
  12188. t['thirteenperiod'] = 0x2494;
  12189. t['thonangmonthothai'] = 0x0E11;
  12190. t['thook'] = 0x01AD;
  12191. t['thophuthaothai'] = 0x0E12;
  12192. t['thorn'] = 0x00FE;
  12193. t['thothahanthai'] = 0x0E17;
  12194. t['thothanthai'] = 0x0E10;
  12195. t['thothongthai'] = 0x0E18;
  12196. t['thothungthai'] = 0x0E16;
  12197. t['thousandcyrillic'] = 0x0482;
  12198. t['thousandsseparatorarabic'] = 0x066C;
  12199. t['thousandsseparatorpersian'] = 0x066C;
  12200. t['three'] = 0x0033;
  12201. t['threearabic'] = 0x0663;
  12202. t['threebengali'] = 0x09E9;
  12203. t['threecircle'] = 0x2462;
  12204. t['threecircleinversesansserif'] = 0x278C;
  12205. t['threedeva'] = 0x0969;
  12206. t['threeeighths'] = 0x215C;
  12207. t['threegujarati'] = 0x0AE9;
  12208. t['threegurmukhi'] = 0x0A69;
  12209. t['threehackarabic'] = 0x0663;
  12210. t['threehangzhou'] = 0x3023;
  12211. t['threeideographicparen'] = 0x3222;
  12212. t['threeinferior'] = 0x2083;
  12213. t['threemonospace'] = 0xFF13;
  12214. t['threenumeratorbengali'] = 0x09F6;
  12215. t['threeoldstyle'] = 0xF733;
  12216. t['threeparen'] = 0x2476;
  12217. t['threeperiod'] = 0x248A;
  12218. t['threepersian'] = 0x06F3;
  12219. t['threequarters'] = 0x00BE;
  12220. t['threequartersemdash'] = 0xF6DE;
  12221. t['threeroman'] = 0x2172;
  12222. t['threesuperior'] = 0x00B3;
  12223. t['threethai'] = 0x0E53;
  12224. t['thzsquare'] = 0x3394;
  12225. t['tihiragana'] = 0x3061;
  12226. t['tikatakana'] = 0x30C1;
  12227. t['tikatakanahalfwidth'] = 0xFF81;
  12228. t['tikeutacirclekorean'] = 0x3270;
  12229. t['tikeutaparenkorean'] = 0x3210;
  12230. t['tikeutcirclekorean'] = 0x3262;
  12231. t['tikeutkorean'] = 0x3137;
  12232. t['tikeutparenkorean'] = 0x3202;
  12233. t['tilde'] = 0x02DC;
  12234. t['tildebelowcmb'] = 0x0330;
  12235. t['tildecmb'] = 0x0303;
  12236. t['tildecomb'] = 0x0303;
  12237. t['tildedoublecmb'] = 0x0360;
  12238. t['tildeoperator'] = 0x223C;
  12239. t['tildeoverlaycmb'] = 0x0334;
  12240. t['tildeverticalcmb'] = 0x033E;
  12241. t['timescircle'] = 0x2297;
  12242. t['tipehahebrew'] = 0x0596;
  12243. t['tipehalefthebrew'] = 0x0596;
  12244. t['tippigurmukhi'] = 0x0A70;
  12245. t['titlocyrilliccmb'] = 0x0483;
  12246. t['tiwnarmenian'] = 0x057F;
  12247. t['tlinebelow'] = 0x1E6F;
  12248. t['tmonospace'] = 0xFF54;
  12249. t['toarmenian'] = 0x0569;
  12250. t['tohiragana'] = 0x3068;
  12251. t['tokatakana'] = 0x30C8;
  12252. t['tokatakanahalfwidth'] = 0xFF84;
  12253. t['tonebarextrahighmod'] = 0x02E5;
  12254. t['tonebarextralowmod'] = 0x02E9;
  12255. t['tonebarhighmod'] = 0x02E6;
  12256. t['tonebarlowmod'] = 0x02E8;
  12257. t['tonebarmidmod'] = 0x02E7;
  12258. t['tonefive'] = 0x01BD;
  12259. t['tonesix'] = 0x0185;
  12260. t['tonetwo'] = 0x01A8;
  12261. t['tonos'] = 0x0384;
  12262. t['tonsquare'] = 0x3327;
  12263. t['topatakthai'] = 0x0E0F;
  12264. t['tortoiseshellbracketleft'] = 0x3014;
  12265. t['tortoiseshellbracketleftsmall'] = 0xFE5D;
  12266. t['tortoiseshellbracketleftvertical'] = 0xFE39;
  12267. t['tortoiseshellbracketright'] = 0x3015;
  12268. t['tortoiseshellbracketrightsmall'] = 0xFE5E;
  12269. t['tortoiseshellbracketrightvertical'] = 0xFE3A;
  12270. t['totaothai'] = 0x0E15;
  12271. t['tpalatalhook'] = 0x01AB;
  12272. t['tparen'] = 0x24AF;
  12273. t['trademark'] = 0x2122;
  12274. t['trademarksans'] = 0xF8EA;
  12275. t['trademarkserif'] = 0xF6DB;
  12276. t['tretroflexhook'] = 0x0288;
  12277. t['triagdn'] = 0x25BC;
  12278. t['triaglf'] = 0x25C4;
  12279. t['triagrt'] = 0x25BA;
  12280. t['triagup'] = 0x25B2;
  12281. t['ts'] = 0x02A6;
  12282. t['tsadi'] = 0x05E6;
  12283. t['tsadidagesh'] = 0xFB46;
  12284. t['tsadidageshhebrew'] = 0xFB46;
  12285. t['tsadihebrew'] = 0x05E6;
  12286. t['tsecyrillic'] = 0x0446;
  12287. t['tsere'] = 0x05B5;
  12288. t['tsere12'] = 0x05B5;
  12289. t['tsere1e'] = 0x05B5;
  12290. t['tsere2b'] = 0x05B5;
  12291. t['tserehebrew'] = 0x05B5;
  12292. t['tserenarrowhebrew'] = 0x05B5;
  12293. t['tserequarterhebrew'] = 0x05B5;
  12294. t['tserewidehebrew'] = 0x05B5;
  12295. t['tshecyrillic'] = 0x045B;
  12296. t['tsuperior'] = 0xF6F3;
  12297. t['ttabengali'] = 0x099F;
  12298. t['ttadeva'] = 0x091F;
  12299. t['ttagujarati'] = 0x0A9F;
  12300. t['ttagurmukhi'] = 0x0A1F;
  12301. t['tteharabic'] = 0x0679;
  12302. t['ttehfinalarabic'] = 0xFB67;
  12303. t['ttehinitialarabic'] = 0xFB68;
  12304. t['ttehmedialarabic'] = 0xFB69;
  12305. t['tthabengali'] = 0x09A0;
  12306. t['tthadeva'] = 0x0920;
  12307. t['tthagujarati'] = 0x0AA0;
  12308. t['tthagurmukhi'] = 0x0A20;
  12309. t['tturned'] = 0x0287;
  12310. t['tuhiragana'] = 0x3064;
  12311. t['tukatakana'] = 0x30C4;
  12312. t['tukatakanahalfwidth'] = 0xFF82;
  12313. t['tusmallhiragana'] = 0x3063;
  12314. t['tusmallkatakana'] = 0x30C3;
  12315. t['tusmallkatakanahalfwidth'] = 0xFF6F;
  12316. t['twelvecircle'] = 0x246B;
  12317. t['twelveparen'] = 0x247F;
  12318. t['twelveperiod'] = 0x2493;
  12319. t['twelveroman'] = 0x217B;
  12320. t['twentycircle'] = 0x2473;
  12321. t['twentyhangzhou'] = 0x5344;
  12322. t['twentyparen'] = 0x2487;
  12323. t['twentyperiod'] = 0x249B;
  12324. t['two'] = 0x0032;
  12325. t['twoarabic'] = 0x0662;
  12326. t['twobengali'] = 0x09E8;
  12327. t['twocircle'] = 0x2461;
  12328. t['twocircleinversesansserif'] = 0x278B;
  12329. t['twodeva'] = 0x0968;
  12330. t['twodotenleader'] = 0x2025;
  12331. t['twodotleader'] = 0x2025;
  12332. t['twodotleadervertical'] = 0xFE30;
  12333. t['twogujarati'] = 0x0AE8;
  12334. t['twogurmukhi'] = 0x0A68;
  12335. t['twohackarabic'] = 0x0662;
  12336. t['twohangzhou'] = 0x3022;
  12337. t['twoideographicparen'] = 0x3221;
  12338. t['twoinferior'] = 0x2082;
  12339. t['twomonospace'] = 0xFF12;
  12340. t['twonumeratorbengali'] = 0x09F5;
  12341. t['twooldstyle'] = 0xF732;
  12342. t['twoparen'] = 0x2475;
  12343. t['twoperiod'] = 0x2489;
  12344. t['twopersian'] = 0x06F2;
  12345. t['tworoman'] = 0x2171;
  12346. t['twostroke'] = 0x01BB;
  12347. t['twosuperior'] = 0x00B2;
  12348. t['twothai'] = 0x0E52;
  12349. t['twothirds'] = 0x2154;
  12350. t['u'] = 0x0075;
  12351. t['uacute'] = 0x00FA;
  12352. t['ubar'] = 0x0289;
  12353. t['ubengali'] = 0x0989;
  12354. t['ubopomofo'] = 0x3128;
  12355. t['ubreve'] = 0x016D;
  12356. t['ucaron'] = 0x01D4;
  12357. t['ucircle'] = 0x24E4;
  12358. t['ucircumflex'] = 0x00FB;
  12359. t['ucircumflexbelow'] = 0x1E77;
  12360. t['ucyrillic'] = 0x0443;
  12361. t['udattadeva'] = 0x0951;
  12362. t['udblacute'] = 0x0171;
  12363. t['udblgrave'] = 0x0215;
  12364. t['udeva'] = 0x0909;
  12365. t['udieresis'] = 0x00FC;
  12366. t['udieresisacute'] = 0x01D8;
  12367. t['udieresisbelow'] = 0x1E73;
  12368. t['udieresiscaron'] = 0x01DA;
  12369. t['udieresiscyrillic'] = 0x04F1;
  12370. t['udieresisgrave'] = 0x01DC;
  12371. t['udieresismacron'] = 0x01D6;
  12372. t['udotbelow'] = 0x1EE5;
  12373. t['ugrave'] = 0x00F9;
  12374. t['ugujarati'] = 0x0A89;
  12375. t['ugurmukhi'] = 0x0A09;
  12376. t['uhiragana'] = 0x3046;
  12377. t['uhookabove'] = 0x1EE7;
  12378. t['uhorn'] = 0x01B0;
  12379. t['uhornacute'] = 0x1EE9;
  12380. t['uhorndotbelow'] = 0x1EF1;
  12381. t['uhorngrave'] = 0x1EEB;
  12382. t['uhornhookabove'] = 0x1EED;
  12383. t['uhorntilde'] = 0x1EEF;
  12384. t['uhungarumlaut'] = 0x0171;
  12385. t['uhungarumlautcyrillic'] = 0x04F3;
  12386. t['uinvertedbreve'] = 0x0217;
  12387. t['ukatakana'] = 0x30A6;
  12388. t['ukatakanahalfwidth'] = 0xFF73;
  12389. t['ukcyrillic'] = 0x0479;
  12390. t['ukorean'] = 0x315C;
  12391. t['umacron'] = 0x016B;
  12392. t['umacroncyrillic'] = 0x04EF;
  12393. t['umacrondieresis'] = 0x1E7B;
  12394. t['umatragurmukhi'] = 0x0A41;
  12395. t['umonospace'] = 0xFF55;
  12396. t['underscore'] = 0x005F;
  12397. t['underscoredbl'] = 0x2017;
  12398. t['underscoremonospace'] = 0xFF3F;
  12399. t['underscorevertical'] = 0xFE33;
  12400. t['underscorewavy'] = 0xFE4F;
  12401. t['union'] = 0x222A;
  12402. t['universal'] = 0x2200;
  12403. t['uogonek'] = 0x0173;
  12404. t['uparen'] = 0x24B0;
  12405. t['upblock'] = 0x2580;
  12406. t['upperdothebrew'] = 0x05C4;
  12407. t['upsilon'] = 0x03C5;
  12408. t['upsilondieresis'] = 0x03CB;
  12409. t['upsilondieresistonos'] = 0x03B0;
  12410. t['upsilonlatin'] = 0x028A;
  12411. t['upsilontonos'] = 0x03CD;
  12412. t['uptackbelowcmb'] = 0x031D;
  12413. t['uptackmod'] = 0x02D4;
  12414. t['uragurmukhi'] = 0x0A73;
  12415. t['uring'] = 0x016F;
  12416. t['ushortcyrillic'] = 0x045E;
  12417. t['usmallhiragana'] = 0x3045;
  12418. t['usmallkatakana'] = 0x30A5;
  12419. t['usmallkatakanahalfwidth'] = 0xFF69;
  12420. t['ustraightcyrillic'] = 0x04AF;
  12421. t['ustraightstrokecyrillic'] = 0x04B1;
  12422. t['utilde'] = 0x0169;
  12423. t['utildeacute'] = 0x1E79;
  12424. t['utildebelow'] = 0x1E75;
  12425. t['uubengali'] = 0x098A;
  12426. t['uudeva'] = 0x090A;
  12427. t['uugujarati'] = 0x0A8A;
  12428. t['uugurmukhi'] = 0x0A0A;
  12429. t['uumatragurmukhi'] = 0x0A42;
  12430. t['uuvowelsignbengali'] = 0x09C2;
  12431. t['uuvowelsigndeva'] = 0x0942;
  12432. t['uuvowelsigngujarati'] = 0x0AC2;
  12433. t['uvowelsignbengali'] = 0x09C1;
  12434. t['uvowelsigndeva'] = 0x0941;
  12435. t['uvowelsigngujarati'] = 0x0AC1;
  12436. t['v'] = 0x0076;
  12437. t['vadeva'] = 0x0935;
  12438. t['vagujarati'] = 0x0AB5;
  12439. t['vagurmukhi'] = 0x0A35;
  12440. t['vakatakana'] = 0x30F7;
  12441. t['vav'] = 0x05D5;
  12442. t['vavdagesh'] = 0xFB35;
  12443. t['vavdagesh65'] = 0xFB35;
  12444. t['vavdageshhebrew'] = 0xFB35;
  12445. t['vavhebrew'] = 0x05D5;
  12446. t['vavholam'] = 0xFB4B;
  12447. t['vavholamhebrew'] = 0xFB4B;
  12448. t['vavvavhebrew'] = 0x05F0;
  12449. t['vavyodhebrew'] = 0x05F1;
  12450. t['vcircle'] = 0x24E5;
  12451. t['vdotbelow'] = 0x1E7F;
  12452. t['vecyrillic'] = 0x0432;
  12453. t['veharabic'] = 0x06A4;
  12454. t['vehfinalarabic'] = 0xFB6B;
  12455. t['vehinitialarabic'] = 0xFB6C;
  12456. t['vehmedialarabic'] = 0xFB6D;
  12457. t['vekatakana'] = 0x30F9;
  12458. t['venus'] = 0x2640;
  12459. t['verticalbar'] = 0x007C;
  12460. t['verticallineabovecmb'] = 0x030D;
  12461. t['verticallinebelowcmb'] = 0x0329;
  12462. t['verticallinelowmod'] = 0x02CC;
  12463. t['verticallinemod'] = 0x02C8;
  12464. t['vewarmenian'] = 0x057E;
  12465. t['vhook'] = 0x028B;
  12466. t['vikatakana'] = 0x30F8;
  12467. t['viramabengali'] = 0x09CD;
  12468. t['viramadeva'] = 0x094D;
  12469. t['viramagujarati'] = 0x0ACD;
  12470. t['visargabengali'] = 0x0983;
  12471. t['visargadeva'] = 0x0903;
  12472. t['visargagujarati'] = 0x0A83;
  12473. t['vmonospace'] = 0xFF56;
  12474. t['voarmenian'] = 0x0578;
  12475. t['voicediterationhiragana'] = 0x309E;
  12476. t['voicediterationkatakana'] = 0x30FE;
  12477. t['voicedmarkkana'] = 0x309B;
  12478. t['voicedmarkkanahalfwidth'] = 0xFF9E;
  12479. t['vokatakana'] = 0x30FA;
  12480. t['vparen'] = 0x24B1;
  12481. t['vtilde'] = 0x1E7D;
  12482. t['vturned'] = 0x028C;
  12483. t['vuhiragana'] = 0x3094;
  12484. t['vukatakana'] = 0x30F4;
  12485. t['w'] = 0x0077;
  12486. t['wacute'] = 0x1E83;
  12487. t['waekorean'] = 0x3159;
  12488. t['wahiragana'] = 0x308F;
  12489. t['wakatakana'] = 0x30EF;
  12490. t['wakatakanahalfwidth'] = 0xFF9C;
  12491. t['wakorean'] = 0x3158;
  12492. t['wasmallhiragana'] = 0x308E;
  12493. t['wasmallkatakana'] = 0x30EE;
  12494. t['wattosquare'] = 0x3357;
  12495. t['wavedash'] = 0x301C;
  12496. t['wavyunderscorevertical'] = 0xFE34;
  12497. t['wawarabic'] = 0x0648;
  12498. t['wawfinalarabic'] = 0xFEEE;
  12499. t['wawhamzaabovearabic'] = 0x0624;
  12500. t['wawhamzaabovefinalarabic'] = 0xFE86;
  12501. t['wbsquare'] = 0x33DD;
  12502. t['wcircle'] = 0x24E6;
  12503. t['wcircumflex'] = 0x0175;
  12504. t['wdieresis'] = 0x1E85;
  12505. t['wdotaccent'] = 0x1E87;
  12506. t['wdotbelow'] = 0x1E89;
  12507. t['wehiragana'] = 0x3091;
  12508. t['weierstrass'] = 0x2118;
  12509. t['wekatakana'] = 0x30F1;
  12510. t['wekorean'] = 0x315E;
  12511. t['weokorean'] = 0x315D;
  12512. t['wgrave'] = 0x1E81;
  12513. t['whitebullet'] = 0x25E6;
  12514. t['whitecircle'] = 0x25CB;
  12515. t['whitecircleinverse'] = 0x25D9;
  12516. t['whitecornerbracketleft'] = 0x300E;
  12517. t['whitecornerbracketleftvertical'] = 0xFE43;
  12518. t['whitecornerbracketright'] = 0x300F;
  12519. t['whitecornerbracketrightvertical'] = 0xFE44;
  12520. t['whitediamond'] = 0x25C7;
  12521. t['whitediamondcontainingblacksmalldiamond'] = 0x25C8;
  12522. t['whitedownpointingsmalltriangle'] = 0x25BF;
  12523. t['whitedownpointingtriangle'] = 0x25BD;
  12524. t['whiteleftpointingsmalltriangle'] = 0x25C3;
  12525. t['whiteleftpointingtriangle'] = 0x25C1;
  12526. t['whitelenticularbracketleft'] = 0x3016;
  12527. t['whitelenticularbracketright'] = 0x3017;
  12528. t['whiterightpointingsmalltriangle'] = 0x25B9;
  12529. t['whiterightpointingtriangle'] = 0x25B7;
  12530. t['whitesmallsquare'] = 0x25AB;
  12531. t['whitesmilingface'] = 0x263A;
  12532. t['whitesquare'] = 0x25A1;
  12533. t['whitestar'] = 0x2606;
  12534. t['whitetelephone'] = 0x260F;
  12535. t['whitetortoiseshellbracketleft'] = 0x3018;
  12536. t['whitetortoiseshellbracketright'] = 0x3019;
  12537. t['whiteuppointingsmalltriangle'] = 0x25B5;
  12538. t['whiteuppointingtriangle'] = 0x25B3;
  12539. t['wihiragana'] = 0x3090;
  12540. t['wikatakana'] = 0x30F0;
  12541. t['wikorean'] = 0x315F;
  12542. t['wmonospace'] = 0xFF57;
  12543. t['wohiragana'] = 0x3092;
  12544. t['wokatakana'] = 0x30F2;
  12545. t['wokatakanahalfwidth'] = 0xFF66;
  12546. t['won'] = 0x20A9;
  12547. t['wonmonospace'] = 0xFFE6;
  12548. t['wowaenthai'] = 0x0E27;
  12549. t['wparen'] = 0x24B2;
  12550. t['wring'] = 0x1E98;
  12551. t['wsuperior'] = 0x02B7;
  12552. t['wturned'] = 0x028D;
  12553. t['wynn'] = 0x01BF;
  12554. t['x'] = 0x0078;
  12555. t['xabovecmb'] = 0x033D;
  12556. t['xbopomofo'] = 0x3112;
  12557. t['xcircle'] = 0x24E7;
  12558. t['xdieresis'] = 0x1E8D;
  12559. t['xdotaccent'] = 0x1E8B;
  12560. t['xeharmenian'] = 0x056D;
  12561. t['xi'] = 0x03BE;
  12562. t['xmonospace'] = 0xFF58;
  12563. t['xparen'] = 0x24B3;
  12564. t['xsuperior'] = 0x02E3;
  12565. t['y'] = 0x0079;
  12566. t['yaadosquare'] = 0x334E;
  12567. t['yabengali'] = 0x09AF;
  12568. t['yacute'] = 0x00FD;
  12569. t['yadeva'] = 0x092F;
  12570. t['yaekorean'] = 0x3152;
  12571. t['yagujarati'] = 0x0AAF;
  12572. t['yagurmukhi'] = 0x0A2F;
  12573. t['yahiragana'] = 0x3084;
  12574. t['yakatakana'] = 0x30E4;
  12575. t['yakatakanahalfwidth'] = 0xFF94;
  12576. t['yakorean'] = 0x3151;
  12577. t['yamakkanthai'] = 0x0E4E;
  12578. t['yasmallhiragana'] = 0x3083;
  12579. t['yasmallkatakana'] = 0x30E3;
  12580. t['yasmallkatakanahalfwidth'] = 0xFF6C;
  12581. t['yatcyrillic'] = 0x0463;
  12582. t['ycircle'] = 0x24E8;
  12583. t['ycircumflex'] = 0x0177;
  12584. t['ydieresis'] = 0x00FF;
  12585. t['ydotaccent'] = 0x1E8F;
  12586. t['ydotbelow'] = 0x1EF5;
  12587. t['yeharabic'] = 0x064A;
  12588. t['yehbarreearabic'] = 0x06D2;
  12589. t['yehbarreefinalarabic'] = 0xFBAF;
  12590. t['yehfinalarabic'] = 0xFEF2;
  12591. t['yehhamzaabovearabic'] = 0x0626;
  12592. t['yehhamzaabovefinalarabic'] = 0xFE8A;
  12593. t['yehhamzaaboveinitialarabic'] = 0xFE8B;
  12594. t['yehhamzaabovemedialarabic'] = 0xFE8C;
  12595. t['yehinitialarabic'] = 0xFEF3;
  12596. t['yehmedialarabic'] = 0xFEF4;
  12597. t['yehmeeminitialarabic'] = 0xFCDD;
  12598. t['yehmeemisolatedarabic'] = 0xFC58;
  12599. t['yehnoonfinalarabic'] = 0xFC94;
  12600. t['yehthreedotsbelowarabic'] = 0x06D1;
  12601. t['yekorean'] = 0x3156;
  12602. t['yen'] = 0x00A5;
  12603. t['yenmonospace'] = 0xFFE5;
  12604. t['yeokorean'] = 0x3155;
  12605. t['yeorinhieuhkorean'] = 0x3186;
  12606. t['yerahbenyomohebrew'] = 0x05AA;
  12607. t['yerahbenyomolefthebrew'] = 0x05AA;
  12608. t['yericyrillic'] = 0x044B;
  12609. t['yerudieresiscyrillic'] = 0x04F9;
  12610. t['yesieungkorean'] = 0x3181;
  12611. t['yesieungpansioskorean'] = 0x3183;
  12612. t['yesieungsioskorean'] = 0x3182;
  12613. t['yetivhebrew'] = 0x059A;
  12614. t['ygrave'] = 0x1EF3;
  12615. t['yhook'] = 0x01B4;
  12616. t['yhookabove'] = 0x1EF7;
  12617. t['yiarmenian'] = 0x0575;
  12618. t['yicyrillic'] = 0x0457;
  12619. t['yikorean'] = 0x3162;
  12620. t['yinyang'] = 0x262F;
  12621. t['yiwnarmenian'] = 0x0582;
  12622. t['ymonospace'] = 0xFF59;
  12623. t['yod'] = 0x05D9;
  12624. t['yoddagesh'] = 0xFB39;
  12625. t['yoddageshhebrew'] = 0xFB39;
  12626. t['yodhebrew'] = 0x05D9;
  12627. t['yodyodhebrew'] = 0x05F2;
  12628. t['yodyodpatahhebrew'] = 0xFB1F;
  12629. t['yohiragana'] = 0x3088;
  12630. t['yoikorean'] = 0x3189;
  12631. t['yokatakana'] = 0x30E8;
  12632. t['yokatakanahalfwidth'] = 0xFF96;
  12633. t['yokorean'] = 0x315B;
  12634. t['yosmallhiragana'] = 0x3087;
  12635. t['yosmallkatakana'] = 0x30E7;
  12636. t['yosmallkatakanahalfwidth'] = 0xFF6E;
  12637. t['yotgreek'] = 0x03F3;
  12638. t['yoyaekorean'] = 0x3188;
  12639. t['yoyakorean'] = 0x3187;
  12640. t['yoyakthai'] = 0x0E22;
  12641. t['yoyingthai'] = 0x0E0D;
  12642. t['yparen'] = 0x24B4;
  12643. t['ypogegrammeni'] = 0x037A;
  12644. t['ypogegrammenigreekcmb'] = 0x0345;
  12645. t['yr'] = 0x01A6;
  12646. t['yring'] = 0x1E99;
  12647. t['ysuperior'] = 0x02B8;
  12648. t['ytilde'] = 0x1EF9;
  12649. t['yturned'] = 0x028E;
  12650. t['yuhiragana'] = 0x3086;
  12651. t['yuikorean'] = 0x318C;
  12652. t['yukatakana'] = 0x30E6;
  12653. t['yukatakanahalfwidth'] = 0xFF95;
  12654. t['yukorean'] = 0x3160;
  12655. t['yusbigcyrillic'] = 0x046B;
  12656. t['yusbigiotifiedcyrillic'] = 0x046D;
  12657. t['yuslittlecyrillic'] = 0x0467;
  12658. t['yuslittleiotifiedcyrillic'] = 0x0469;
  12659. t['yusmallhiragana'] = 0x3085;
  12660. t['yusmallkatakana'] = 0x30E5;
  12661. t['yusmallkatakanahalfwidth'] = 0xFF6D;
  12662. t['yuyekorean'] = 0x318B;
  12663. t['yuyeokorean'] = 0x318A;
  12664. t['yyabengali'] = 0x09DF;
  12665. t['yyadeva'] = 0x095F;
  12666. t['z'] = 0x007A;
  12667. t['zaarmenian'] = 0x0566;
  12668. t['zacute'] = 0x017A;
  12669. t['zadeva'] = 0x095B;
  12670. t['zagurmukhi'] = 0x0A5B;
  12671. t['zaharabic'] = 0x0638;
  12672. t['zahfinalarabic'] = 0xFEC6;
  12673. t['zahinitialarabic'] = 0xFEC7;
  12674. t['zahiragana'] = 0x3056;
  12675. t['zahmedialarabic'] = 0xFEC8;
  12676. t['zainarabic'] = 0x0632;
  12677. t['zainfinalarabic'] = 0xFEB0;
  12678. t['zakatakana'] = 0x30B6;
  12679. t['zaqefgadolhebrew'] = 0x0595;
  12680. t['zaqefqatanhebrew'] = 0x0594;
  12681. t['zarqahebrew'] = 0x0598;
  12682. t['zayin'] = 0x05D6;
  12683. t['zayindagesh'] = 0xFB36;
  12684. t['zayindageshhebrew'] = 0xFB36;
  12685. t['zayinhebrew'] = 0x05D6;
  12686. t['zbopomofo'] = 0x3117;
  12687. t['zcaron'] = 0x017E;
  12688. t['zcircle'] = 0x24E9;
  12689. t['zcircumflex'] = 0x1E91;
  12690. t['zcurl'] = 0x0291;
  12691. t['zdot'] = 0x017C;
  12692. t['zdotaccent'] = 0x017C;
  12693. t['zdotbelow'] = 0x1E93;
  12694. t['zecyrillic'] = 0x0437;
  12695. t['zedescendercyrillic'] = 0x0499;
  12696. t['zedieresiscyrillic'] = 0x04DF;
  12697. t['zehiragana'] = 0x305C;
  12698. t['zekatakana'] = 0x30BC;
  12699. t['zero'] = 0x0030;
  12700. t['zeroarabic'] = 0x0660;
  12701. t['zerobengali'] = 0x09E6;
  12702. t['zerodeva'] = 0x0966;
  12703. t['zerogujarati'] = 0x0AE6;
  12704. t['zerogurmukhi'] = 0x0A66;
  12705. t['zerohackarabic'] = 0x0660;
  12706. t['zeroinferior'] = 0x2080;
  12707. t['zeromonospace'] = 0xFF10;
  12708. t['zerooldstyle'] = 0xF730;
  12709. t['zeropersian'] = 0x06F0;
  12710. t['zerosuperior'] = 0x2070;
  12711. t['zerothai'] = 0x0E50;
  12712. t['zerowidthjoiner'] = 0xFEFF;
  12713. t['zerowidthnonjoiner'] = 0x200C;
  12714. t['zerowidthspace'] = 0x200B;
  12715. t['zeta'] = 0x03B6;
  12716. t['zhbopomofo'] = 0x3113;
  12717. t['zhearmenian'] = 0x056A;
  12718. t['zhebrevecyrillic'] = 0x04C2;
  12719. t['zhecyrillic'] = 0x0436;
  12720. t['zhedescendercyrillic'] = 0x0497;
  12721. t['zhedieresiscyrillic'] = 0x04DD;
  12722. t['zihiragana'] = 0x3058;
  12723. t['zikatakana'] = 0x30B8;
  12724. t['zinorhebrew'] = 0x05AE;
  12725. t['zlinebelow'] = 0x1E95;
  12726. t['zmonospace'] = 0xFF5A;
  12727. t['zohiragana'] = 0x305E;
  12728. t['zokatakana'] = 0x30BE;
  12729. t['zparen'] = 0x24B5;
  12730. t['zretroflexhook'] = 0x0290;
  12731. t['zstroke'] = 0x01B6;
  12732. t['zuhiragana'] = 0x305A;
  12733. t['zukatakana'] = 0x30BA;
  12734. t['.notdef'] = 0x0000;
  12735. });
  12736. var getDingbatsGlyphsUnicode = getLookupTableFactory(function (t) {
  12737. t['space'] = 0x0020;
  12738. t['a1'] = 0x2701;
  12739. t['a2'] = 0x2702;
  12740. t['a202'] = 0x2703;
  12741. t['a3'] = 0x2704;
  12742. t['a4'] = 0x260E;
  12743. t['a5'] = 0x2706;
  12744. t['a119'] = 0x2707;
  12745. t['a118'] = 0x2708;
  12746. t['a117'] = 0x2709;
  12747. t['a11'] = 0x261B;
  12748. t['a12'] = 0x261E;
  12749. t['a13'] = 0x270C;
  12750. t['a14'] = 0x270D;
  12751. t['a15'] = 0x270E;
  12752. t['a16'] = 0x270F;
  12753. t['a105'] = 0x2710;
  12754. t['a17'] = 0x2711;
  12755. t['a18'] = 0x2712;
  12756. t['a19'] = 0x2713;
  12757. t['a20'] = 0x2714;
  12758. t['a21'] = 0x2715;
  12759. t['a22'] = 0x2716;
  12760. t['a23'] = 0x2717;
  12761. t['a24'] = 0x2718;
  12762. t['a25'] = 0x2719;
  12763. t['a26'] = 0x271A;
  12764. t['a27'] = 0x271B;
  12765. t['a28'] = 0x271C;
  12766. t['a6'] = 0x271D;
  12767. t['a7'] = 0x271E;
  12768. t['a8'] = 0x271F;
  12769. t['a9'] = 0x2720;
  12770. t['a10'] = 0x2721;
  12771. t['a29'] = 0x2722;
  12772. t['a30'] = 0x2723;
  12773. t['a31'] = 0x2724;
  12774. t['a32'] = 0x2725;
  12775. t['a33'] = 0x2726;
  12776. t['a34'] = 0x2727;
  12777. t['a35'] = 0x2605;
  12778. t['a36'] = 0x2729;
  12779. t['a37'] = 0x272A;
  12780. t['a38'] = 0x272B;
  12781. t['a39'] = 0x272C;
  12782. t['a40'] = 0x272D;
  12783. t['a41'] = 0x272E;
  12784. t['a42'] = 0x272F;
  12785. t['a43'] = 0x2730;
  12786. t['a44'] = 0x2731;
  12787. t['a45'] = 0x2732;
  12788. t['a46'] = 0x2733;
  12789. t['a47'] = 0x2734;
  12790. t['a48'] = 0x2735;
  12791. t['a49'] = 0x2736;
  12792. t['a50'] = 0x2737;
  12793. t['a51'] = 0x2738;
  12794. t['a52'] = 0x2739;
  12795. t['a53'] = 0x273A;
  12796. t['a54'] = 0x273B;
  12797. t['a55'] = 0x273C;
  12798. t['a56'] = 0x273D;
  12799. t['a57'] = 0x273E;
  12800. t['a58'] = 0x273F;
  12801. t['a59'] = 0x2740;
  12802. t['a60'] = 0x2741;
  12803. t['a61'] = 0x2742;
  12804. t['a62'] = 0x2743;
  12805. t['a63'] = 0x2744;
  12806. t['a64'] = 0x2745;
  12807. t['a65'] = 0x2746;
  12808. t['a66'] = 0x2747;
  12809. t['a67'] = 0x2748;
  12810. t['a68'] = 0x2749;
  12811. t['a69'] = 0x274A;
  12812. t['a70'] = 0x274B;
  12813. t['a71'] = 0x25CF;
  12814. t['a72'] = 0x274D;
  12815. t['a73'] = 0x25A0;
  12816. t['a74'] = 0x274F;
  12817. t['a203'] = 0x2750;
  12818. t['a75'] = 0x2751;
  12819. t['a204'] = 0x2752;
  12820. t['a76'] = 0x25B2;
  12821. t['a77'] = 0x25BC;
  12822. t['a78'] = 0x25C6;
  12823. t['a79'] = 0x2756;
  12824. t['a81'] = 0x25D7;
  12825. t['a82'] = 0x2758;
  12826. t['a83'] = 0x2759;
  12827. t['a84'] = 0x275A;
  12828. t['a97'] = 0x275B;
  12829. t['a98'] = 0x275C;
  12830. t['a99'] = 0x275D;
  12831. t['a100'] = 0x275E;
  12832. t['a101'] = 0x2761;
  12833. t['a102'] = 0x2762;
  12834. t['a103'] = 0x2763;
  12835. t['a104'] = 0x2764;
  12836. t['a106'] = 0x2765;
  12837. t['a107'] = 0x2766;
  12838. t['a108'] = 0x2767;
  12839. t['a112'] = 0x2663;
  12840. t['a111'] = 0x2666;
  12841. t['a110'] = 0x2665;
  12842. t['a109'] = 0x2660;
  12843. t['a120'] = 0x2460;
  12844. t['a121'] = 0x2461;
  12845. t['a122'] = 0x2462;
  12846. t['a123'] = 0x2463;
  12847. t['a124'] = 0x2464;
  12848. t['a125'] = 0x2465;
  12849. t['a126'] = 0x2466;
  12850. t['a127'] = 0x2467;
  12851. t['a128'] = 0x2468;
  12852. t['a129'] = 0x2469;
  12853. t['a130'] = 0x2776;
  12854. t['a131'] = 0x2777;
  12855. t['a132'] = 0x2778;
  12856. t['a133'] = 0x2779;
  12857. t['a134'] = 0x277A;
  12858. t['a135'] = 0x277B;
  12859. t['a136'] = 0x277C;
  12860. t['a137'] = 0x277D;
  12861. t['a138'] = 0x277E;
  12862. t['a139'] = 0x277F;
  12863. t['a140'] = 0x2780;
  12864. t['a141'] = 0x2781;
  12865. t['a142'] = 0x2782;
  12866. t['a143'] = 0x2783;
  12867. t['a144'] = 0x2784;
  12868. t['a145'] = 0x2785;
  12869. t['a146'] = 0x2786;
  12870. t['a147'] = 0x2787;
  12871. t['a148'] = 0x2788;
  12872. t['a149'] = 0x2789;
  12873. t['a150'] = 0x278A;
  12874. t['a151'] = 0x278B;
  12875. t['a152'] = 0x278C;
  12876. t['a153'] = 0x278D;
  12877. t['a154'] = 0x278E;
  12878. t['a155'] = 0x278F;
  12879. t['a156'] = 0x2790;
  12880. t['a157'] = 0x2791;
  12881. t['a158'] = 0x2792;
  12882. t['a159'] = 0x2793;
  12883. t['a160'] = 0x2794;
  12884. t['a161'] = 0x2192;
  12885. t['a163'] = 0x2194;
  12886. t['a164'] = 0x2195;
  12887. t['a196'] = 0x2798;
  12888. t['a165'] = 0x2799;
  12889. t['a192'] = 0x279A;
  12890. t['a166'] = 0x279B;
  12891. t['a167'] = 0x279C;
  12892. t['a168'] = 0x279D;
  12893. t['a169'] = 0x279E;
  12894. t['a170'] = 0x279F;
  12895. t['a171'] = 0x27A0;
  12896. t['a172'] = 0x27A1;
  12897. t['a173'] = 0x27A2;
  12898. t['a162'] = 0x27A3;
  12899. t['a174'] = 0x27A4;
  12900. t['a175'] = 0x27A5;
  12901. t['a176'] = 0x27A6;
  12902. t['a177'] = 0x27A7;
  12903. t['a178'] = 0x27A8;
  12904. t['a179'] = 0x27A9;
  12905. t['a193'] = 0x27AA;
  12906. t['a180'] = 0x27AB;
  12907. t['a199'] = 0x27AC;
  12908. t['a181'] = 0x27AD;
  12909. t['a200'] = 0x27AE;
  12910. t['a182'] = 0x27AF;
  12911. t['a201'] = 0x27B1;
  12912. t['a183'] = 0x27B2;
  12913. t['a184'] = 0x27B3;
  12914. t['a197'] = 0x27B4;
  12915. t['a185'] = 0x27B5;
  12916. t['a194'] = 0x27B6;
  12917. t['a198'] = 0x27B7;
  12918. t['a186'] = 0x27B8;
  12919. t['a195'] = 0x27B9;
  12920. t['a187'] = 0x27BA;
  12921. t['a188'] = 0x27BB;
  12922. t['a189'] = 0x27BC;
  12923. t['a190'] = 0x27BD;
  12924. t['a191'] = 0x27BE;
  12925. t['a89'] = 0x2768;
  12926. t['a90'] = 0x2769;
  12927. t['a93'] = 0x276A;
  12928. t['a94'] = 0x276B;
  12929. t['a91'] = 0x276C;
  12930. t['a92'] = 0x276D;
  12931. t['a205'] = 0x276E;
  12932. t['a85'] = 0x276F;
  12933. t['a206'] = 0x2770;
  12934. t['a86'] = 0x2771;
  12935. t['a87'] = 0x2772;
  12936. t['a88'] = 0x2773;
  12937. t['a95'] = 0x2774;
  12938. t['a96'] = 0x2775;
  12939. t['.notdef'] = 0x0000;
  12940. });
  12941. exports.getGlyphsUnicode = getGlyphsUnicode;
  12942. exports.getDingbatsGlyphsUnicode = getDingbatsGlyphsUnicode;
  12943. }));
  12944. (function (root, factory) {
  12945. factory(root.pdfjsCoreJbig2 = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  12946. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  12947. var error = sharedUtil.error;
  12948. var log2 = sharedUtil.log2;
  12949. var readInt8 = sharedUtil.readInt8;
  12950. var readUint16 = sharedUtil.readUint16;
  12951. var readUint32 = sharedUtil.readUint32;
  12952. var shadow = sharedUtil.shadow;
  12953. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  12954. var Jbig2Image = function Jbig2ImageClosure() {
  12955. function ContextCache() {
  12956. }
  12957. ContextCache.prototype = {
  12958. getContexts: function (id) {
  12959. if (id in this) {
  12960. return this[id];
  12961. }
  12962. return this[id] = new Int8Array(1 << 16);
  12963. }
  12964. };
  12965. function DecodingContext(data, start, end) {
  12966. this.data = data;
  12967. this.start = start;
  12968. this.end = end;
  12969. }
  12970. DecodingContext.prototype = {
  12971. get decoder() {
  12972. var decoder = new ArithmeticDecoder(this.data, this.start, this.end);
  12973. return shadow(this, 'decoder', decoder);
  12974. },
  12975. get contextCache() {
  12976. var cache = new ContextCache();
  12977. return shadow(this, 'contextCache', cache);
  12978. }
  12979. };
  12980. function decodeInteger(contextCache, procedure, decoder) {
  12981. var contexts = contextCache.getContexts(procedure);
  12982. var prev = 1;
  12983. function readBits(length) {
  12984. var v = 0;
  12985. for (var i = 0; i < length; i++) {
  12986. var bit = decoder.readBit(contexts, prev);
  12987. prev = prev < 256 ? prev << 1 | bit : (prev << 1 | bit) & 511 | 256;
  12988. v = v << 1 | bit;
  12989. }
  12990. return v >>> 0;
  12991. }
  12992. var sign = readBits(1);
  12993. var value = readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(1) ? readBits(32) + 4436 : readBits(12) + 340 : readBits(8) + 84 : readBits(6) + 20 : readBits(4) + 4 : readBits(2);
  12994. return sign === 0 ? value : value > 0 ? -value : null;
  12995. }
  12996. function decodeIAID(contextCache, decoder, codeLength) {
  12997. var contexts = contextCache.getContexts('IAID');
  12998. var prev = 1;
  12999. for (var i = 0; i < codeLength; i++) {
  13000. var bit = decoder.readBit(contexts, prev);
  13001. prev = prev << 1 | bit;
  13002. }
  13003. if (codeLength < 31) {
  13004. return prev & (1 << codeLength) - 1;
  13005. }
  13006. return prev & 0x7FFFFFFF;
  13007. }
  13008. var SegmentTypes = [
  13009. 'SymbolDictionary',
  13010. null,
  13011. null,
  13012. null,
  13013. 'IntermediateTextRegion',
  13014. null,
  13015. 'ImmediateTextRegion',
  13016. 'ImmediateLosslessTextRegion',
  13017. null,
  13018. null,
  13019. null,
  13020. null,
  13021. null,
  13022. null,
  13023. null,
  13024. null,
  13025. 'patternDictionary',
  13026. null,
  13027. null,
  13028. null,
  13029. 'IntermediateHalftoneRegion',
  13030. null,
  13031. 'ImmediateHalftoneRegion',
  13032. 'ImmediateLosslessHalftoneRegion',
  13033. null,
  13034. null,
  13035. null,
  13036. null,
  13037. null,
  13038. null,
  13039. null,
  13040. null,
  13041. null,
  13042. null,
  13043. null,
  13044. null,
  13045. 'IntermediateGenericRegion',
  13046. null,
  13047. 'ImmediateGenericRegion',
  13048. 'ImmediateLosslessGenericRegion',
  13049. 'IntermediateGenericRefinementRegion',
  13050. null,
  13051. 'ImmediateGenericRefinementRegion',
  13052. 'ImmediateLosslessGenericRefinementRegion',
  13053. null,
  13054. null,
  13055. null,
  13056. null,
  13057. 'PageInformation',
  13058. 'EndOfPage',
  13059. 'EndOfStripe',
  13060. 'EndOfFile',
  13061. 'Profiles',
  13062. 'Tables',
  13063. null,
  13064. null,
  13065. null,
  13066. null,
  13067. null,
  13068. null,
  13069. null,
  13070. null,
  13071. 'Extension'
  13072. ];
  13073. var CodingTemplates = [
  13074. [
  13075. {
  13076. x: -1,
  13077. y: -2
  13078. },
  13079. {
  13080. x: 0,
  13081. y: -2
  13082. },
  13083. {
  13084. x: 1,
  13085. y: -2
  13086. },
  13087. {
  13088. x: -2,
  13089. y: -1
  13090. },
  13091. {
  13092. x: -1,
  13093. y: -1
  13094. },
  13095. {
  13096. x: 0,
  13097. y: -1
  13098. },
  13099. {
  13100. x: 1,
  13101. y: -1
  13102. },
  13103. {
  13104. x: 2,
  13105. y: -1
  13106. },
  13107. {
  13108. x: -4,
  13109. y: 0
  13110. },
  13111. {
  13112. x: -3,
  13113. y: 0
  13114. },
  13115. {
  13116. x: -2,
  13117. y: 0
  13118. },
  13119. {
  13120. x: -1,
  13121. y: 0
  13122. }
  13123. ],
  13124. [
  13125. {
  13126. x: -1,
  13127. y: -2
  13128. },
  13129. {
  13130. x: 0,
  13131. y: -2
  13132. },
  13133. {
  13134. x: 1,
  13135. y: -2
  13136. },
  13137. {
  13138. x: 2,
  13139. y: -2
  13140. },
  13141. {
  13142. x: -2,
  13143. y: -1
  13144. },
  13145. {
  13146. x: -1,
  13147. y: -1
  13148. },
  13149. {
  13150. x: 0,
  13151. y: -1
  13152. },
  13153. {
  13154. x: 1,
  13155. y: -1
  13156. },
  13157. {
  13158. x: 2,
  13159. y: -1
  13160. },
  13161. {
  13162. x: -3,
  13163. y: 0
  13164. },
  13165. {
  13166. x: -2,
  13167. y: 0
  13168. },
  13169. {
  13170. x: -1,
  13171. y: 0
  13172. }
  13173. ],
  13174. [
  13175. {
  13176. x: -1,
  13177. y: -2
  13178. },
  13179. {
  13180. x: 0,
  13181. y: -2
  13182. },
  13183. {
  13184. x: 1,
  13185. y: -2
  13186. },
  13187. {
  13188. x: -2,
  13189. y: -1
  13190. },
  13191. {
  13192. x: -1,
  13193. y: -1
  13194. },
  13195. {
  13196. x: 0,
  13197. y: -1
  13198. },
  13199. {
  13200. x: 1,
  13201. y: -1
  13202. },
  13203. {
  13204. x: -2,
  13205. y: 0
  13206. },
  13207. {
  13208. x: -1,
  13209. y: 0
  13210. }
  13211. ],
  13212. [
  13213. {
  13214. x: -3,
  13215. y: -1
  13216. },
  13217. {
  13218. x: -2,
  13219. y: -1
  13220. },
  13221. {
  13222. x: -1,
  13223. y: -1
  13224. },
  13225. {
  13226. x: 0,
  13227. y: -1
  13228. },
  13229. {
  13230. x: 1,
  13231. y: -1
  13232. },
  13233. {
  13234. x: -4,
  13235. y: 0
  13236. },
  13237. {
  13238. x: -3,
  13239. y: 0
  13240. },
  13241. {
  13242. x: -2,
  13243. y: 0
  13244. },
  13245. {
  13246. x: -1,
  13247. y: 0
  13248. }
  13249. ]
  13250. ];
  13251. var RefinementTemplates = [
  13252. {
  13253. coding: [
  13254. {
  13255. x: 0,
  13256. y: -1
  13257. },
  13258. {
  13259. x: 1,
  13260. y: -1
  13261. },
  13262. {
  13263. x: -1,
  13264. y: 0
  13265. }
  13266. ],
  13267. reference: [
  13268. {
  13269. x: 0,
  13270. y: -1
  13271. },
  13272. {
  13273. x: 1,
  13274. y: -1
  13275. },
  13276. {
  13277. x: -1,
  13278. y: 0
  13279. },
  13280. {
  13281. x: 0,
  13282. y: 0
  13283. },
  13284. {
  13285. x: 1,
  13286. y: 0
  13287. },
  13288. {
  13289. x: -1,
  13290. y: 1
  13291. },
  13292. {
  13293. x: 0,
  13294. y: 1
  13295. },
  13296. {
  13297. x: 1,
  13298. y: 1
  13299. }
  13300. ]
  13301. },
  13302. {
  13303. coding: [
  13304. {
  13305. x: -1,
  13306. y: -1
  13307. },
  13308. {
  13309. x: 0,
  13310. y: -1
  13311. },
  13312. {
  13313. x: 1,
  13314. y: -1
  13315. },
  13316. {
  13317. x: -1,
  13318. y: 0
  13319. }
  13320. ],
  13321. reference: [
  13322. {
  13323. x: 0,
  13324. y: -1
  13325. },
  13326. {
  13327. x: -1,
  13328. y: 0
  13329. },
  13330. {
  13331. x: 0,
  13332. y: 0
  13333. },
  13334. {
  13335. x: 1,
  13336. y: 0
  13337. },
  13338. {
  13339. x: 0,
  13340. y: 1
  13341. },
  13342. {
  13343. x: 1,
  13344. y: 1
  13345. }
  13346. ]
  13347. }
  13348. ];
  13349. var ReusedContexts = [
  13350. 0x9B25,
  13351. 0x0795,
  13352. 0x00E5,
  13353. 0x0195
  13354. ];
  13355. var RefinementReusedContexts = [
  13356. 0x0020,
  13357. 0x0008
  13358. ];
  13359. function decodeBitmapTemplate0(width, height, decodingContext) {
  13360. var decoder = decodingContext.decoder;
  13361. var contexts = decodingContext.contextCache.getContexts('GB');
  13362. var contextLabel, i, j, pixel, row, row1, row2, bitmap = [];
  13363. var OLD_PIXEL_MASK = 0x7BF7;
  13364. for (i = 0; i < height; i++) {
  13365. row = bitmap[i] = new Uint8Array(width);
  13366. row1 = i < 1 ? row : bitmap[i - 1];
  13367. row2 = i < 2 ? row : bitmap[i - 2];
  13368. contextLabel = row2[0] << 13 | row2[1] << 12 | row2[2] << 11 | row1[0] << 7 | row1[1] << 6 | row1[2] << 5 | row1[3] << 4;
  13369. for (j = 0; j < width; j++) {
  13370. row[j] = pixel = decoder.readBit(contexts, contextLabel);
  13371. contextLabel = (contextLabel & OLD_PIXEL_MASK) << 1 | (j + 3 < width ? row2[j + 3] << 11 : 0) | (j + 4 < width ? row1[j + 4] << 4 : 0) | pixel;
  13372. }
  13373. }
  13374. return bitmap;
  13375. }
  13376. function decodeBitmap(mmr, width, height, templateIndex, prediction, skip, at, decodingContext) {
  13377. if (mmr) {
  13378. error('JBIG2 error: MMR encoding is not supported');
  13379. }
  13380. if (templateIndex === 0 && !skip && !prediction && at.length === 4 && at[0].x === 3 && at[0].y === -1 && at[1].x === -3 && at[1].y === -1 && at[2].x === 2 && at[2].y === -2 && at[3].x === -2 && at[3].y === -2) {
  13381. return decodeBitmapTemplate0(width, height, decodingContext);
  13382. }
  13383. var useskip = !!skip;
  13384. var template = CodingTemplates[templateIndex].concat(at);
  13385. template.sort(function (a, b) {
  13386. return a.y - b.y || a.x - b.x;
  13387. });
  13388. var templateLength = template.length;
  13389. var templateX = new Int8Array(templateLength);
  13390. var templateY = new Int8Array(templateLength);
  13391. var changingTemplateEntries = [];
  13392. var reuseMask = 0, minX = 0, maxX = 0, minY = 0;
  13393. var c, k;
  13394. for (k = 0; k < templateLength; k++) {
  13395. templateX[k] = template[k].x;
  13396. templateY[k] = template[k].y;
  13397. minX = Math.min(minX, template[k].x);
  13398. maxX = Math.max(maxX, template[k].x);
  13399. minY = Math.min(minY, template[k].y);
  13400. if (k < templateLength - 1 && template[k].y === template[k + 1].y && template[k].x === template[k + 1].x - 1) {
  13401. reuseMask |= 1 << templateLength - 1 - k;
  13402. } else {
  13403. changingTemplateEntries.push(k);
  13404. }
  13405. }
  13406. var changingEntriesLength = changingTemplateEntries.length;
  13407. var changingTemplateX = new Int8Array(changingEntriesLength);
  13408. var changingTemplateY = new Int8Array(changingEntriesLength);
  13409. var changingTemplateBit = new Uint16Array(changingEntriesLength);
  13410. for (c = 0; c < changingEntriesLength; c++) {
  13411. k = changingTemplateEntries[c];
  13412. changingTemplateX[c] = template[k].x;
  13413. changingTemplateY[c] = template[k].y;
  13414. changingTemplateBit[c] = 1 << templateLength - 1 - k;
  13415. }
  13416. var sbb_left = -minX;
  13417. var sbb_top = -minY;
  13418. var sbb_right = width - maxX;
  13419. var pseudoPixelContext = ReusedContexts[templateIndex];
  13420. var row = new Uint8Array(width);
  13421. var bitmap = [];
  13422. var decoder = decodingContext.decoder;
  13423. var contexts = decodingContext.contextCache.getContexts('GB');
  13424. var ltp = 0, j, i0, j0, contextLabel = 0, bit, shift;
  13425. for (var i = 0; i < height; i++) {
  13426. if (prediction) {
  13427. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13428. ltp ^= sltp;
  13429. if (ltp) {
  13430. bitmap.push(row);
  13431. continue;
  13432. }
  13433. }
  13434. row = new Uint8Array(row);
  13435. bitmap.push(row);
  13436. for (j = 0; j < width; j++) {
  13437. if (useskip && skip[i][j]) {
  13438. row[j] = 0;
  13439. continue;
  13440. }
  13441. if (j >= sbb_left && j < sbb_right && i >= sbb_top) {
  13442. contextLabel = contextLabel << 1 & reuseMask;
  13443. for (k = 0; k < changingEntriesLength; k++) {
  13444. i0 = i + changingTemplateY[k];
  13445. j0 = j + changingTemplateX[k];
  13446. bit = bitmap[i0][j0];
  13447. if (bit) {
  13448. bit = changingTemplateBit[k];
  13449. contextLabel |= bit;
  13450. }
  13451. }
  13452. } else {
  13453. contextLabel = 0;
  13454. shift = templateLength - 1;
  13455. for (k = 0; k < templateLength; k++, shift--) {
  13456. j0 = j + templateX[k];
  13457. if (j0 >= 0 && j0 < width) {
  13458. i0 = i + templateY[k];
  13459. if (i0 >= 0) {
  13460. bit = bitmap[i0][j0];
  13461. if (bit) {
  13462. contextLabel |= bit << shift;
  13463. }
  13464. }
  13465. }
  13466. }
  13467. }
  13468. var pixel = decoder.readBit(contexts, contextLabel);
  13469. row[j] = pixel;
  13470. }
  13471. }
  13472. return bitmap;
  13473. }
  13474. function decodeRefinement(width, height, templateIndex, referenceBitmap, offsetX, offsetY, prediction, at, decodingContext) {
  13475. var codingTemplate = RefinementTemplates[templateIndex].coding;
  13476. if (templateIndex === 0) {
  13477. codingTemplate = codingTemplate.concat([at[0]]);
  13478. }
  13479. var codingTemplateLength = codingTemplate.length;
  13480. var codingTemplateX = new Int32Array(codingTemplateLength);
  13481. var codingTemplateY = new Int32Array(codingTemplateLength);
  13482. var k;
  13483. for (k = 0; k < codingTemplateLength; k++) {
  13484. codingTemplateX[k] = codingTemplate[k].x;
  13485. codingTemplateY[k] = codingTemplate[k].y;
  13486. }
  13487. var referenceTemplate = RefinementTemplates[templateIndex].reference;
  13488. if (templateIndex === 0) {
  13489. referenceTemplate = referenceTemplate.concat([at[1]]);
  13490. }
  13491. var referenceTemplateLength = referenceTemplate.length;
  13492. var referenceTemplateX = new Int32Array(referenceTemplateLength);
  13493. var referenceTemplateY = new Int32Array(referenceTemplateLength);
  13494. for (k = 0; k < referenceTemplateLength; k++) {
  13495. referenceTemplateX[k] = referenceTemplate[k].x;
  13496. referenceTemplateY[k] = referenceTemplate[k].y;
  13497. }
  13498. var referenceWidth = referenceBitmap[0].length;
  13499. var referenceHeight = referenceBitmap.length;
  13500. var pseudoPixelContext = RefinementReusedContexts[templateIndex];
  13501. var bitmap = [];
  13502. var decoder = decodingContext.decoder;
  13503. var contexts = decodingContext.contextCache.getContexts('GR');
  13504. var ltp = 0;
  13505. for (var i = 0; i < height; i++) {
  13506. if (prediction) {
  13507. var sltp = decoder.readBit(contexts, pseudoPixelContext);
  13508. ltp ^= sltp;
  13509. if (ltp) {
  13510. error('JBIG2 error: prediction is not supported');
  13511. }
  13512. }
  13513. var row = new Uint8Array(width);
  13514. bitmap.push(row);
  13515. for (var j = 0; j < width; j++) {
  13516. var i0, j0;
  13517. var contextLabel = 0;
  13518. for (k = 0; k < codingTemplateLength; k++) {
  13519. i0 = i + codingTemplateY[k];
  13520. j0 = j + codingTemplateX[k];
  13521. if (i0 < 0 || j0 < 0 || j0 >= width) {
  13522. contextLabel <<= 1;
  13523. } else
  13524. {
  13525. contextLabel = contextLabel << 1 | bitmap[i0][j0];
  13526. }
  13527. }
  13528. for (k = 0; k < referenceTemplateLength; k++) {
  13529. i0 = i + referenceTemplateY[k] + offsetY;
  13530. j0 = j + referenceTemplateX[k] + offsetX;
  13531. if (i0 < 0 || i0 >= referenceHeight || j0 < 0 || j0 >= referenceWidth) {
  13532. contextLabel <<= 1;
  13533. } else
  13534. {
  13535. contextLabel = contextLabel << 1 | referenceBitmap[i0][j0];
  13536. }
  13537. }
  13538. var pixel = decoder.readBit(contexts, contextLabel);
  13539. row[j] = pixel;
  13540. }
  13541. }
  13542. return bitmap;
  13543. }
  13544. function decodeSymbolDictionary(huffman, refinement, symbols, numberOfNewSymbols, numberOfExportedSymbols, huffmanTables, templateIndex, at, refinementTemplateIndex, refinementAt, decodingContext) {
  13545. if (huffman) {
  13546. error('JBIG2 error: huffman is not supported');
  13547. }
  13548. var newSymbols = [];
  13549. var currentHeight = 0;
  13550. var symbolCodeLength = log2(symbols.length + numberOfNewSymbols);
  13551. var decoder = decodingContext.decoder;
  13552. var contextCache = decodingContext.contextCache;
  13553. while (newSymbols.length < numberOfNewSymbols) {
  13554. var deltaHeight = decodeInteger(contextCache, 'IADH', decoder);
  13555. currentHeight += deltaHeight;
  13556. var currentWidth = 0;
  13557. var totalWidth = 0;
  13558. while (true) {
  13559. var deltaWidth = decodeInteger(contextCache, 'IADW', decoder);
  13560. if (deltaWidth === null) {
  13561. break;
  13562. }
  13563. currentWidth += deltaWidth;
  13564. totalWidth += currentWidth;
  13565. var bitmap;
  13566. if (refinement) {
  13567. var numberOfInstances = decodeInteger(contextCache, 'IAAI', decoder);
  13568. if (numberOfInstances > 1) {
  13569. bitmap = decodeTextRegion(huffman, refinement, currentWidth, currentHeight, 0, numberOfInstances, 1, symbols.concat(newSymbols), symbolCodeLength, 0, 0, 1, 0, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext);
  13570. } else {
  13571. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13572. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13573. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13574. var symbol = symbolId < symbols.length ? symbols[symbolId] : newSymbols[symbolId - symbols.length];
  13575. bitmap = decodeRefinement(currentWidth, currentHeight, refinementTemplateIndex, symbol, rdx, rdy, false, refinementAt, decodingContext);
  13576. }
  13577. } else {
  13578. bitmap = decodeBitmap(false, currentWidth, currentHeight, templateIndex, false, null, at, decodingContext);
  13579. }
  13580. newSymbols.push(bitmap);
  13581. }
  13582. }
  13583. var exportedSymbols = [];
  13584. var flags = [], currentFlag = false;
  13585. var totalSymbolsLength = symbols.length + numberOfNewSymbols;
  13586. while (flags.length < totalSymbolsLength) {
  13587. var runLength = decodeInteger(contextCache, 'IAEX', decoder);
  13588. while (runLength--) {
  13589. flags.push(currentFlag);
  13590. }
  13591. currentFlag = !currentFlag;
  13592. }
  13593. for (var i = 0, ii = symbols.length; i < ii; i++) {
  13594. if (flags[i]) {
  13595. exportedSymbols.push(symbols[i]);
  13596. }
  13597. }
  13598. for (var j = 0; j < numberOfNewSymbols; i++, j++) {
  13599. if (flags[i]) {
  13600. exportedSymbols.push(newSymbols[j]);
  13601. }
  13602. }
  13603. return exportedSymbols;
  13604. }
  13605. function decodeTextRegion(huffman, refinement, width, height, defaultPixelValue, numberOfSymbolInstances, stripSize, inputSymbols, symbolCodeLength, transposed, dsOffset, referenceCorner, combinationOperator, huffmanTables, refinementTemplateIndex, refinementAt, decodingContext) {
  13606. if (huffman) {
  13607. error('JBIG2 error: huffman is not supported');
  13608. }
  13609. var bitmap = [];
  13610. var i, row;
  13611. for (i = 0; i < height; i++) {
  13612. row = new Uint8Array(width);
  13613. if (defaultPixelValue) {
  13614. for (var j = 0; j < width; j++) {
  13615. row[j] = defaultPixelValue;
  13616. }
  13617. }
  13618. bitmap.push(row);
  13619. }
  13620. var decoder = decodingContext.decoder;
  13621. var contextCache = decodingContext.contextCache;
  13622. var stripT = -decodeInteger(contextCache, 'IADT', decoder);
  13623. var firstS = 0;
  13624. i = 0;
  13625. while (i < numberOfSymbolInstances) {
  13626. var deltaT = decodeInteger(contextCache, 'IADT', decoder);
  13627. stripT += deltaT;
  13628. var deltaFirstS = decodeInteger(contextCache, 'IAFS', decoder);
  13629. firstS += deltaFirstS;
  13630. var currentS = firstS;
  13631. do {
  13632. var currentT = stripSize === 1 ? 0 : decodeInteger(contextCache, 'IAIT', decoder);
  13633. var t = stripSize * stripT + currentT;
  13634. var symbolId = decodeIAID(contextCache, decoder, symbolCodeLength);
  13635. var applyRefinement = refinement && decodeInteger(contextCache, 'IARI', decoder);
  13636. var symbolBitmap = inputSymbols[symbolId];
  13637. var symbolWidth = symbolBitmap[0].length;
  13638. var symbolHeight = symbolBitmap.length;
  13639. if (applyRefinement) {
  13640. var rdw = decodeInteger(contextCache, 'IARDW', decoder);
  13641. var rdh = decodeInteger(contextCache, 'IARDH', decoder);
  13642. var rdx = decodeInteger(contextCache, 'IARDX', decoder);
  13643. var rdy = decodeInteger(contextCache, 'IARDY', decoder);
  13644. symbolWidth += rdw;
  13645. symbolHeight += rdh;
  13646. symbolBitmap = decodeRefinement(symbolWidth, symbolHeight, refinementTemplateIndex, symbolBitmap, (rdw >> 1) + rdx, (rdh >> 1) + rdy, false, refinementAt, decodingContext);
  13647. }
  13648. var offsetT = t - (referenceCorner & 1 ? 0 : symbolHeight);
  13649. var offsetS = currentS - (referenceCorner & 2 ? symbolWidth : 0);
  13650. var s2, t2, symbolRow;
  13651. if (transposed) {
  13652. for (s2 = 0; s2 < symbolHeight; s2++) {
  13653. row = bitmap[offsetS + s2];
  13654. if (!row) {
  13655. continue;
  13656. }
  13657. symbolRow = symbolBitmap[s2];
  13658. var maxWidth = Math.min(width - offsetT, symbolWidth);
  13659. switch (combinationOperator) {
  13660. case 0:
  13661. for (t2 = 0; t2 < maxWidth; t2++) {
  13662. row[offsetT + t2] |= symbolRow[t2];
  13663. }
  13664. break;
  13665. case 2:
  13666. for (t2 = 0; t2 < maxWidth; t2++) {
  13667. row[offsetT + t2] ^= symbolRow[t2];
  13668. }
  13669. break;
  13670. default:
  13671. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13672. }
  13673. }
  13674. currentS += symbolHeight - 1;
  13675. } else {
  13676. for (t2 = 0; t2 < symbolHeight; t2++) {
  13677. row = bitmap[offsetT + t2];
  13678. if (!row) {
  13679. continue;
  13680. }
  13681. symbolRow = symbolBitmap[t2];
  13682. switch (combinationOperator) {
  13683. case 0:
  13684. for (s2 = 0; s2 < symbolWidth; s2++) {
  13685. row[offsetS + s2] |= symbolRow[s2];
  13686. }
  13687. break;
  13688. case 2:
  13689. for (s2 = 0; s2 < symbolWidth; s2++) {
  13690. row[offsetS + s2] ^= symbolRow[s2];
  13691. }
  13692. break;
  13693. default:
  13694. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  13695. }
  13696. }
  13697. currentS += symbolWidth - 1;
  13698. }
  13699. i++;
  13700. var deltaS = decodeInteger(contextCache, 'IADS', decoder);
  13701. if (deltaS === null) {
  13702. break;
  13703. }
  13704. currentS += deltaS + dsOffset;
  13705. } while (true);
  13706. }
  13707. return bitmap;
  13708. }
  13709. function readSegmentHeader(data, start) {
  13710. var segmentHeader = {};
  13711. segmentHeader.number = readUint32(data, start);
  13712. var flags = data[start + 4];
  13713. var segmentType = flags & 0x3F;
  13714. if (!SegmentTypes[segmentType]) {
  13715. error('JBIG2 error: invalid segment type: ' + segmentType);
  13716. }
  13717. segmentHeader.type = segmentType;
  13718. segmentHeader.typeName = SegmentTypes[segmentType];
  13719. segmentHeader.deferredNonRetain = !!(flags & 0x80);
  13720. var pageAssociationFieldSize = !!(flags & 0x40);
  13721. var referredFlags = data[start + 5];
  13722. var referredToCount = referredFlags >> 5 & 7;
  13723. var retainBits = [referredFlags & 31];
  13724. var position = start + 6;
  13725. if (referredFlags === 7) {
  13726. referredToCount = readUint32(data, position - 1) & 0x1FFFFFFF;
  13727. position += 3;
  13728. var bytes = referredToCount + 7 >> 3;
  13729. retainBits[0] = data[position++];
  13730. while (--bytes > 0) {
  13731. retainBits.push(data[position++]);
  13732. }
  13733. } else if (referredFlags === 5 || referredFlags === 6) {
  13734. error('JBIG2 error: invalid referred-to flags');
  13735. }
  13736. segmentHeader.retainBits = retainBits;
  13737. var referredToSegmentNumberSize = segmentHeader.number <= 256 ? 1 : segmentHeader.number <= 65536 ? 2 : 4;
  13738. var referredTo = [];
  13739. var i, ii;
  13740. for (i = 0; i < referredToCount; i++) {
  13741. var number = referredToSegmentNumberSize === 1 ? data[position] : referredToSegmentNumberSize === 2 ? readUint16(data, position) : readUint32(data, position);
  13742. referredTo.push(number);
  13743. position += referredToSegmentNumberSize;
  13744. }
  13745. segmentHeader.referredTo = referredTo;
  13746. if (!pageAssociationFieldSize) {
  13747. segmentHeader.pageAssociation = data[position++];
  13748. } else {
  13749. segmentHeader.pageAssociation = readUint32(data, position);
  13750. position += 4;
  13751. }
  13752. segmentHeader.length = readUint32(data, position);
  13753. position += 4;
  13754. if (segmentHeader.length === 0xFFFFFFFF) {
  13755. if (segmentType === 38) {
  13756. var genericRegionInfo = readRegionSegmentInformation(data, position);
  13757. var genericRegionSegmentFlags = data[position + RegionSegmentInformationFieldLength];
  13758. var genericRegionMmr = !!(genericRegionSegmentFlags & 1);
  13759. var searchPatternLength = 6;
  13760. var searchPattern = new Uint8Array(searchPatternLength);
  13761. if (!genericRegionMmr) {
  13762. searchPattern[0] = 0xFF;
  13763. searchPattern[1] = 0xAC;
  13764. }
  13765. searchPattern[2] = genericRegionInfo.height >>> 24 & 0xFF;
  13766. searchPattern[3] = genericRegionInfo.height >> 16 & 0xFF;
  13767. searchPattern[4] = genericRegionInfo.height >> 8 & 0xFF;
  13768. searchPattern[5] = genericRegionInfo.height & 0xFF;
  13769. for (i = position, ii = data.length; i < ii; i++) {
  13770. var j = 0;
  13771. while (j < searchPatternLength && searchPattern[j] === data[i + j]) {
  13772. j++;
  13773. }
  13774. if (j === searchPatternLength) {
  13775. segmentHeader.length = i + searchPatternLength;
  13776. break;
  13777. }
  13778. }
  13779. if (segmentHeader.length === 0xFFFFFFFF) {
  13780. error('JBIG2 error: segment end was not found');
  13781. }
  13782. } else {
  13783. error('JBIG2 error: invalid unknown segment length');
  13784. }
  13785. }
  13786. segmentHeader.headerEnd = position;
  13787. return segmentHeader;
  13788. }
  13789. function readSegments(header, data, start, end) {
  13790. var segments = [];
  13791. var position = start;
  13792. while (position < end) {
  13793. var segmentHeader = readSegmentHeader(data, position);
  13794. position = segmentHeader.headerEnd;
  13795. var segment = {
  13796. header: segmentHeader,
  13797. data: data
  13798. };
  13799. if (!header.randomAccess) {
  13800. segment.start = position;
  13801. position += segmentHeader.length;
  13802. segment.end = position;
  13803. }
  13804. segments.push(segment);
  13805. if (segmentHeader.type === 51) {
  13806. break;
  13807. }
  13808. }
  13809. if (header.randomAccess) {
  13810. for (var i = 0, ii = segments.length; i < ii; i++) {
  13811. segments[i].start = position;
  13812. position += segments[i].header.length;
  13813. segments[i].end = position;
  13814. }
  13815. }
  13816. return segments;
  13817. }
  13818. function readRegionSegmentInformation(data, start) {
  13819. return {
  13820. width: readUint32(data, start),
  13821. height: readUint32(data, start + 4),
  13822. x: readUint32(data, start + 8),
  13823. y: readUint32(data, start + 12),
  13824. combinationOperator: data[start + 16] & 7
  13825. };
  13826. }
  13827. var RegionSegmentInformationFieldLength = 17;
  13828. function processSegment(segment, visitor) {
  13829. var header = segment.header;
  13830. var data = segment.data, position = segment.start, end = segment.end;
  13831. var args, at, i, atLength;
  13832. switch (header.type) {
  13833. case 0:
  13834. var dictionary = {};
  13835. var dictionaryFlags = readUint16(data, position);
  13836. dictionary.huffman = !!(dictionaryFlags & 1);
  13837. dictionary.refinement = !!(dictionaryFlags & 2);
  13838. dictionary.huffmanDHSelector = dictionaryFlags >> 2 & 3;
  13839. dictionary.huffmanDWSelector = dictionaryFlags >> 4 & 3;
  13840. dictionary.bitmapSizeSelector = dictionaryFlags >> 6 & 1;
  13841. dictionary.aggregationInstancesSelector = dictionaryFlags >> 7 & 1;
  13842. dictionary.bitmapCodingContextUsed = !!(dictionaryFlags & 256);
  13843. dictionary.bitmapCodingContextRetained = !!(dictionaryFlags & 512);
  13844. dictionary.template = dictionaryFlags >> 10 & 3;
  13845. dictionary.refinementTemplate = dictionaryFlags >> 12 & 1;
  13846. position += 2;
  13847. if (!dictionary.huffman) {
  13848. atLength = dictionary.template === 0 ? 4 : 1;
  13849. at = [];
  13850. for (i = 0; i < atLength; i++) {
  13851. at.push({
  13852. x: readInt8(data, position),
  13853. y: readInt8(data, position + 1)
  13854. });
  13855. position += 2;
  13856. }
  13857. dictionary.at = at;
  13858. }
  13859. if (dictionary.refinement && !dictionary.refinementTemplate) {
  13860. at = [];
  13861. for (i = 0; i < 2; i++) {
  13862. at.push({
  13863. x: readInt8(data, position),
  13864. y: readInt8(data, position + 1)
  13865. });
  13866. position += 2;
  13867. }
  13868. dictionary.refinementAt = at;
  13869. }
  13870. dictionary.numberOfExportedSymbols = readUint32(data, position);
  13871. position += 4;
  13872. dictionary.numberOfNewSymbols = readUint32(data, position);
  13873. position += 4;
  13874. args = [
  13875. dictionary,
  13876. header.number,
  13877. header.referredTo,
  13878. data,
  13879. position,
  13880. end
  13881. ];
  13882. break;
  13883. case 6:
  13884. case 7:
  13885. var textRegion = {};
  13886. textRegion.info = readRegionSegmentInformation(data, position);
  13887. position += RegionSegmentInformationFieldLength;
  13888. var textRegionSegmentFlags = readUint16(data, position);
  13889. position += 2;
  13890. textRegion.huffman = !!(textRegionSegmentFlags & 1);
  13891. textRegion.refinement = !!(textRegionSegmentFlags & 2);
  13892. textRegion.stripSize = 1 << (textRegionSegmentFlags >> 2 & 3);
  13893. textRegion.referenceCorner = textRegionSegmentFlags >> 4 & 3;
  13894. textRegion.transposed = !!(textRegionSegmentFlags & 64);
  13895. textRegion.combinationOperator = textRegionSegmentFlags >> 7 & 3;
  13896. textRegion.defaultPixelValue = textRegionSegmentFlags >> 9 & 1;
  13897. textRegion.dsOffset = textRegionSegmentFlags << 17 >> 27;
  13898. textRegion.refinementTemplate = textRegionSegmentFlags >> 15 & 1;
  13899. if (textRegion.huffman) {
  13900. var textRegionHuffmanFlags = readUint16(data, position);
  13901. position += 2;
  13902. textRegion.huffmanFS = textRegionHuffmanFlags & 3;
  13903. textRegion.huffmanDS = textRegionHuffmanFlags >> 2 & 3;
  13904. textRegion.huffmanDT = textRegionHuffmanFlags >> 4 & 3;
  13905. textRegion.huffmanRefinementDW = textRegionHuffmanFlags >> 6 & 3;
  13906. textRegion.huffmanRefinementDH = textRegionHuffmanFlags >> 8 & 3;
  13907. textRegion.huffmanRefinementDX = textRegionHuffmanFlags >> 10 & 3;
  13908. textRegion.huffmanRefinementDY = textRegionHuffmanFlags >> 12 & 3;
  13909. textRegion.huffmanRefinementSizeSelector = !!(textRegionHuffmanFlags & 14);
  13910. }
  13911. if (textRegion.refinement && !textRegion.refinementTemplate) {
  13912. at = [];
  13913. for (i = 0; i < 2; i++) {
  13914. at.push({
  13915. x: readInt8(data, position),
  13916. y: readInt8(data, position + 1)
  13917. });
  13918. position += 2;
  13919. }
  13920. textRegion.refinementAt = at;
  13921. }
  13922. textRegion.numberOfSymbolInstances = readUint32(data, position);
  13923. position += 4;
  13924. if (textRegion.huffman) {
  13925. error('JBIG2 error: huffman is not supported');
  13926. }
  13927. args = [
  13928. textRegion,
  13929. header.referredTo,
  13930. data,
  13931. position,
  13932. end
  13933. ];
  13934. break;
  13935. case 38:
  13936. case 39:
  13937. var genericRegion = {};
  13938. genericRegion.info = readRegionSegmentInformation(data, position);
  13939. position += RegionSegmentInformationFieldLength;
  13940. var genericRegionSegmentFlags = data[position++];
  13941. genericRegion.mmr = !!(genericRegionSegmentFlags & 1);
  13942. genericRegion.template = genericRegionSegmentFlags >> 1 & 3;
  13943. genericRegion.prediction = !!(genericRegionSegmentFlags & 8);
  13944. if (!genericRegion.mmr) {
  13945. atLength = genericRegion.template === 0 ? 4 : 1;
  13946. at = [];
  13947. for (i = 0; i < atLength; i++) {
  13948. at.push({
  13949. x: readInt8(data, position),
  13950. y: readInt8(data, position + 1)
  13951. });
  13952. position += 2;
  13953. }
  13954. genericRegion.at = at;
  13955. }
  13956. args = [
  13957. genericRegion,
  13958. data,
  13959. position,
  13960. end
  13961. ];
  13962. break;
  13963. case 48:
  13964. var pageInfo = {
  13965. width: readUint32(data, position),
  13966. height: readUint32(data, position + 4),
  13967. resolutionX: readUint32(data, position + 8),
  13968. resolutionY: readUint32(data, position + 12)
  13969. };
  13970. if (pageInfo.height === 0xFFFFFFFF) {
  13971. delete pageInfo.height;
  13972. }
  13973. var pageSegmentFlags = data[position + 16];
  13974. var pageStripingInformation = readUint16(data, position + 17);
  13975. pageInfo.lossless = !!(pageSegmentFlags & 1);
  13976. pageInfo.refinement = !!(pageSegmentFlags & 2);
  13977. pageInfo.defaultPixelValue = pageSegmentFlags >> 2 & 1;
  13978. pageInfo.combinationOperator = pageSegmentFlags >> 3 & 3;
  13979. pageInfo.requiresBuffer = !!(pageSegmentFlags & 32);
  13980. pageInfo.combinationOperatorOverride = !!(pageSegmentFlags & 64);
  13981. args = [pageInfo];
  13982. break;
  13983. case 49:
  13984. break;
  13985. case 50:
  13986. break;
  13987. case 51:
  13988. break;
  13989. case 62:
  13990. break;
  13991. default:
  13992. error('JBIG2 error: segment type ' + header.typeName + '(' + header.type + ') is not implemented');
  13993. }
  13994. var callbackName = 'on' + header.typeName;
  13995. if (callbackName in visitor) {
  13996. visitor[callbackName].apply(visitor, args);
  13997. }
  13998. }
  13999. function processSegments(segments, visitor) {
  14000. for (var i = 0, ii = segments.length; i < ii; i++) {
  14001. processSegment(segments[i], visitor);
  14002. }
  14003. }
  14004. function parseJbig2(data, start, end) {
  14005. var position = start;
  14006. if (data[position] !== 0x97 || data[position + 1] !== 0x4A || data[position + 2] !== 0x42 || data[position + 3] !== 0x32 || data[position + 4] !== 0x0D || data[position + 5] !== 0x0A || data[position + 6] !== 0x1A || data[position + 7] !== 0x0A) {
  14007. error('JBIG2 error: invalid header');
  14008. }
  14009. var header = {};
  14010. position += 8;
  14011. var flags = data[position++];
  14012. header.randomAccess = !(flags & 1);
  14013. if (!(flags & 2)) {
  14014. header.numberOfPages = readUint32(data, position);
  14015. position += 4;
  14016. }
  14017. var segments = readSegments(header, data, position, end);
  14018. error('Not implemented');
  14019. }
  14020. function parseJbig2Chunks(chunks) {
  14021. var visitor = new SimpleSegmentVisitor();
  14022. for (var i = 0, ii = chunks.length; i < ii; i++) {
  14023. var chunk = chunks[i];
  14024. var segments = readSegments({}, chunk.data, chunk.start, chunk.end);
  14025. processSegments(segments, visitor);
  14026. }
  14027. return visitor.buffer;
  14028. }
  14029. function SimpleSegmentVisitor() {
  14030. }
  14031. SimpleSegmentVisitor.prototype = {
  14032. onPageInformation: function SimpleSegmentVisitor_onPageInformation(info) {
  14033. this.currentPageInfo = info;
  14034. var rowSize = info.width + 7 >> 3;
  14035. var buffer = new Uint8Array(rowSize * info.height);
  14036. if (info.defaultPixelValue) {
  14037. for (var i = 0, ii = buffer.length; i < ii; i++) {
  14038. buffer[i] = 0xFF;
  14039. }
  14040. }
  14041. this.buffer = buffer;
  14042. },
  14043. drawBitmap: function SimpleSegmentVisitor_drawBitmap(regionInfo, bitmap) {
  14044. var pageInfo = this.currentPageInfo;
  14045. var width = regionInfo.width, height = regionInfo.height;
  14046. var rowSize = pageInfo.width + 7 >> 3;
  14047. var combinationOperator = pageInfo.combinationOperatorOverride ? regionInfo.combinationOperator : pageInfo.combinationOperator;
  14048. var buffer = this.buffer;
  14049. var mask0 = 128 >> (regionInfo.x & 7);
  14050. var offset0 = regionInfo.y * rowSize + (regionInfo.x >> 3);
  14051. var i, j, mask, offset;
  14052. switch (combinationOperator) {
  14053. case 0:
  14054. for (i = 0; i < height; i++) {
  14055. mask = mask0;
  14056. offset = offset0;
  14057. for (j = 0; j < width; j++) {
  14058. if (bitmap[i][j]) {
  14059. buffer[offset] |= mask;
  14060. }
  14061. mask >>= 1;
  14062. if (!mask) {
  14063. mask = 128;
  14064. offset++;
  14065. }
  14066. }
  14067. offset0 += rowSize;
  14068. }
  14069. break;
  14070. case 2:
  14071. for (i = 0; i < height; i++) {
  14072. mask = mask0;
  14073. offset = offset0;
  14074. for (j = 0; j < width; j++) {
  14075. if (bitmap[i][j]) {
  14076. buffer[offset] ^= mask;
  14077. }
  14078. mask >>= 1;
  14079. if (!mask) {
  14080. mask = 128;
  14081. offset++;
  14082. }
  14083. }
  14084. offset0 += rowSize;
  14085. }
  14086. break;
  14087. default:
  14088. error('JBIG2 error: operator ' + combinationOperator + ' is not supported');
  14089. }
  14090. },
  14091. onImmediateGenericRegion: function SimpleSegmentVisitor_onImmediateGenericRegion(region, data, start, end) {
  14092. var regionInfo = region.info;
  14093. var decodingContext = new DecodingContext(data, start, end);
  14094. var bitmap = decodeBitmap(region.mmr, regionInfo.width, regionInfo.height, region.template, region.prediction, null, region.at, decodingContext);
  14095. this.drawBitmap(regionInfo, bitmap);
  14096. },
  14097. onImmediateLosslessGenericRegion: function SimpleSegmentVisitor_onImmediateLosslessGenericRegion() {
  14098. this.onImmediateGenericRegion.apply(this, arguments);
  14099. },
  14100. onSymbolDictionary: function SimpleSegmentVisitor_onSymbolDictionary(dictionary, currentSegment, referredSegments, data, start, end) {
  14101. var huffmanTables;
  14102. if (dictionary.huffman) {
  14103. error('JBIG2 error: huffman is not supported');
  14104. }
  14105. var symbols = this.symbols;
  14106. if (!symbols) {
  14107. this.symbols = symbols = {};
  14108. }
  14109. var inputSymbols = [];
  14110. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14111. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14112. }
  14113. var decodingContext = new DecodingContext(data, start, end);
  14114. symbols[currentSegment] = decodeSymbolDictionary(dictionary.huffman, dictionary.refinement, inputSymbols, dictionary.numberOfNewSymbols, dictionary.numberOfExportedSymbols, huffmanTables, dictionary.template, dictionary.at, dictionary.refinementTemplate, dictionary.refinementAt, decodingContext);
  14115. },
  14116. onImmediateTextRegion: function SimpleSegmentVisitor_onImmediateTextRegion(region, referredSegments, data, start, end) {
  14117. var regionInfo = region.info;
  14118. var huffmanTables;
  14119. var symbols = this.symbols;
  14120. var inputSymbols = [];
  14121. for (var i = 0, ii = referredSegments.length; i < ii; i++) {
  14122. inputSymbols = inputSymbols.concat(symbols[referredSegments[i]]);
  14123. }
  14124. var symbolCodeLength = log2(inputSymbols.length);
  14125. var decodingContext = new DecodingContext(data, start, end);
  14126. var bitmap = decodeTextRegion(region.huffman, region.refinement, regionInfo.width, regionInfo.height, region.defaultPixelValue, region.numberOfSymbolInstances, region.stripSize, inputSymbols, symbolCodeLength, region.transposed, region.dsOffset, region.referenceCorner, region.combinationOperator, huffmanTables, region.refinementTemplate, region.refinementAt, decodingContext);
  14127. this.drawBitmap(regionInfo, bitmap);
  14128. },
  14129. onImmediateLosslessTextRegion: function SimpleSegmentVisitor_onImmediateLosslessTextRegion() {
  14130. this.onImmediateTextRegion.apply(this, arguments);
  14131. }
  14132. };
  14133. function Jbig2Image() {
  14134. }
  14135. Jbig2Image.prototype = {
  14136. parseChunks: function Jbig2Image_parseChunks(chunks) {
  14137. return parseJbig2Chunks(chunks);
  14138. }
  14139. };
  14140. return Jbig2Image;
  14141. }();
  14142. exports.Jbig2Image = Jbig2Image;
  14143. }));
  14144. (function (root, factory) {
  14145. factory(root.pdfjsCoreJpg = {}, root.pdfjsSharedUtil);
  14146. }(this, function (exports, sharedUtil) {
  14147. var error = sharedUtil.error;
  14148. var JpegImage = function JpegImageClosure() {
  14149. var dctZigZag = new Uint8Array([
  14150. 0,
  14151. 1,
  14152. 8,
  14153. 16,
  14154. 9,
  14155. 2,
  14156. 3,
  14157. 10,
  14158. 17,
  14159. 24,
  14160. 32,
  14161. 25,
  14162. 18,
  14163. 11,
  14164. 4,
  14165. 5,
  14166. 12,
  14167. 19,
  14168. 26,
  14169. 33,
  14170. 40,
  14171. 48,
  14172. 41,
  14173. 34,
  14174. 27,
  14175. 20,
  14176. 13,
  14177. 6,
  14178. 7,
  14179. 14,
  14180. 21,
  14181. 28,
  14182. 35,
  14183. 42,
  14184. 49,
  14185. 56,
  14186. 57,
  14187. 50,
  14188. 43,
  14189. 36,
  14190. 29,
  14191. 22,
  14192. 15,
  14193. 23,
  14194. 30,
  14195. 37,
  14196. 44,
  14197. 51,
  14198. 58,
  14199. 59,
  14200. 52,
  14201. 45,
  14202. 38,
  14203. 31,
  14204. 39,
  14205. 46,
  14206. 53,
  14207. 60,
  14208. 61,
  14209. 54,
  14210. 47,
  14211. 55,
  14212. 62,
  14213. 63
  14214. ]);
  14215. var dctCos1 = 4017;
  14216. var dctSin1 = 799;
  14217. var dctCos3 = 3406;
  14218. var dctSin3 = 2276;
  14219. var dctCos6 = 1567;
  14220. var dctSin6 = 3784;
  14221. var dctSqrt2 = 5793;
  14222. var dctSqrt1d2 = 2896;
  14223. function JpegImage() {
  14224. this.decodeTransform = null;
  14225. this.colorTransform = -1;
  14226. }
  14227. function buildHuffmanTable(codeLengths, values) {
  14228. var k = 0, code = [], i, j, length = 16;
  14229. while (length > 0 && !codeLengths[length - 1]) {
  14230. length--;
  14231. }
  14232. code.push({
  14233. children: [],
  14234. index: 0
  14235. });
  14236. var p = code[0], q;
  14237. for (i = 0; i < length; i++) {
  14238. for (j = 0; j < codeLengths[i]; j++) {
  14239. p = code.pop();
  14240. p.children[p.index] = values[k];
  14241. while (p.index > 0) {
  14242. p = code.pop();
  14243. }
  14244. p.index++;
  14245. code.push(p);
  14246. while (code.length <= i) {
  14247. code.push(q = {
  14248. children: [],
  14249. index: 0
  14250. });
  14251. p.children[p.index] = q.children;
  14252. p = q;
  14253. }
  14254. k++;
  14255. }
  14256. if (i + 1 < length) {
  14257. code.push(q = {
  14258. children: [],
  14259. index: 0
  14260. });
  14261. p.children[p.index] = q.children;
  14262. p = q;
  14263. }
  14264. }
  14265. return code[0].children;
  14266. }
  14267. function getBlockBufferOffset(component, row, col) {
  14268. return 64 * ((component.blocksPerLine + 1) * row + col);
  14269. }
  14270. function decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successivePrev, successive) {
  14271. var mcusPerLine = frame.mcusPerLine;
  14272. var progressive = frame.progressive;
  14273. var startOffset = offset, bitsData = 0, bitsCount = 0;
  14274. function readBit() {
  14275. if (bitsCount > 0) {
  14276. bitsCount--;
  14277. return bitsData >> bitsCount & 1;
  14278. }
  14279. bitsData = data[offset++];
  14280. if (bitsData === 0xFF) {
  14281. var nextByte = data[offset++];
  14282. if (nextByte) {
  14283. error('JPEG error: unexpected marker ' + (bitsData << 8 | nextByte).toString(16));
  14284. }
  14285. }
  14286. bitsCount = 7;
  14287. return bitsData >>> 7;
  14288. }
  14289. function decodeHuffman(tree) {
  14290. var node = tree;
  14291. while (true) {
  14292. node = node[readBit()];
  14293. if (typeof node === 'number') {
  14294. return node;
  14295. }
  14296. if (typeof node !== 'object') {
  14297. error('JPEG error: invalid huffman sequence');
  14298. }
  14299. }
  14300. }
  14301. function receive(length) {
  14302. var n = 0;
  14303. while (length > 0) {
  14304. n = n << 1 | readBit();
  14305. length--;
  14306. }
  14307. return n;
  14308. }
  14309. function receiveAndExtend(length) {
  14310. if (length === 1) {
  14311. return readBit() === 1 ? 1 : -1;
  14312. }
  14313. var n = receive(length);
  14314. if (n >= 1 << length - 1) {
  14315. return n;
  14316. }
  14317. return n + (-1 << length) + 1;
  14318. }
  14319. function decodeBaseline(component, offset) {
  14320. var t = decodeHuffman(component.huffmanTableDC);
  14321. var diff = t === 0 ? 0 : receiveAndExtend(t);
  14322. component.blockData[offset] = component.pred += diff;
  14323. var k = 1;
  14324. while (k < 64) {
  14325. var rs = decodeHuffman(component.huffmanTableAC);
  14326. var s = rs & 15, r = rs >> 4;
  14327. if (s === 0) {
  14328. if (r < 15) {
  14329. break;
  14330. }
  14331. k += 16;
  14332. continue;
  14333. }
  14334. k += r;
  14335. var z = dctZigZag[k];
  14336. component.blockData[offset + z] = receiveAndExtend(s);
  14337. k++;
  14338. }
  14339. }
  14340. function decodeDCFirst(component, offset) {
  14341. var t = decodeHuffman(component.huffmanTableDC);
  14342. var diff = t === 0 ? 0 : receiveAndExtend(t) << successive;
  14343. component.blockData[offset] = component.pred += diff;
  14344. }
  14345. function decodeDCSuccessive(component, offset) {
  14346. component.blockData[offset] |= readBit() << successive;
  14347. }
  14348. var eobrun = 0;
  14349. function decodeACFirst(component, offset) {
  14350. if (eobrun > 0) {
  14351. eobrun--;
  14352. return;
  14353. }
  14354. var k = spectralStart, e = spectralEnd;
  14355. while (k <= e) {
  14356. var rs = decodeHuffman(component.huffmanTableAC);
  14357. var s = rs & 15, r = rs >> 4;
  14358. if (s === 0) {
  14359. if (r < 15) {
  14360. eobrun = receive(r) + (1 << r) - 1;
  14361. break;
  14362. }
  14363. k += 16;
  14364. continue;
  14365. }
  14366. k += r;
  14367. var z = dctZigZag[k];
  14368. component.blockData[offset + z] = receiveAndExtend(s) * (1 << successive);
  14369. k++;
  14370. }
  14371. }
  14372. var successiveACState = 0, successiveACNextValue;
  14373. function decodeACSuccessive(component, offset) {
  14374. var k = spectralStart;
  14375. var e = spectralEnd;
  14376. var r = 0;
  14377. var s;
  14378. var rs;
  14379. while (k <= e) {
  14380. var z = dctZigZag[k];
  14381. switch (successiveACState) {
  14382. case 0:
  14383. rs = decodeHuffman(component.huffmanTableAC);
  14384. s = rs & 15;
  14385. r = rs >> 4;
  14386. if (s === 0) {
  14387. if (r < 15) {
  14388. eobrun = receive(r) + (1 << r);
  14389. successiveACState = 4;
  14390. } else {
  14391. r = 16;
  14392. successiveACState = 1;
  14393. }
  14394. } else {
  14395. if (s !== 1) {
  14396. error('JPEG error: invalid ACn encoding');
  14397. }
  14398. successiveACNextValue = receiveAndExtend(s);
  14399. successiveACState = r ? 2 : 3;
  14400. }
  14401. continue;
  14402. case 1:
  14403. case 2:
  14404. if (component.blockData[offset + z]) {
  14405. component.blockData[offset + z] += readBit() << successive;
  14406. } else {
  14407. r--;
  14408. if (r === 0) {
  14409. successiveACState = successiveACState === 2 ? 3 : 0;
  14410. }
  14411. }
  14412. break;
  14413. case 3:
  14414. if (component.blockData[offset + z]) {
  14415. component.blockData[offset + z] += readBit() << successive;
  14416. } else {
  14417. component.blockData[offset + z] = successiveACNextValue << successive;
  14418. successiveACState = 0;
  14419. }
  14420. break;
  14421. case 4:
  14422. if (component.blockData[offset + z]) {
  14423. component.blockData[offset + z] += readBit() << successive;
  14424. }
  14425. break;
  14426. }
  14427. k++;
  14428. }
  14429. if (successiveACState === 4) {
  14430. eobrun--;
  14431. if (eobrun === 0) {
  14432. successiveACState = 0;
  14433. }
  14434. }
  14435. }
  14436. function decodeMcu(component, decode, mcu, row, col) {
  14437. var mcuRow = mcu / mcusPerLine | 0;
  14438. var mcuCol = mcu % mcusPerLine;
  14439. var blockRow = mcuRow * component.v + row;
  14440. var blockCol = mcuCol * component.h + col;
  14441. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14442. decode(component, offset);
  14443. }
  14444. function decodeBlock(component, decode, mcu) {
  14445. var blockRow = mcu / component.blocksPerLine | 0;
  14446. var blockCol = mcu % component.blocksPerLine;
  14447. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14448. decode(component, offset);
  14449. }
  14450. var componentsLength = components.length;
  14451. var component, i, j, k, n;
  14452. var decodeFn;
  14453. if (progressive) {
  14454. if (spectralStart === 0) {
  14455. decodeFn = successivePrev === 0 ? decodeDCFirst : decodeDCSuccessive;
  14456. } else {
  14457. decodeFn = successivePrev === 0 ? decodeACFirst : decodeACSuccessive;
  14458. }
  14459. } else {
  14460. decodeFn = decodeBaseline;
  14461. }
  14462. var mcu = 0, marker;
  14463. var mcuExpected;
  14464. if (componentsLength === 1) {
  14465. mcuExpected = components[0].blocksPerLine * components[0].blocksPerColumn;
  14466. } else {
  14467. mcuExpected = mcusPerLine * frame.mcusPerColumn;
  14468. }
  14469. if (!resetInterval) {
  14470. resetInterval = mcuExpected;
  14471. }
  14472. var h, v;
  14473. while (mcu < mcuExpected) {
  14474. for (i = 0; i < componentsLength; i++) {
  14475. components[i].pred = 0;
  14476. }
  14477. eobrun = 0;
  14478. if (componentsLength === 1) {
  14479. component = components[0];
  14480. for (n = 0; n < resetInterval; n++) {
  14481. decodeBlock(component, decodeFn, mcu);
  14482. mcu++;
  14483. }
  14484. } else {
  14485. for (n = 0; n < resetInterval; n++) {
  14486. for (i = 0; i < componentsLength; i++) {
  14487. component = components[i];
  14488. h = component.h;
  14489. v = component.v;
  14490. for (j = 0; j < v; j++) {
  14491. for (k = 0; k < h; k++) {
  14492. decodeMcu(component, decodeFn, mcu, j, k);
  14493. }
  14494. }
  14495. }
  14496. mcu++;
  14497. }
  14498. }
  14499. bitsCount = 0;
  14500. marker = data[offset] << 8 | data[offset + 1];
  14501. while (data[offset] === 0x00 && offset < data.length - 1) {
  14502. offset++;
  14503. marker = data[offset] << 8 | data[offset + 1];
  14504. }
  14505. if (marker <= 0xFF00) {
  14506. error('JPEG error: marker was not found');
  14507. }
  14508. if (marker >= 0xFFD0 && marker <= 0xFFD7) {
  14509. offset += 2;
  14510. } else {
  14511. break;
  14512. }
  14513. }
  14514. return offset - startOffset;
  14515. }
  14516. function quantizeAndInverse(component, blockBufferOffset, p) {
  14517. var qt = component.quantizationTable, blockData = component.blockData;
  14518. var v0, v1, v2, v3, v4, v5, v6, v7;
  14519. var p0, p1, p2, p3, p4, p5, p6, p7;
  14520. var t;
  14521. if (!qt) {
  14522. error('JPEG error: missing required Quantization Table.');
  14523. }
  14524. for (var row = 0; row < 64; row += 8) {
  14525. p0 = blockData[blockBufferOffset + row];
  14526. p1 = blockData[blockBufferOffset + row + 1];
  14527. p2 = blockData[blockBufferOffset + row + 2];
  14528. p3 = blockData[blockBufferOffset + row + 3];
  14529. p4 = blockData[blockBufferOffset + row + 4];
  14530. p5 = blockData[blockBufferOffset + row + 5];
  14531. p6 = blockData[blockBufferOffset + row + 6];
  14532. p7 = blockData[blockBufferOffset + row + 7];
  14533. p0 *= qt[row];
  14534. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14535. t = dctSqrt2 * p0 + 512 >> 10;
  14536. p[row] = t;
  14537. p[row + 1] = t;
  14538. p[row + 2] = t;
  14539. p[row + 3] = t;
  14540. p[row + 4] = t;
  14541. p[row + 5] = t;
  14542. p[row + 6] = t;
  14543. p[row + 7] = t;
  14544. continue;
  14545. }
  14546. p1 *= qt[row + 1];
  14547. p2 *= qt[row + 2];
  14548. p3 *= qt[row + 3];
  14549. p4 *= qt[row + 4];
  14550. p5 *= qt[row + 5];
  14551. p6 *= qt[row + 6];
  14552. p7 *= qt[row + 7];
  14553. v0 = dctSqrt2 * p0 + 128 >> 8;
  14554. v1 = dctSqrt2 * p4 + 128 >> 8;
  14555. v2 = p2;
  14556. v3 = p6;
  14557. v4 = dctSqrt1d2 * (p1 - p7) + 128 >> 8;
  14558. v7 = dctSqrt1d2 * (p1 + p7) + 128 >> 8;
  14559. v5 = p3 << 4;
  14560. v6 = p5 << 4;
  14561. v0 = v0 + v1 + 1 >> 1;
  14562. v1 = v0 - v1;
  14563. t = v2 * dctSin6 + v3 * dctCos6 + 128 >> 8;
  14564. v2 = v2 * dctCos6 - v3 * dctSin6 + 128 >> 8;
  14565. v3 = t;
  14566. v4 = v4 + v6 + 1 >> 1;
  14567. v6 = v4 - v6;
  14568. v7 = v7 + v5 + 1 >> 1;
  14569. v5 = v7 - v5;
  14570. v0 = v0 + v3 + 1 >> 1;
  14571. v3 = v0 - v3;
  14572. v1 = v1 + v2 + 1 >> 1;
  14573. v2 = v1 - v2;
  14574. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14575. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14576. v7 = t;
  14577. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14578. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14579. v6 = t;
  14580. p[row] = v0 + v7;
  14581. p[row + 7] = v0 - v7;
  14582. p[row + 1] = v1 + v6;
  14583. p[row + 6] = v1 - v6;
  14584. p[row + 2] = v2 + v5;
  14585. p[row + 5] = v2 - v5;
  14586. p[row + 3] = v3 + v4;
  14587. p[row + 4] = v3 - v4;
  14588. }
  14589. for (var col = 0; col < 8; ++col) {
  14590. p0 = p[col];
  14591. p1 = p[col + 8];
  14592. p2 = p[col + 16];
  14593. p3 = p[col + 24];
  14594. p4 = p[col + 32];
  14595. p5 = p[col + 40];
  14596. p6 = p[col + 48];
  14597. p7 = p[col + 56];
  14598. if ((p1 | p2 | p3 | p4 | p5 | p6 | p7) === 0) {
  14599. t = dctSqrt2 * p0 + 8192 >> 14;
  14600. t = t < -2040 ? 0 : t >= 2024 ? 255 : t + 2056 >> 4;
  14601. blockData[blockBufferOffset + col] = t;
  14602. blockData[blockBufferOffset + col + 8] = t;
  14603. blockData[blockBufferOffset + col + 16] = t;
  14604. blockData[blockBufferOffset + col + 24] = t;
  14605. blockData[blockBufferOffset + col + 32] = t;
  14606. blockData[blockBufferOffset + col + 40] = t;
  14607. blockData[blockBufferOffset + col + 48] = t;
  14608. blockData[blockBufferOffset + col + 56] = t;
  14609. continue;
  14610. }
  14611. v0 = dctSqrt2 * p0 + 2048 >> 12;
  14612. v1 = dctSqrt2 * p4 + 2048 >> 12;
  14613. v2 = p2;
  14614. v3 = p6;
  14615. v4 = dctSqrt1d2 * (p1 - p7) + 2048 >> 12;
  14616. v7 = dctSqrt1d2 * (p1 + p7) + 2048 >> 12;
  14617. v5 = p3;
  14618. v6 = p5;
  14619. v0 = (v0 + v1 + 1 >> 1) + 4112;
  14620. v1 = v0 - v1;
  14621. t = v2 * dctSin6 + v3 * dctCos6 + 2048 >> 12;
  14622. v2 = v2 * dctCos6 - v3 * dctSin6 + 2048 >> 12;
  14623. v3 = t;
  14624. v4 = v4 + v6 + 1 >> 1;
  14625. v6 = v4 - v6;
  14626. v7 = v7 + v5 + 1 >> 1;
  14627. v5 = v7 - v5;
  14628. v0 = v0 + v3 + 1 >> 1;
  14629. v3 = v0 - v3;
  14630. v1 = v1 + v2 + 1 >> 1;
  14631. v2 = v1 - v2;
  14632. t = v4 * dctSin3 + v7 * dctCos3 + 2048 >> 12;
  14633. v4 = v4 * dctCos3 - v7 * dctSin3 + 2048 >> 12;
  14634. v7 = t;
  14635. t = v5 * dctSin1 + v6 * dctCos1 + 2048 >> 12;
  14636. v5 = v5 * dctCos1 - v6 * dctSin1 + 2048 >> 12;
  14637. v6 = t;
  14638. p0 = v0 + v7;
  14639. p7 = v0 - v7;
  14640. p1 = v1 + v6;
  14641. p6 = v1 - v6;
  14642. p2 = v2 + v5;
  14643. p5 = v2 - v5;
  14644. p3 = v3 + v4;
  14645. p4 = v3 - v4;
  14646. p0 = p0 < 16 ? 0 : p0 >= 4080 ? 255 : p0 >> 4;
  14647. p1 = p1 < 16 ? 0 : p1 >= 4080 ? 255 : p1 >> 4;
  14648. p2 = p2 < 16 ? 0 : p2 >= 4080 ? 255 : p2 >> 4;
  14649. p3 = p3 < 16 ? 0 : p3 >= 4080 ? 255 : p3 >> 4;
  14650. p4 = p4 < 16 ? 0 : p4 >= 4080 ? 255 : p4 >> 4;
  14651. p5 = p5 < 16 ? 0 : p5 >= 4080 ? 255 : p5 >> 4;
  14652. p6 = p6 < 16 ? 0 : p6 >= 4080 ? 255 : p6 >> 4;
  14653. p7 = p7 < 16 ? 0 : p7 >= 4080 ? 255 : p7 >> 4;
  14654. blockData[blockBufferOffset + col] = p0;
  14655. blockData[blockBufferOffset + col + 8] = p1;
  14656. blockData[blockBufferOffset + col + 16] = p2;
  14657. blockData[blockBufferOffset + col + 24] = p3;
  14658. blockData[blockBufferOffset + col + 32] = p4;
  14659. blockData[blockBufferOffset + col + 40] = p5;
  14660. blockData[blockBufferOffset + col + 48] = p6;
  14661. blockData[blockBufferOffset + col + 56] = p7;
  14662. }
  14663. }
  14664. function buildComponentData(frame, component) {
  14665. var blocksPerLine = component.blocksPerLine;
  14666. var blocksPerColumn = component.blocksPerColumn;
  14667. var computationBuffer = new Int16Array(64);
  14668. for (var blockRow = 0; blockRow < blocksPerColumn; blockRow++) {
  14669. for (var blockCol = 0; blockCol < blocksPerLine; blockCol++) {
  14670. var offset = getBlockBufferOffset(component, blockRow, blockCol);
  14671. quantizeAndInverse(component, offset, computationBuffer);
  14672. }
  14673. }
  14674. return component.blockData;
  14675. }
  14676. function clamp0to255(a) {
  14677. return a <= 0 ? 0 : a >= 255 ? 255 : a;
  14678. }
  14679. JpegImage.prototype = {
  14680. parse: function parse(data) {
  14681. function readUint16() {
  14682. var value = data[offset] << 8 | data[offset + 1];
  14683. offset += 2;
  14684. return value;
  14685. }
  14686. function readDataBlock() {
  14687. var length = readUint16();
  14688. var array = data.subarray(offset, offset + length - 2);
  14689. offset += array.length;
  14690. return array;
  14691. }
  14692. function prepareComponents(frame) {
  14693. var mcusPerLine = Math.ceil(frame.samplesPerLine / 8 / frame.maxH);
  14694. var mcusPerColumn = Math.ceil(frame.scanLines / 8 / frame.maxV);
  14695. for (var i = 0; i < frame.components.length; i++) {
  14696. component = frame.components[i];
  14697. var blocksPerLine = Math.ceil(Math.ceil(frame.samplesPerLine / 8) * component.h / frame.maxH);
  14698. var blocksPerColumn = Math.ceil(Math.ceil(frame.scanLines / 8) * component.v / frame.maxV);
  14699. var blocksPerLineForMcu = mcusPerLine * component.h;
  14700. var blocksPerColumnForMcu = mcusPerColumn * component.v;
  14701. var blocksBufferSize = 64 * blocksPerColumnForMcu * (blocksPerLineForMcu + 1);
  14702. component.blockData = new Int16Array(blocksBufferSize);
  14703. component.blocksPerLine = blocksPerLine;
  14704. component.blocksPerColumn = blocksPerColumn;
  14705. }
  14706. frame.mcusPerLine = mcusPerLine;
  14707. frame.mcusPerColumn = mcusPerColumn;
  14708. }
  14709. var offset = 0;
  14710. var jfif = null;
  14711. var adobe = null;
  14712. var frame, resetInterval;
  14713. var quantizationTables = [];
  14714. var huffmanTablesAC = [], huffmanTablesDC = [];
  14715. var fileMarker = readUint16();
  14716. if (fileMarker !== 0xFFD8) {
  14717. error('JPEG error: SOI not found');
  14718. }
  14719. fileMarker = readUint16();
  14720. while (fileMarker !== 0xFFD9) {
  14721. var i, j, l;
  14722. switch (fileMarker) {
  14723. case 0xFFE0:
  14724. case 0xFFE1:
  14725. case 0xFFE2:
  14726. case 0xFFE3:
  14727. case 0xFFE4:
  14728. case 0xFFE5:
  14729. case 0xFFE6:
  14730. case 0xFFE7:
  14731. case 0xFFE8:
  14732. case 0xFFE9:
  14733. case 0xFFEA:
  14734. case 0xFFEB:
  14735. case 0xFFEC:
  14736. case 0xFFED:
  14737. case 0xFFEE:
  14738. case 0xFFEF:
  14739. case 0xFFFE:
  14740. var appData = readDataBlock();
  14741. if (fileMarker === 0xFFE0) {
  14742. if (appData[0] === 0x4A && appData[1] === 0x46 && appData[2] === 0x49 && appData[3] === 0x46 && appData[4] === 0) {
  14743. jfif = {
  14744. version: {
  14745. major: appData[5],
  14746. minor: appData[6]
  14747. },
  14748. densityUnits: appData[7],
  14749. xDensity: appData[8] << 8 | appData[9],
  14750. yDensity: appData[10] << 8 | appData[11],
  14751. thumbWidth: appData[12],
  14752. thumbHeight: appData[13],
  14753. thumbData: appData.subarray(14, 14 + 3 * appData[12] * appData[13])
  14754. };
  14755. }
  14756. }
  14757. if (fileMarker === 0xFFEE) {
  14758. if (appData[0] === 0x41 && appData[1] === 0x64 && appData[2] === 0x6F && appData[3] === 0x62 && appData[4] === 0x65) {
  14759. adobe = {
  14760. version: appData[5] << 8 | appData[6],
  14761. flags0: appData[7] << 8 | appData[8],
  14762. flags1: appData[9] << 8 | appData[10],
  14763. transformCode: appData[11]
  14764. };
  14765. }
  14766. }
  14767. break;
  14768. case 0xFFDB:
  14769. var quantizationTablesLength = readUint16();
  14770. var quantizationTablesEnd = quantizationTablesLength + offset - 2;
  14771. var z;
  14772. while (offset < quantizationTablesEnd) {
  14773. var quantizationTableSpec = data[offset++];
  14774. var tableData = new Uint16Array(64);
  14775. if (quantizationTableSpec >> 4 === 0) {
  14776. for (j = 0; j < 64; j++) {
  14777. z = dctZigZag[j];
  14778. tableData[z] = data[offset++];
  14779. }
  14780. } else if (quantizationTableSpec >> 4 === 1) {
  14781. for (j = 0; j < 64; j++) {
  14782. z = dctZigZag[j];
  14783. tableData[z] = readUint16();
  14784. }
  14785. } else {
  14786. error('JPEG error: DQT - invalid table spec');
  14787. }
  14788. quantizationTables[quantizationTableSpec & 15] = tableData;
  14789. }
  14790. break;
  14791. case 0xFFC0:
  14792. case 0xFFC1:
  14793. case 0xFFC2:
  14794. if (frame) {
  14795. error('JPEG error: Only single frame JPEGs supported');
  14796. }
  14797. readUint16();
  14798. frame = {};
  14799. frame.extended = fileMarker === 0xFFC1;
  14800. frame.progressive = fileMarker === 0xFFC2;
  14801. frame.precision = data[offset++];
  14802. frame.scanLines = readUint16();
  14803. frame.samplesPerLine = readUint16();
  14804. frame.components = [];
  14805. frame.componentIds = {};
  14806. var componentsCount = data[offset++], componentId;
  14807. var maxH = 0, maxV = 0;
  14808. for (i = 0; i < componentsCount; i++) {
  14809. componentId = data[offset];
  14810. var h = data[offset + 1] >> 4;
  14811. var v = data[offset + 1] & 15;
  14812. if (maxH < h) {
  14813. maxH = h;
  14814. }
  14815. if (maxV < v) {
  14816. maxV = v;
  14817. }
  14818. var qId = data[offset + 2];
  14819. l = frame.components.push({
  14820. h: h,
  14821. v: v,
  14822. quantizationId: qId,
  14823. quantizationTable: null
  14824. });
  14825. frame.componentIds[componentId] = l - 1;
  14826. offset += 3;
  14827. }
  14828. frame.maxH = maxH;
  14829. frame.maxV = maxV;
  14830. prepareComponents(frame);
  14831. break;
  14832. case 0xFFC4:
  14833. var huffmanLength = readUint16();
  14834. for (i = 2; i < huffmanLength;) {
  14835. var huffmanTableSpec = data[offset++];
  14836. var codeLengths = new Uint8Array(16);
  14837. var codeLengthSum = 0;
  14838. for (j = 0; j < 16; j++, offset++) {
  14839. codeLengthSum += codeLengths[j] = data[offset];
  14840. }
  14841. var huffmanValues = new Uint8Array(codeLengthSum);
  14842. for (j = 0; j < codeLengthSum; j++, offset++) {
  14843. huffmanValues[j] = data[offset];
  14844. }
  14845. i += 17 + codeLengthSum;
  14846. (huffmanTableSpec >> 4 === 0 ? huffmanTablesDC : huffmanTablesAC)[huffmanTableSpec & 15] = buildHuffmanTable(codeLengths, huffmanValues);
  14847. }
  14848. break;
  14849. case 0xFFDD:
  14850. readUint16();
  14851. resetInterval = readUint16();
  14852. break;
  14853. case 0xFFDA:
  14854. var scanLength = readUint16();
  14855. var selectorsCount = data[offset++];
  14856. var components = [], component;
  14857. for (i = 0; i < selectorsCount; i++) {
  14858. var componentIndex = frame.componentIds[data[offset++]];
  14859. component = frame.components[componentIndex];
  14860. var tableSpec = data[offset++];
  14861. component.huffmanTableDC = huffmanTablesDC[tableSpec >> 4];
  14862. component.huffmanTableAC = huffmanTablesAC[tableSpec & 15];
  14863. components.push(component);
  14864. }
  14865. var spectralStart = data[offset++];
  14866. var spectralEnd = data[offset++];
  14867. var successiveApproximation = data[offset++];
  14868. var processed = decodeScan(data, offset, frame, components, resetInterval, spectralStart, spectralEnd, successiveApproximation >> 4, successiveApproximation & 15);
  14869. offset += processed;
  14870. break;
  14871. case 0xFFFF:
  14872. if (data[offset] !== 0xFF) {
  14873. offset--;
  14874. }
  14875. break;
  14876. default:
  14877. if (data[offset - 3] === 0xFF && data[offset - 2] >= 0xC0 && data[offset - 2] <= 0xFE) {
  14878. offset -= 3;
  14879. break;
  14880. }
  14881. error('JPEG error: unknown marker ' + fileMarker.toString(16));
  14882. }
  14883. fileMarker = readUint16();
  14884. }
  14885. this.width = frame.samplesPerLine;
  14886. this.height = frame.scanLines;
  14887. this.jfif = jfif;
  14888. this.adobe = adobe;
  14889. this.components = [];
  14890. for (i = 0; i < frame.components.length; i++) {
  14891. component = frame.components[i];
  14892. var quantizationTable = quantizationTables[component.quantizationId];
  14893. if (quantizationTable) {
  14894. component.quantizationTable = quantizationTable;
  14895. }
  14896. this.components.push({
  14897. output: buildComponentData(frame, component),
  14898. scaleX: component.h / frame.maxH,
  14899. scaleY: component.v / frame.maxV,
  14900. blocksPerLine: component.blocksPerLine,
  14901. blocksPerColumn: component.blocksPerColumn
  14902. });
  14903. }
  14904. this.numComponents = this.components.length;
  14905. },
  14906. _getLinearizedBlockData: function getLinearizedBlockData(width, height) {
  14907. var scaleX = this.width / width, scaleY = this.height / height;
  14908. var component, componentScaleX, componentScaleY, blocksPerScanline;
  14909. var x, y, i, j, k;
  14910. var index;
  14911. var offset = 0;
  14912. var output;
  14913. var numComponents = this.components.length;
  14914. var dataLength = width * height * numComponents;
  14915. var data = new Uint8Array(dataLength);
  14916. var xScaleBlockOffset = new Uint32Array(width);
  14917. var mask3LSB = 0xfffffff8;
  14918. for (i = 0; i < numComponents; i++) {
  14919. component = this.components[i];
  14920. componentScaleX = component.scaleX * scaleX;
  14921. componentScaleY = component.scaleY * scaleY;
  14922. offset = i;
  14923. output = component.output;
  14924. blocksPerScanline = component.blocksPerLine + 1 << 3;
  14925. for (x = 0; x < width; x++) {
  14926. j = 0 | x * componentScaleX;
  14927. xScaleBlockOffset[x] = (j & mask3LSB) << 3 | j & 7;
  14928. }
  14929. for (y = 0; y < height; y++) {
  14930. j = 0 | y * componentScaleY;
  14931. index = blocksPerScanline * (j & mask3LSB) | (j & 7) << 3;
  14932. for (x = 0; x < width; x++) {
  14933. data[offset] = output[index + xScaleBlockOffset[x]];
  14934. offset += numComponents;
  14935. }
  14936. }
  14937. }
  14938. var transform = this.decodeTransform;
  14939. if (transform) {
  14940. for (i = 0; i < dataLength;) {
  14941. for (j = 0, k = 0; j < numComponents; j++, i++, k += 2) {
  14942. data[i] = (data[i] * transform[k] >> 8) + transform[k + 1];
  14943. }
  14944. }
  14945. }
  14946. return data;
  14947. },
  14948. _isColorConversionNeeded: function isColorConversionNeeded() {
  14949. if (this.adobe && this.adobe.transformCode) {
  14950. return true;
  14951. } else if (this.numComponents === 3) {
  14952. if (!this.adobe && this.colorTransform === 0) {
  14953. return false;
  14954. }
  14955. return true;
  14956. } else {
  14957. if (!this.adobe && this.colorTransform === 1) {
  14958. return true;
  14959. }
  14960. return false;
  14961. }
  14962. },
  14963. _convertYccToRgb: function convertYccToRgb(data) {
  14964. var Y, Cb, Cr;
  14965. for (var i = 0, length = data.length; i < length; i += 3) {
  14966. Y = data[i];
  14967. Cb = data[i + 1];
  14968. Cr = data[i + 2];
  14969. data[i] = clamp0to255(Y - 179.456 + 1.402 * Cr);
  14970. data[i + 1] = clamp0to255(Y + 135.459 - 0.344 * Cb - 0.714 * Cr);
  14971. data[i + 2] = clamp0to255(Y - 226.816 + 1.772 * Cb);
  14972. }
  14973. return data;
  14974. },
  14975. _convertYcckToRgb: function convertYcckToRgb(data) {
  14976. var Y, Cb, Cr, k;
  14977. var offset = 0;
  14978. for (var i = 0, length = data.length; i < length; i += 4) {
  14979. Y = data[i];
  14980. Cb = data[i + 1];
  14981. Cr = data[i + 2];
  14982. k = data[i + 3];
  14983. var r = -122.67195406894 + Cb * (-6.60635669420364e-5 * Cb + 0.000437130475926232 * Cr - 5.4080610064599e-5 * Y + 0.00048449797120281 * k - 0.154362151871126) + Cr * (-0.000957964378445773 * Cr + 0.000817076911346625 * Y - 0.00477271405408747 * k + 1.53380253221734) + Y * (0.000961250184130688 * Y - 0.00266257332283933 * k + 0.48357088451265) + k * (-0.000336197177618394 * k + 0.484791561490776);
  14984. var g = 107.268039397724 + Cb * (2.19927104525741e-5 * Cb - 0.000640992018297945 * Cr + 0.000659397001245577 * Y + 0.000426105652938837 * k - 0.176491792462875) + Cr * (-0.000778269941513683 * Cr + 0.00130872261408275 * Y + 0.000770482631801132 * k - 0.151051492775562) + Y * (0.00126935368114843 * Y - 0.00265090189010898 * k + 0.25802910206845) + k * (-0.000318913117588328 * k - 0.213742400323665);
  14985. var b = -20.810012546947 + Cb * (-0.000570115196973677 * Cb - 2.63409051004589e-5 * Cr + 0.0020741088115012 * Y - 0.00288260236853442 * k + 0.814272968359295) + Cr * (-1.53496057440975e-5 * Cr - 0.000132689043961446 * Y + 0.000560833691242812 * k - 0.195152027534049) + Y * (0.00174418132927582 * Y - 0.00255243321439347 * k + 0.116935020465145) + k * (-0.000343531996510555 * k + 0.24165260232407);
  14986. data[offset++] = clamp0to255(r);
  14987. data[offset++] = clamp0to255(g);
  14988. data[offset++] = clamp0to255(b);
  14989. }
  14990. return data;
  14991. },
  14992. _convertYcckToCmyk: function convertYcckToCmyk(data) {
  14993. var Y, Cb, Cr;
  14994. for (var i = 0, length = data.length; i < length; i += 4) {
  14995. Y = data[i];
  14996. Cb = data[i + 1];
  14997. Cr = data[i + 2];
  14998. data[i] = clamp0to255(434.456 - Y - 1.402 * Cr);
  14999. data[i + 1] = clamp0to255(119.541 - Y + 0.344 * Cb + 0.714 * Cr);
  15000. data[i + 2] = clamp0to255(481.816 - Y - 1.772 * Cb);
  15001. }
  15002. return data;
  15003. },
  15004. _convertCmykToRgb: function convertCmykToRgb(data) {
  15005. var c, m, y, k;
  15006. var offset = 0;
  15007. var min = -255 * 255 * 255;
  15008. var scale = 1 / 255 / 255;
  15009. for (var i = 0, length = data.length; i < length; i += 4) {
  15010. c = data[i];
  15011. m = data[i + 1];
  15012. y = data[i + 2];
  15013. k = data[i + 3];
  15014. var r = c * (-4.387332384609988 * c + 54.48615194189176 * m + 18.82290502165302 * y + 212.25662451639585 * k - 72734.4411664936) + m * (1.7149763477362134 * m - 5.6096736904047315 * y - 17.873870861415444 * k - 1401.7366389350734) + y * (-2.5217340131683033 * y - 21.248923337353073 * k + 4465.541406466231) - k * (21.86122147463605 * k + 48317.86113160301);
  15015. var g = c * (8.841041422036149 * c + 60.118027045597366 * m + 6.871425592049007 * y + 31.159100130055922 * k - 20220.756542821975) + m * (-15.310361306967817 * m + 17.575251261109482 * y + 131.35250912493976 * k - 48691.05921601825) + y * (4.444339102852739 * y + 9.8632861493405 * k - 6341.191035517494) - k * (20.737325471181034 * k + 47890.15695978492);
  15016. var b = c * (0.8842522430003296 * c + 8.078677503112928 * m + 30.89978309703729 * y - 0.23883238689178934 * k - 3616.812083916688) + m * (10.49593273432072 * m + 63.02378494754052 * y + 50.606957656360734 * k - 28620.90484698408) + y * (0.03296041114873217 * y + 115.60384449646641 * k - 49363.43385999684) - k * (22.33816807309886 * k + 45932.16563550634);
  15017. data[offset++] = r >= 0 ? 255 : r <= min ? 0 : 255 + r * scale | 0;
  15018. data[offset++] = g >= 0 ? 255 : g <= min ? 0 : 255 + g * scale | 0;
  15019. data[offset++] = b >= 0 ? 255 : b <= min ? 0 : 255 + b * scale | 0;
  15020. }
  15021. return data;
  15022. },
  15023. getData: function getData(width, height, forceRGBoutput) {
  15024. if (this.numComponents > 4) {
  15025. error('JPEG error: Unsupported color mode');
  15026. }
  15027. var data = this._getLinearizedBlockData(width, height);
  15028. if (this.numComponents === 1 && forceRGBoutput) {
  15029. var dataLength = data.length;
  15030. var rgbData = new Uint8Array(dataLength * 3);
  15031. var offset = 0;
  15032. for (var i = 0; i < dataLength; i++) {
  15033. var grayColor = data[i];
  15034. rgbData[offset++] = grayColor;
  15035. rgbData[offset++] = grayColor;
  15036. rgbData[offset++] = grayColor;
  15037. }
  15038. return rgbData;
  15039. } else if (this.numComponents === 3 && this._isColorConversionNeeded()) {
  15040. return this._convertYccToRgb(data);
  15041. } else if (this.numComponents === 4) {
  15042. if (this._isColorConversionNeeded()) {
  15043. if (forceRGBoutput) {
  15044. return this._convertYcckToRgb(data);
  15045. } else {
  15046. return this._convertYcckToCmyk(data);
  15047. }
  15048. } else if (forceRGBoutput) {
  15049. return this._convertCmykToRgb(data);
  15050. }
  15051. }
  15052. return data;
  15053. }
  15054. };
  15055. return JpegImage;
  15056. }();
  15057. exports.JpegImage = JpegImage;
  15058. }));
  15059. (function (root, factory) {
  15060. factory(root.pdfjsCoreJpx = {}, root.pdfjsSharedUtil, root.pdfjsCoreArithmeticDecoder);
  15061. }(this, function (exports, sharedUtil, coreArithmeticDecoder) {
  15062. var info = sharedUtil.info;
  15063. var warn = sharedUtil.warn;
  15064. var error = sharedUtil.error;
  15065. var log2 = sharedUtil.log2;
  15066. var readUint16 = sharedUtil.readUint16;
  15067. var readUint32 = sharedUtil.readUint32;
  15068. var ArithmeticDecoder = coreArithmeticDecoder.ArithmeticDecoder;
  15069. var JpxImage = function JpxImageClosure() {
  15070. var SubbandsGainLog2 = {
  15071. 'LL': 0,
  15072. 'LH': 1,
  15073. 'HL': 1,
  15074. 'HH': 2
  15075. };
  15076. function JpxImage() {
  15077. this.failOnCorruptedImage = false;
  15078. }
  15079. JpxImage.prototype = {
  15080. parse: function JpxImage_parse(data) {
  15081. var head = readUint16(data, 0);
  15082. if (head === 0xFF4F) {
  15083. this.parseCodestream(data, 0, data.length);
  15084. return;
  15085. }
  15086. var position = 0, length = data.length;
  15087. while (position < length) {
  15088. var headerSize = 8;
  15089. var lbox = readUint32(data, position);
  15090. var tbox = readUint32(data, position + 4);
  15091. position += headerSize;
  15092. if (lbox === 1) {
  15093. lbox = readUint32(data, position) * 4294967296 + readUint32(data, position + 4);
  15094. position += 8;
  15095. headerSize += 8;
  15096. }
  15097. if (lbox === 0) {
  15098. lbox = length - position + headerSize;
  15099. }
  15100. if (lbox < headerSize) {
  15101. error('JPX Error: Invalid box field size');
  15102. }
  15103. var dataLength = lbox - headerSize;
  15104. var jumpDataLength = true;
  15105. switch (tbox) {
  15106. case 0x6A703268:
  15107. jumpDataLength = false;
  15108. break;
  15109. case 0x636F6C72:
  15110. var method = data[position];
  15111. if (method === 1) {
  15112. var colorspace = readUint32(data, position + 3);
  15113. switch (colorspace) {
  15114. case 16:
  15115. case 17:
  15116. case 18:
  15117. break;
  15118. default:
  15119. warn('Unknown colorspace ' + colorspace);
  15120. break;
  15121. }
  15122. } else if (method === 2) {
  15123. info('ICC profile not supported');
  15124. }
  15125. break;
  15126. case 0x6A703263:
  15127. this.parseCodestream(data, position, position + dataLength);
  15128. break;
  15129. case 0x6A502020:
  15130. if (0x0d0a870a !== readUint32(data, position)) {
  15131. warn('Invalid JP2 signature');
  15132. }
  15133. break;
  15134. case 0x6A501A1A:
  15135. case 0x66747970:
  15136. case 0x72726571:
  15137. case 0x72657320:
  15138. case 0x69686472:
  15139. break;
  15140. default:
  15141. var headerType = String.fromCharCode(tbox >> 24 & 0xFF, tbox >> 16 & 0xFF, tbox >> 8 & 0xFF, tbox & 0xFF);
  15142. warn('Unsupported header type ' + tbox + ' (' + headerType + ')');
  15143. break;
  15144. }
  15145. if (jumpDataLength) {
  15146. position += dataLength;
  15147. }
  15148. }
  15149. },
  15150. parseImageProperties: function JpxImage_parseImageProperties(stream) {
  15151. var newByte = stream.getByte();
  15152. while (newByte >= 0) {
  15153. var oldByte = newByte;
  15154. newByte = stream.getByte();
  15155. var code = oldByte << 8 | newByte;
  15156. if (code === 0xFF51) {
  15157. stream.skip(4);
  15158. var Xsiz = stream.getInt32() >>> 0;
  15159. var Ysiz = stream.getInt32() >>> 0;
  15160. var XOsiz = stream.getInt32() >>> 0;
  15161. var YOsiz = stream.getInt32() >>> 0;
  15162. stream.skip(16);
  15163. var Csiz = stream.getUint16();
  15164. this.width = Xsiz - XOsiz;
  15165. this.height = Ysiz - YOsiz;
  15166. this.componentsCount = Csiz;
  15167. this.bitsPerComponent = 8;
  15168. return;
  15169. }
  15170. }
  15171. error('JPX Error: No size marker found in JPX stream');
  15172. },
  15173. parseCodestream: function JpxImage_parseCodestream(data, start, end) {
  15174. var context = {};
  15175. var doNotRecover = false;
  15176. try {
  15177. var position = start;
  15178. while (position + 1 < end) {
  15179. var code = readUint16(data, position);
  15180. position += 2;
  15181. var length = 0, j, sqcd, spqcds, spqcdSize, scalarExpounded, tile;
  15182. switch (code) {
  15183. case 0xFF4F:
  15184. context.mainHeader = true;
  15185. break;
  15186. case 0xFFD9:
  15187. break;
  15188. case 0xFF51:
  15189. length = readUint16(data, position);
  15190. var siz = {};
  15191. siz.Xsiz = readUint32(data, position + 4);
  15192. siz.Ysiz = readUint32(data, position + 8);
  15193. siz.XOsiz = readUint32(data, position + 12);
  15194. siz.YOsiz = readUint32(data, position + 16);
  15195. siz.XTsiz = readUint32(data, position + 20);
  15196. siz.YTsiz = readUint32(data, position + 24);
  15197. siz.XTOsiz = readUint32(data, position + 28);
  15198. siz.YTOsiz = readUint32(data, position + 32);
  15199. var componentsCount = readUint16(data, position + 36);
  15200. siz.Csiz = componentsCount;
  15201. var components = [];
  15202. j = position + 38;
  15203. for (var i = 0; i < componentsCount; i++) {
  15204. var component = {
  15205. precision: (data[j] & 0x7F) + 1,
  15206. isSigned: !!(data[j] & 0x80),
  15207. XRsiz: data[j + 1],
  15208. YRsiz: data[j + 1]
  15209. };
  15210. calculateComponentDimensions(component, siz);
  15211. components.push(component);
  15212. }
  15213. context.SIZ = siz;
  15214. context.components = components;
  15215. calculateTileGrids(context, components);
  15216. context.QCC = [];
  15217. context.COC = [];
  15218. break;
  15219. case 0xFF5C:
  15220. length = readUint16(data, position);
  15221. var qcd = {};
  15222. j = position + 2;
  15223. sqcd = data[j++];
  15224. switch (sqcd & 0x1F) {
  15225. case 0:
  15226. spqcdSize = 8;
  15227. scalarExpounded = true;
  15228. break;
  15229. case 1:
  15230. spqcdSize = 16;
  15231. scalarExpounded = false;
  15232. break;
  15233. case 2:
  15234. spqcdSize = 16;
  15235. scalarExpounded = true;
  15236. break;
  15237. default:
  15238. throw new Error('Invalid SQcd value ' + sqcd);
  15239. }
  15240. qcd.noQuantization = spqcdSize === 8;
  15241. qcd.scalarExpounded = scalarExpounded;
  15242. qcd.guardBits = sqcd >> 5;
  15243. spqcds = [];
  15244. while (j < length + position) {
  15245. var spqcd = {};
  15246. if (spqcdSize === 8) {
  15247. spqcd.epsilon = data[j++] >> 3;
  15248. spqcd.mu = 0;
  15249. } else {
  15250. spqcd.epsilon = data[j] >> 3;
  15251. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15252. j += 2;
  15253. }
  15254. spqcds.push(spqcd);
  15255. }
  15256. qcd.SPqcds = spqcds;
  15257. if (context.mainHeader) {
  15258. context.QCD = qcd;
  15259. } else {
  15260. context.currentTile.QCD = qcd;
  15261. context.currentTile.QCC = [];
  15262. }
  15263. break;
  15264. case 0xFF5D:
  15265. length = readUint16(data, position);
  15266. var qcc = {};
  15267. j = position + 2;
  15268. var cqcc;
  15269. if (context.SIZ.Csiz < 257) {
  15270. cqcc = data[j++];
  15271. } else {
  15272. cqcc = readUint16(data, j);
  15273. j += 2;
  15274. }
  15275. sqcd = data[j++];
  15276. switch (sqcd & 0x1F) {
  15277. case 0:
  15278. spqcdSize = 8;
  15279. scalarExpounded = true;
  15280. break;
  15281. case 1:
  15282. spqcdSize = 16;
  15283. scalarExpounded = false;
  15284. break;
  15285. case 2:
  15286. spqcdSize = 16;
  15287. scalarExpounded = true;
  15288. break;
  15289. default:
  15290. throw new Error('Invalid SQcd value ' + sqcd);
  15291. }
  15292. qcc.noQuantization = spqcdSize === 8;
  15293. qcc.scalarExpounded = scalarExpounded;
  15294. qcc.guardBits = sqcd >> 5;
  15295. spqcds = [];
  15296. while (j < length + position) {
  15297. spqcd = {};
  15298. if (spqcdSize === 8) {
  15299. spqcd.epsilon = data[j++] >> 3;
  15300. spqcd.mu = 0;
  15301. } else {
  15302. spqcd.epsilon = data[j] >> 3;
  15303. spqcd.mu = (data[j] & 0x7) << 8 | data[j + 1];
  15304. j += 2;
  15305. }
  15306. spqcds.push(spqcd);
  15307. }
  15308. qcc.SPqcds = spqcds;
  15309. if (context.mainHeader) {
  15310. context.QCC[cqcc] = qcc;
  15311. } else {
  15312. context.currentTile.QCC[cqcc] = qcc;
  15313. }
  15314. break;
  15315. case 0xFF52:
  15316. length = readUint16(data, position);
  15317. var cod = {};
  15318. j = position + 2;
  15319. var scod = data[j++];
  15320. cod.entropyCoderWithCustomPrecincts = !!(scod & 1);
  15321. cod.sopMarkerUsed = !!(scod & 2);
  15322. cod.ephMarkerUsed = !!(scod & 4);
  15323. cod.progressionOrder = data[j++];
  15324. cod.layersCount = readUint16(data, j);
  15325. j += 2;
  15326. cod.multipleComponentTransform = data[j++];
  15327. cod.decompositionLevelsCount = data[j++];
  15328. cod.xcb = (data[j++] & 0xF) + 2;
  15329. cod.ycb = (data[j++] & 0xF) + 2;
  15330. var blockStyle = data[j++];
  15331. cod.selectiveArithmeticCodingBypass = !!(blockStyle & 1);
  15332. cod.resetContextProbabilities = !!(blockStyle & 2);
  15333. cod.terminationOnEachCodingPass = !!(blockStyle & 4);
  15334. cod.verticalyStripe = !!(blockStyle & 8);
  15335. cod.predictableTermination = !!(blockStyle & 16);
  15336. cod.segmentationSymbolUsed = !!(blockStyle & 32);
  15337. cod.reversibleTransformation = data[j++];
  15338. if (cod.entropyCoderWithCustomPrecincts) {
  15339. var precinctsSizes = [];
  15340. while (j < length + position) {
  15341. var precinctsSize = data[j++];
  15342. precinctsSizes.push({
  15343. PPx: precinctsSize & 0xF,
  15344. PPy: precinctsSize >> 4
  15345. });
  15346. }
  15347. cod.precinctsSizes = precinctsSizes;
  15348. }
  15349. var unsupported = [];
  15350. if (cod.selectiveArithmeticCodingBypass) {
  15351. unsupported.push('selectiveArithmeticCodingBypass');
  15352. }
  15353. if (cod.resetContextProbabilities) {
  15354. unsupported.push('resetContextProbabilities');
  15355. }
  15356. if (cod.terminationOnEachCodingPass) {
  15357. unsupported.push('terminationOnEachCodingPass');
  15358. }
  15359. if (cod.verticalyStripe) {
  15360. unsupported.push('verticalyStripe');
  15361. }
  15362. if (cod.predictableTermination) {
  15363. unsupported.push('predictableTermination');
  15364. }
  15365. if (unsupported.length > 0) {
  15366. doNotRecover = true;
  15367. throw new Error('Unsupported COD options (' + unsupported.join(', ') + ')');
  15368. }
  15369. if (context.mainHeader) {
  15370. context.COD = cod;
  15371. } else {
  15372. context.currentTile.COD = cod;
  15373. context.currentTile.COC = [];
  15374. }
  15375. break;
  15376. case 0xFF90:
  15377. length = readUint16(data, position);
  15378. tile = {};
  15379. tile.index = readUint16(data, position + 2);
  15380. tile.length = readUint32(data, position + 4);
  15381. tile.dataEnd = tile.length + position - 2;
  15382. tile.partIndex = data[position + 8];
  15383. tile.partsCount = data[position + 9];
  15384. context.mainHeader = false;
  15385. if (tile.partIndex === 0) {
  15386. tile.COD = context.COD;
  15387. tile.COC = context.COC.slice(0);
  15388. tile.QCD = context.QCD;
  15389. tile.QCC = context.QCC.slice(0);
  15390. }
  15391. context.currentTile = tile;
  15392. break;
  15393. case 0xFF93:
  15394. tile = context.currentTile;
  15395. if (tile.partIndex === 0) {
  15396. initializeTile(context, tile.index);
  15397. buildPackets(context);
  15398. }
  15399. length = tile.dataEnd - position;
  15400. parseTilePackets(context, data, position, length);
  15401. break;
  15402. case 0xFF55:
  15403. case 0xFF57:
  15404. case 0xFF58:
  15405. case 0xFF64:
  15406. length = readUint16(data, position);
  15407. break;
  15408. case 0xFF53:
  15409. throw new Error('Codestream code 0xFF53 (COC) is ' + 'not implemented');
  15410. default:
  15411. throw new Error('Unknown codestream code: ' + code.toString(16));
  15412. }
  15413. position += length;
  15414. }
  15415. } catch (e) {
  15416. if (doNotRecover || this.failOnCorruptedImage) {
  15417. error('JPX Error: ' + e.message);
  15418. } else {
  15419. warn('JPX: Trying to recover from: ' + e.message);
  15420. }
  15421. }
  15422. this.tiles = transformComponents(context);
  15423. this.width = context.SIZ.Xsiz - context.SIZ.XOsiz;
  15424. this.height = context.SIZ.Ysiz - context.SIZ.YOsiz;
  15425. this.componentsCount = context.SIZ.Csiz;
  15426. }
  15427. };
  15428. function calculateComponentDimensions(component, siz) {
  15429. component.x0 = Math.ceil(siz.XOsiz / component.XRsiz);
  15430. component.x1 = Math.ceil(siz.Xsiz / component.XRsiz);
  15431. component.y0 = Math.ceil(siz.YOsiz / component.YRsiz);
  15432. component.y1 = Math.ceil(siz.Ysiz / component.YRsiz);
  15433. component.width = component.x1 - component.x0;
  15434. component.height = component.y1 - component.y0;
  15435. }
  15436. function calculateTileGrids(context, components) {
  15437. var siz = context.SIZ;
  15438. var tile, tiles = [];
  15439. var numXtiles = Math.ceil((siz.Xsiz - siz.XTOsiz) / siz.XTsiz);
  15440. var numYtiles = Math.ceil((siz.Ysiz - siz.YTOsiz) / siz.YTsiz);
  15441. for (var q = 0; q < numYtiles; q++) {
  15442. for (var p = 0; p < numXtiles; p++) {
  15443. tile = {};
  15444. tile.tx0 = Math.max(siz.XTOsiz + p * siz.XTsiz, siz.XOsiz);
  15445. tile.ty0 = Math.max(siz.YTOsiz + q * siz.YTsiz, siz.YOsiz);
  15446. tile.tx1 = Math.min(siz.XTOsiz + (p + 1) * siz.XTsiz, siz.Xsiz);
  15447. tile.ty1 = Math.min(siz.YTOsiz + (q + 1) * siz.YTsiz, siz.Ysiz);
  15448. tile.width = tile.tx1 - tile.tx0;
  15449. tile.height = tile.ty1 - tile.ty0;
  15450. tile.components = [];
  15451. tiles.push(tile);
  15452. }
  15453. }
  15454. context.tiles = tiles;
  15455. var componentsCount = siz.Csiz;
  15456. for (var i = 0, ii = componentsCount; i < ii; i++) {
  15457. var component = components[i];
  15458. for (var j = 0, jj = tiles.length; j < jj; j++) {
  15459. var tileComponent = {};
  15460. tile = tiles[j];
  15461. tileComponent.tcx0 = Math.ceil(tile.tx0 / component.XRsiz);
  15462. tileComponent.tcy0 = Math.ceil(tile.ty0 / component.YRsiz);
  15463. tileComponent.tcx1 = Math.ceil(tile.tx1 / component.XRsiz);
  15464. tileComponent.tcy1 = Math.ceil(tile.ty1 / component.YRsiz);
  15465. tileComponent.width = tileComponent.tcx1 - tileComponent.tcx0;
  15466. tileComponent.height = tileComponent.tcy1 - tileComponent.tcy0;
  15467. tile.components[i] = tileComponent;
  15468. }
  15469. }
  15470. }
  15471. function getBlocksDimensions(context, component, r) {
  15472. var codOrCoc = component.codingStyleParameters;
  15473. var result = {};
  15474. if (!codOrCoc.entropyCoderWithCustomPrecincts) {
  15475. result.PPx = 15;
  15476. result.PPy = 15;
  15477. } else {
  15478. result.PPx = codOrCoc.precinctsSizes[r].PPx;
  15479. result.PPy = codOrCoc.precinctsSizes[r].PPy;
  15480. }
  15481. result.xcb_ = r > 0 ? Math.min(codOrCoc.xcb, result.PPx - 1) : Math.min(codOrCoc.xcb, result.PPx);
  15482. result.ycb_ = r > 0 ? Math.min(codOrCoc.ycb, result.PPy - 1) : Math.min(codOrCoc.ycb, result.PPy);
  15483. return result;
  15484. }
  15485. function buildPrecincts(context, resolution, dimensions) {
  15486. var precinctWidth = 1 << dimensions.PPx;
  15487. var precinctHeight = 1 << dimensions.PPy;
  15488. var isZeroRes = resolution.resLevel === 0;
  15489. var precinctWidthInSubband = 1 << dimensions.PPx + (isZeroRes ? 0 : -1);
  15490. var precinctHeightInSubband = 1 << dimensions.PPy + (isZeroRes ? 0 : -1);
  15491. var numprecinctswide = resolution.trx1 > resolution.trx0 ? Math.ceil(resolution.trx1 / precinctWidth) - Math.floor(resolution.trx0 / precinctWidth) : 0;
  15492. var numprecinctshigh = resolution.try1 > resolution.try0 ? Math.ceil(resolution.try1 / precinctHeight) - Math.floor(resolution.try0 / precinctHeight) : 0;
  15493. var numprecincts = numprecinctswide * numprecinctshigh;
  15494. resolution.precinctParameters = {
  15495. precinctWidth: precinctWidth,
  15496. precinctHeight: precinctHeight,
  15497. numprecinctswide: numprecinctswide,
  15498. numprecinctshigh: numprecinctshigh,
  15499. numprecincts: numprecincts,
  15500. precinctWidthInSubband: precinctWidthInSubband,
  15501. precinctHeightInSubband: precinctHeightInSubband
  15502. };
  15503. }
  15504. function buildCodeblocks(context, subband, dimensions) {
  15505. var xcb_ = dimensions.xcb_;
  15506. var ycb_ = dimensions.ycb_;
  15507. var codeblockWidth = 1 << xcb_;
  15508. var codeblockHeight = 1 << ycb_;
  15509. var cbx0 = subband.tbx0 >> xcb_;
  15510. var cby0 = subband.tby0 >> ycb_;
  15511. var cbx1 = subband.tbx1 + codeblockWidth - 1 >> xcb_;
  15512. var cby1 = subband.tby1 + codeblockHeight - 1 >> ycb_;
  15513. var precinctParameters = subband.resolution.precinctParameters;
  15514. var codeblocks = [];
  15515. var precincts = [];
  15516. var i, j, codeblock, precinctNumber;
  15517. for (j = cby0; j < cby1; j++) {
  15518. for (i = cbx0; i < cbx1; i++) {
  15519. codeblock = {
  15520. cbx: i,
  15521. cby: j,
  15522. tbx0: codeblockWidth * i,
  15523. tby0: codeblockHeight * j,
  15524. tbx1: codeblockWidth * (i + 1),
  15525. tby1: codeblockHeight * (j + 1)
  15526. };
  15527. codeblock.tbx0_ = Math.max(subband.tbx0, codeblock.tbx0);
  15528. codeblock.tby0_ = Math.max(subband.tby0, codeblock.tby0);
  15529. codeblock.tbx1_ = Math.min(subband.tbx1, codeblock.tbx1);
  15530. codeblock.tby1_ = Math.min(subband.tby1, codeblock.tby1);
  15531. var pi = Math.floor((codeblock.tbx0_ - subband.tbx0) / precinctParameters.precinctWidthInSubband);
  15532. var pj = Math.floor((codeblock.tby0_ - subband.tby0) / precinctParameters.precinctHeightInSubband);
  15533. precinctNumber = pi + pj * precinctParameters.numprecinctswide;
  15534. codeblock.precinctNumber = precinctNumber;
  15535. codeblock.subbandType = subband.type;
  15536. codeblock.Lblock = 3;
  15537. if (codeblock.tbx1_ <= codeblock.tbx0_ || codeblock.tby1_ <= codeblock.tby0_) {
  15538. continue;
  15539. }
  15540. codeblocks.push(codeblock);
  15541. var precinct = precincts[precinctNumber];
  15542. if (precinct !== undefined) {
  15543. if (i < precinct.cbxMin) {
  15544. precinct.cbxMin = i;
  15545. } else if (i > precinct.cbxMax) {
  15546. precinct.cbxMax = i;
  15547. }
  15548. if (j < precinct.cbyMin) {
  15549. precinct.cbxMin = j;
  15550. } else if (j > precinct.cbyMax) {
  15551. precinct.cbyMax = j;
  15552. }
  15553. } else {
  15554. precincts[precinctNumber] = precinct = {
  15555. cbxMin: i,
  15556. cbyMin: j,
  15557. cbxMax: i,
  15558. cbyMax: j
  15559. };
  15560. }
  15561. codeblock.precinct = precinct;
  15562. }
  15563. }
  15564. subband.codeblockParameters = {
  15565. codeblockWidth: xcb_,
  15566. codeblockHeight: ycb_,
  15567. numcodeblockwide: cbx1 - cbx0 + 1,
  15568. numcodeblockhigh: cby1 - cby0 + 1
  15569. };
  15570. subband.codeblocks = codeblocks;
  15571. subband.precincts = precincts;
  15572. }
  15573. function createPacket(resolution, precinctNumber, layerNumber) {
  15574. var precinctCodeblocks = [];
  15575. var subbands = resolution.subbands;
  15576. for (var i = 0, ii = subbands.length; i < ii; i++) {
  15577. var subband = subbands[i];
  15578. var codeblocks = subband.codeblocks;
  15579. for (var j = 0, jj = codeblocks.length; j < jj; j++) {
  15580. var codeblock = codeblocks[j];
  15581. if (codeblock.precinctNumber !== precinctNumber) {
  15582. continue;
  15583. }
  15584. precinctCodeblocks.push(codeblock);
  15585. }
  15586. }
  15587. return {
  15588. layerNumber: layerNumber,
  15589. codeblocks: precinctCodeblocks
  15590. };
  15591. }
  15592. function LayerResolutionComponentPositionIterator(context) {
  15593. var siz = context.SIZ;
  15594. var tileIndex = context.currentTile.index;
  15595. var tile = context.tiles[tileIndex];
  15596. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15597. var componentsCount = siz.Csiz;
  15598. var maxDecompositionLevelsCount = 0;
  15599. for (var q = 0; q < componentsCount; q++) {
  15600. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15601. }
  15602. var l = 0, r = 0, i = 0, k = 0;
  15603. this.nextPacket = function JpxImage_nextPacket() {
  15604. for (; l < layersCount; l++) {
  15605. for (; r <= maxDecompositionLevelsCount; r++) {
  15606. for (; i < componentsCount; i++) {
  15607. var component = tile.components[i];
  15608. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15609. continue;
  15610. }
  15611. var resolution = component.resolutions[r];
  15612. var numprecincts = resolution.precinctParameters.numprecincts;
  15613. for (; k < numprecincts;) {
  15614. var packet = createPacket(resolution, k, l);
  15615. k++;
  15616. return packet;
  15617. }
  15618. k = 0;
  15619. }
  15620. i = 0;
  15621. }
  15622. r = 0;
  15623. }
  15624. error('JPX Error: Out of packets');
  15625. };
  15626. }
  15627. function ResolutionLayerComponentPositionIterator(context) {
  15628. var siz = context.SIZ;
  15629. var tileIndex = context.currentTile.index;
  15630. var tile = context.tiles[tileIndex];
  15631. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15632. var componentsCount = siz.Csiz;
  15633. var maxDecompositionLevelsCount = 0;
  15634. for (var q = 0; q < componentsCount; q++) {
  15635. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, tile.components[q].codingStyleParameters.decompositionLevelsCount);
  15636. }
  15637. var r = 0, l = 0, i = 0, k = 0;
  15638. this.nextPacket = function JpxImage_nextPacket() {
  15639. for (; r <= maxDecompositionLevelsCount; r++) {
  15640. for (; l < layersCount; l++) {
  15641. for (; i < componentsCount; i++) {
  15642. var component = tile.components[i];
  15643. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15644. continue;
  15645. }
  15646. var resolution = component.resolutions[r];
  15647. var numprecincts = resolution.precinctParameters.numprecincts;
  15648. for (; k < numprecincts;) {
  15649. var packet = createPacket(resolution, k, l);
  15650. k++;
  15651. return packet;
  15652. }
  15653. k = 0;
  15654. }
  15655. i = 0;
  15656. }
  15657. l = 0;
  15658. }
  15659. error('JPX Error: Out of packets');
  15660. };
  15661. }
  15662. function ResolutionPositionComponentLayerIterator(context) {
  15663. var siz = context.SIZ;
  15664. var tileIndex = context.currentTile.index;
  15665. var tile = context.tiles[tileIndex];
  15666. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15667. var componentsCount = siz.Csiz;
  15668. var l, r, c, p;
  15669. var maxDecompositionLevelsCount = 0;
  15670. for (c = 0; c < componentsCount; c++) {
  15671. var component = tile.components[c];
  15672. maxDecompositionLevelsCount = Math.max(maxDecompositionLevelsCount, component.codingStyleParameters.decompositionLevelsCount);
  15673. }
  15674. var maxNumPrecinctsInLevel = new Int32Array(maxDecompositionLevelsCount + 1);
  15675. for (r = 0; r <= maxDecompositionLevelsCount; ++r) {
  15676. var maxNumPrecincts = 0;
  15677. for (c = 0; c < componentsCount; ++c) {
  15678. var resolutions = tile.components[c].resolutions;
  15679. if (r < resolutions.length) {
  15680. maxNumPrecincts = Math.max(maxNumPrecincts, resolutions[r].precinctParameters.numprecincts);
  15681. }
  15682. }
  15683. maxNumPrecinctsInLevel[r] = maxNumPrecincts;
  15684. }
  15685. l = 0;
  15686. r = 0;
  15687. c = 0;
  15688. p = 0;
  15689. this.nextPacket = function JpxImage_nextPacket() {
  15690. for (; r <= maxDecompositionLevelsCount; r++) {
  15691. for (; p < maxNumPrecinctsInLevel[r]; p++) {
  15692. for (; c < componentsCount; c++) {
  15693. var component = tile.components[c];
  15694. if (r > component.codingStyleParameters.decompositionLevelsCount) {
  15695. continue;
  15696. }
  15697. var resolution = component.resolutions[r];
  15698. var numprecincts = resolution.precinctParameters.numprecincts;
  15699. if (p >= numprecincts) {
  15700. continue;
  15701. }
  15702. for (; l < layersCount;) {
  15703. var packet = createPacket(resolution, p, l);
  15704. l++;
  15705. return packet;
  15706. }
  15707. l = 0;
  15708. }
  15709. c = 0;
  15710. }
  15711. p = 0;
  15712. }
  15713. error('JPX Error: Out of packets');
  15714. };
  15715. }
  15716. function PositionComponentResolutionLayerIterator(context) {
  15717. var siz = context.SIZ;
  15718. var tileIndex = context.currentTile.index;
  15719. var tile = context.tiles[tileIndex];
  15720. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15721. var componentsCount = siz.Csiz;
  15722. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15723. var precinctsIterationSizes = precinctsSizes;
  15724. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15725. this.nextPacket = function JpxImage_nextPacket() {
  15726. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15727. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15728. for (; c < componentsCount; c++) {
  15729. var component = tile.components[c];
  15730. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15731. for (; r <= decompositionLevelsCount; r++) {
  15732. var resolution = component.resolutions[r];
  15733. var sizeInImageScale = precinctsSizes.components[c].resolutions[r];
  15734. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15735. if (k === null) {
  15736. continue;
  15737. }
  15738. for (; l < layersCount;) {
  15739. var packet = createPacket(resolution, k, l);
  15740. l++;
  15741. return packet;
  15742. }
  15743. l = 0;
  15744. }
  15745. r = 0;
  15746. }
  15747. c = 0;
  15748. }
  15749. px = 0;
  15750. }
  15751. error('JPX Error: Out of packets');
  15752. };
  15753. }
  15754. function ComponentPositionResolutionLayerIterator(context) {
  15755. var siz = context.SIZ;
  15756. var tileIndex = context.currentTile.index;
  15757. var tile = context.tiles[tileIndex];
  15758. var layersCount = tile.codingStyleDefaultParameters.layersCount;
  15759. var componentsCount = siz.Csiz;
  15760. var precinctsSizes = getPrecinctSizesInImageScale(tile);
  15761. var l = 0, r = 0, c = 0, px = 0, py = 0;
  15762. this.nextPacket = function JpxImage_nextPacket() {
  15763. for (; c < componentsCount; ++c) {
  15764. var component = tile.components[c];
  15765. var precinctsIterationSizes = precinctsSizes.components[c];
  15766. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15767. for (; py < precinctsIterationSizes.maxNumHigh; py++) {
  15768. for (; px < precinctsIterationSizes.maxNumWide; px++) {
  15769. for (; r <= decompositionLevelsCount; r++) {
  15770. var resolution = component.resolutions[r];
  15771. var sizeInImageScale = precinctsIterationSizes.resolutions[r];
  15772. var k = getPrecinctIndexIfExist(px, py, sizeInImageScale, precinctsIterationSizes, resolution);
  15773. if (k === null) {
  15774. continue;
  15775. }
  15776. for (; l < layersCount;) {
  15777. var packet = createPacket(resolution, k, l);
  15778. l++;
  15779. return packet;
  15780. }
  15781. l = 0;
  15782. }
  15783. r = 0;
  15784. }
  15785. px = 0;
  15786. }
  15787. py = 0;
  15788. }
  15789. error('JPX Error: Out of packets');
  15790. };
  15791. }
  15792. function getPrecinctIndexIfExist(pxIndex, pyIndex, sizeInImageScale, precinctIterationSizes, resolution) {
  15793. var posX = pxIndex * precinctIterationSizes.minWidth;
  15794. var posY = pyIndex * precinctIterationSizes.minHeight;
  15795. if (posX % sizeInImageScale.width !== 0 || posY % sizeInImageScale.height !== 0) {
  15796. return null;
  15797. }
  15798. var startPrecinctRowIndex = posY / sizeInImageScale.width * resolution.precinctParameters.numprecinctswide;
  15799. return posX / sizeInImageScale.height + startPrecinctRowIndex;
  15800. }
  15801. function getPrecinctSizesInImageScale(tile) {
  15802. var componentsCount = tile.components.length;
  15803. var minWidth = Number.MAX_VALUE;
  15804. var minHeight = Number.MAX_VALUE;
  15805. var maxNumWide = 0;
  15806. var maxNumHigh = 0;
  15807. var sizePerComponent = new Array(componentsCount);
  15808. for (var c = 0; c < componentsCount; c++) {
  15809. var component = tile.components[c];
  15810. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15811. var sizePerResolution = new Array(decompositionLevelsCount + 1);
  15812. var minWidthCurrentComponent = Number.MAX_VALUE;
  15813. var minHeightCurrentComponent = Number.MAX_VALUE;
  15814. var maxNumWideCurrentComponent = 0;
  15815. var maxNumHighCurrentComponent = 0;
  15816. var scale = 1;
  15817. for (var r = decompositionLevelsCount; r >= 0; --r) {
  15818. var resolution = component.resolutions[r];
  15819. var widthCurrentResolution = scale * resolution.precinctParameters.precinctWidth;
  15820. var heightCurrentResolution = scale * resolution.precinctParameters.precinctHeight;
  15821. minWidthCurrentComponent = Math.min(minWidthCurrentComponent, widthCurrentResolution);
  15822. minHeightCurrentComponent = Math.min(minHeightCurrentComponent, heightCurrentResolution);
  15823. maxNumWideCurrentComponent = Math.max(maxNumWideCurrentComponent, resolution.precinctParameters.numprecinctswide);
  15824. maxNumHighCurrentComponent = Math.max(maxNumHighCurrentComponent, resolution.precinctParameters.numprecinctshigh);
  15825. sizePerResolution[r] = {
  15826. width: widthCurrentResolution,
  15827. height: heightCurrentResolution
  15828. };
  15829. scale <<= 1;
  15830. }
  15831. minWidth = Math.min(minWidth, minWidthCurrentComponent);
  15832. minHeight = Math.min(minHeight, minHeightCurrentComponent);
  15833. maxNumWide = Math.max(maxNumWide, maxNumWideCurrentComponent);
  15834. maxNumHigh = Math.max(maxNumHigh, maxNumHighCurrentComponent);
  15835. sizePerComponent[c] = {
  15836. resolutions: sizePerResolution,
  15837. minWidth: minWidthCurrentComponent,
  15838. minHeight: minHeightCurrentComponent,
  15839. maxNumWide: maxNumWideCurrentComponent,
  15840. maxNumHigh: maxNumHighCurrentComponent
  15841. };
  15842. }
  15843. return {
  15844. components: sizePerComponent,
  15845. minWidth: minWidth,
  15846. minHeight: minHeight,
  15847. maxNumWide: maxNumWide,
  15848. maxNumHigh: maxNumHigh
  15849. };
  15850. }
  15851. function buildPackets(context) {
  15852. var siz = context.SIZ;
  15853. var tileIndex = context.currentTile.index;
  15854. var tile = context.tiles[tileIndex];
  15855. var componentsCount = siz.Csiz;
  15856. for (var c = 0; c < componentsCount; c++) {
  15857. var component = tile.components[c];
  15858. var decompositionLevelsCount = component.codingStyleParameters.decompositionLevelsCount;
  15859. var resolutions = [];
  15860. var subbands = [];
  15861. for (var r = 0; r <= decompositionLevelsCount; r++) {
  15862. var blocksDimensions = getBlocksDimensions(context, component, r);
  15863. var resolution = {};
  15864. var scale = 1 << decompositionLevelsCount - r;
  15865. resolution.trx0 = Math.ceil(component.tcx0 / scale);
  15866. resolution.try0 = Math.ceil(component.tcy0 / scale);
  15867. resolution.trx1 = Math.ceil(component.tcx1 / scale);
  15868. resolution.try1 = Math.ceil(component.tcy1 / scale);
  15869. resolution.resLevel = r;
  15870. buildPrecincts(context, resolution, blocksDimensions);
  15871. resolutions.push(resolution);
  15872. var subband;
  15873. if (r === 0) {
  15874. subband = {};
  15875. subband.type = 'LL';
  15876. subband.tbx0 = Math.ceil(component.tcx0 / scale);
  15877. subband.tby0 = Math.ceil(component.tcy0 / scale);
  15878. subband.tbx1 = Math.ceil(component.tcx1 / scale);
  15879. subband.tby1 = Math.ceil(component.tcy1 / scale);
  15880. subband.resolution = resolution;
  15881. buildCodeblocks(context, subband, blocksDimensions);
  15882. subbands.push(subband);
  15883. resolution.subbands = [subband];
  15884. } else {
  15885. var bscale = 1 << decompositionLevelsCount - r + 1;
  15886. var resolutionSubbands = [];
  15887. subband = {};
  15888. subband.type = 'HL';
  15889. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15890. subband.tby0 = Math.ceil(component.tcy0 / bscale);
  15891. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  15892. subband.tby1 = Math.ceil(component.tcy1 / bscale);
  15893. subband.resolution = resolution;
  15894. buildCodeblocks(context, subband, blocksDimensions);
  15895. subbands.push(subband);
  15896. resolutionSubbands.push(subband);
  15897. subband = {};
  15898. subband.type = 'LH';
  15899. subband.tbx0 = Math.ceil(component.tcx0 / bscale);
  15900. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  15901. subband.tbx1 = Math.ceil(component.tcx1 / bscale);
  15902. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  15903. subband.resolution = resolution;
  15904. buildCodeblocks(context, subband, blocksDimensions);
  15905. subbands.push(subband);
  15906. resolutionSubbands.push(subband);
  15907. subband = {};
  15908. subband.type = 'HH';
  15909. subband.tbx0 = Math.ceil(component.tcx0 / bscale - 0.5);
  15910. subband.tby0 = Math.ceil(component.tcy0 / bscale - 0.5);
  15911. subband.tbx1 = Math.ceil(component.tcx1 / bscale - 0.5);
  15912. subband.tby1 = Math.ceil(component.tcy1 / bscale - 0.5);
  15913. subband.resolution = resolution;
  15914. buildCodeblocks(context, subband, blocksDimensions);
  15915. subbands.push(subband);
  15916. resolutionSubbands.push(subband);
  15917. resolution.subbands = resolutionSubbands;
  15918. }
  15919. }
  15920. component.resolutions = resolutions;
  15921. component.subbands = subbands;
  15922. }
  15923. var progressionOrder = tile.codingStyleDefaultParameters.progressionOrder;
  15924. switch (progressionOrder) {
  15925. case 0:
  15926. tile.packetsIterator = new LayerResolutionComponentPositionIterator(context);
  15927. break;
  15928. case 1:
  15929. tile.packetsIterator = new ResolutionLayerComponentPositionIterator(context);
  15930. break;
  15931. case 2:
  15932. tile.packetsIterator = new ResolutionPositionComponentLayerIterator(context);
  15933. break;
  15934. case 3:
  15935. tile.packetsIterator = new PositionComponentResolutionLayerIterator(context);
  15936. break;
  15937. case 4:
  15938. tile.packetsIterator = new ComponentPositionResolutionLayerIterator(context);
  15939. break;
  15940. default:
  15941. error('JPX Error: Unsupported progression order ' + progressionOrder);
  15942. }
  15943. }
  15944. function parseTilePackets(context, data, offset, dataLength) {
  15945. var position = 0;
  15946. var buffer, bufferSize = 0, skipNextBit = false;
  15947. function readBits(count) {
  15948. while (bufferSize < count) {
  15949. var b = data[offset + position];
  15950. position++;
  15951. if (skipNextBit) {
  15952. buffer = buffer << 7 | b;
  15953. bufferSize += 7;
  15954. skipNextBit = false;
  15955. } else {
  15956. buffer = buffer << 8 | b;
  15957. bufferSize += 8;
  15958. }
  15959. if (b === 0xFF) {
  15960. skipNextBit = true;
  15961. }
  15962. }
  15963. bufferSize -= count;
  15964. return buffer >>> bufferSize & (1 << count) - 1;
  15965. }
  15966. function skipMarkerIfEqual(value) {
  15967. if (data[offset + position - 1] === 0xFF && data[offset + position] === value) {
  15968. skipBytes(1);
  15969. return true;
  15970. } else if (data[offset + position] === 0xFF && data[offset + position + 1] === value) {
  15971. skipBytes(2);
  15972. return true;
  15973. }
  15974. return false;
  15975. }
  15976. function skipBytes(count) {
  15977. position += count;
  15978. }
  15979. function alignToByte() {
  15980. bufferSize = 0;
  15981. if (skipNextBit) {
  15982. position++;
  15983. skipNextBit = false;
  15984. }
  15985. }
  15986. function readCodingpasses() {
  15987. if (readBits(1) === 0) {
  15988. return 1;
  15989. }
  15990. if (readBits(1) === 0) {
  15991. return 2;
  15992. }
  15993. var value = readBits(2);
  15994. if (value < 3) {
  15995. return value + 3;
  15996. }
  15997. value = readBits(5);
  15998. if (value < 31) {
  15999. return value + 6;
  16000. }
  16001. value = readBits(7);
  16002. return value + 37;
  16003. }
  16004. var tileIndex = context.currentTile.index;
  16005. var tile = context.tiles[tileIndex];
  16006. var sopMarkerUsed = context.COD.sopMarkerUsed;
  16007. var ephMarkerUsed = context.COD.ephMarkerUsed;
  16008. var packetsIterator = tile.packetsIterator;
  16009. while (position < dataLength) {
  16010. alignToByte();
  16011. if (sopMarkerUsed && skipMarkerIfEqual(0x91)) {
  16012. skipBytes(4);
  16013. }
  16014. var packet = packetsIterator.nextPacket();
  16015. if (!readBits(1)) {
  16016. continue;
  16017. }
  16018. var layerNumber = packet.layerNumber;
  16019. var queue = [], codeblock;
  16020. for (var i = 0, ii = packet.codeblocks.length; i < ii; i++) {
  16021. codeblock = packet.codeblocks[i];
  16022. var precinct = codeblock.precinct;
  16023. var codeblockColumn = codeblock.cbx - precinct.cbxMin;
  16024. var codeblockRow = codeblock.cby - precinct.cbyMin;
  16025. var codeblockIncluded = false;
  16026. var firstTimeInclusion = false;
  16027. var valueReady;
  16028. if (codeblock['included'] !== undefined) {
  16029. codeblockIncluded = !!readBits(1);
  16030. } else {
  16031. precinct = codeblock.precinct;
  16032. var inclusionTree, zeroBitPlanesTree;
  16033. if (precinct['inclusionTree'] !== undefined) {
  16034. inclusionTree = precinct.inclusionTree;
  16035. } else {
  16036. var width = precinct.cbxMax - precinct.cbxMin + 1;
  16037. var height = precinct.cbyMax - precinct.cbyMin + 1;
  16038. inclusionTree = new InclusionTree(width, height, layerNumber);
  16039. zeroBitPlanesTree = new TagTree(width, height);
  16040. precinct.inclusionTree = inclusionTree;
  16041. precinct.zeroBitPlanesTree = zeroBitPlanesTree;
  16042. }
  16043. if (inclusionTree.reset(codeblockColumn, codeblockRow, layerNumber)) {
  16044. while (true) {
  16045. if (readBits(1)) {
  16046. valueReady = !inclusionTree.nextLevel();
  16047. if (valueReady) {
  16048. codeblock.included = true;
  16049. codeblockIncluded = firstTimeInclusion = true;
  16050. break;
  16051. }
  16052. } else {
  16053. inclusionTree.incrementValue(layerNumber);
  16054. break;
  16055. }
  16056. }
  16057. }
  16058. }
  16059. if (!codeblockIncluded) {
  16060. continue;
  16061. }
  16062. if (firstTimeInclusion) {
  16063. zeroBitPlanesTree = precinct.zeroBitPlanesTree;
  16064. zeroBitPlanesTree.reset(codeblockColumn, codeblockRow);
  16065. while (true) {
  16066. if (readBits(1)) {
  16067. valueReady = !zeroBitPlanesTree.nextLevel();
  16068. if (valueReady) {
  16069. break;
  16070. }
  16071. } else {
  16072. zeroBitPlanesTree.incrementValue();
  16073. }
  16074. }
  16075. codeblock.zeroBitPlanes = zeroBitPlanesTree.value;
  16076. }
  16077. var codingpasses = readCodingpasses();
  16078. while (readBits(1)) {
  16079. codeblock.Lblock++;
  16080. }
  16081. var codingpassesLog2 = log2(codingpasses);
  16082. var bits = (codingpasses < 1 << codingpassesLog2 ? codingpassesLog2 - 1 : codingpassesLog2) + codeblock.Lblock;
  16083. var codedDataLength = readBits(bits);
  16084. queue.push({
  16085. codeblock: codeblock,
  16086. codingpasses: codingpasses,
  16087. dataLength: codedDataLength
  16088. });
  16089. }
  16090. alignToByte();
  16091. if (ephMarkerUsed) {
  16092. skipMarkerIfEqual(0x92);
  16093. }
  16094. while (queue.length > 0) {
  16095. var packetItem = queue.shift();
  16096. codeblock = packetItem.codeblock;
  16097. if (codeblock['data'] === undefined) {
  16098. codeblock.data = [];
  16099. }
  16100. codeblock.data.push({
  16101. data: data,
  16102. start: offset + position,
  16103. end: offset + position + packetItem.dataLength,
  16104. codingpasses: packetItem.codingpasses
  16105. });
  16106. position += packetItem.dataLength;
  16107. }
  16108. }
  16109. return position;
  16110. }
  16111. function copyCoefficients(coefficients, levelWidth, levelHeight, subband, delta, mb, reversible, segmentationSymbolUsed) {
  16112. var x0 = subband.tbx0;
  16113. var y0 = subband.tby0;
  16114. var width = subband.tbx1 - subband.tbx0;
  16115. var codeblocks = subband.codeblocks;
  16116. var right = subband.type.charAt(0) === 'H' ? 1 : 0;
  16117. var bottom = subband.type.charAt(1) === 'H' ? levelWidth : 0;
  16118. for (var i = 0, ii = codeblocks.length; i < ii; ++i) {
  16119. var codeblock = codeblocks[i];
  16120. var blockWidth = codeblock.tbx1_ - codeblock.tbx0_;
  16121. var blockHeight = codeblock.tby1_ - codeblock.tby0_;
  16122. if (blockWidth === 0 || blockHeight === 0) {
  16123. continue;
  16124. }
  16125. if (codeblock['data'] === undefined) {
  16126. continue;
  16127. }
  16128. var bitModel, currentCodingpassType;
  16129. bitModel = new BitModel(blockWidth, blockHeight, codeblock.subbandType, codeblock.zeroBitPlanes, mb);
  16130. currentCodingpassType = 2;
  16131. var data = codeblock.data, totalLength = 0, codingpasses = 0;
  16132. var j, jj, dataItem;
  16133. for (j = 0, jj = data.length; j < jj; j++) {
  16134. dataItem = data[j];
  16135. totalLength += dataItem.end - dataItem.start;
  16136. codingpasses += dataItem.codingpasses;
  16137. }
  16138. var encodedData = new Uint8Array(totalLength);
  16139. var position = 0;
  16140. for (j = 0, jj = data.length; j < jj; j++) {
  16141. dataItem = data[j];
  16142. var chunk = dataItem.data.subarray(dataItem.start, dataItem.end);
  16143. encodedData.set(chunk, position);
  16144. position += chunk.length;
  16145. }
  16146. var decoder = new ArithmeticDecoder(encodedData, 0, totalLength);
  16147. bitModel.setDecoder(decoder);
  16148. for (j = 0; j < codingpasses; j++) {
  16149. switch (currentCodingpassType) {
  16150. case 0:
  16151. bitModel.runSignificancePropagationPass();
  16152. break;
  16153. case 1:
  16154. bitModel.runMagnitudeRefinementPass();
  16155. break;
  16156. case 2:
  16157. bitModel.runCleanupPass();
  16158. if (segmentationSymbolUsed) {
  16159. bitModel.checkSegmentationSymbol();
  16160. }
  16161. break;
  16162. }
  16163. currentCodingpassType = (currentCodingpassType + 1) % 3;
  16164. }
  16165. var offset = codeblock.tbx0_ - x0 + (codeblock.tby0_ - y0) * width;
  16166. var sign = bitModel.coefficentsSign;
  16167. var magnitude = bitModel.coefficentsMagnitude;
  16168. var bitsDecoded = bitModel.bitsDecoded;
  16169. var magnitudeCorrection = reversible ? 0 : 0.5;
  16170. var k, n, nb;
  16171. position = 0;
  16172. var interleave = subband.type !== 'LL';
  16173. for (j = 0; j < blockHeight; j++) {
  16174. var row = offset / width | 0;
  16175. var levelOffset = 2 * row * (levelWidth - width) + right + bottom;
  16176. for (k = 0; k < blockWidth; k++) {
  16177. n = magnitude[position];
  16178. if (n !== 0) {
  16179. n = (n + magnitudeCorrection) * delta;
  16180. if (sign[position] !== 0) {
  16181. n = -n;
  16182. }
  16183. nb = bitsDecoded[position];
  16184. var pos = interleave ? levelOffset + (offset << 1) : offset;
  16185. if (reversible && nb >= mb) {
  16186. coefficients[pos] = n;
  16187. } else {
  16188. coefficients[pos] = n * (1 << mb - nb);
  16189. }
  16190. }
  16191. offset++;
  16192. position++;
  16193. }
  16194. offset += width - blockWidth;
  16195. }
  16196. }
  16197. }
  16198. function transformTile(context, tile, c) {
  16199. var component = tile.components[c];
  16200. var codingStyleParameters = component.codingStyleParameters;
  16201. var quantizationParameters = component.quantizationParameters;
  16202. var decompositionLevelsCount = codingStyleParameters.decompositionLevelsCount;
  16203. var spqcds = quantizationParameters.SPqcds;
  16204. var scalarExpounded = quantizationParameters.scalarExpounded;
  16205. var guardBits = quantizationParameters.guardBits;
  16206. var segmentationSymbolUsed = codingStyleParameters.segmentationSymbolUsed;
  16207. var precision = context.components[c].precision;
  16208. var reversible = codingStyleParameters.reversibleTransformation;
  16209. var transform = reversible ? new ReversibleTransform() : new IrreversibleTransform();
  16210. var subbandCoefficients = [];
  16211. var b = 0;
  16212. for (var i = 0; i <= decompositionLevelsCount; i++) {
  16213. var resolution = component.resolutions[i];
  16214. var width = resolution.trx1 - resolution.trx0;
  16215. var height = resolution.try1 - resolution.try0;
  16216. var coefficients = new Float32Array(width * height);
  16217. for (var j = 0, jj = resolution.subbands.length; j < jj; j++) {
  16218. var mu, epsilon;
  16219. if (!scalarExpounded) {
  16220. mu = spqcds[0].mu;
  16221. epsilon = spqcds[0].epsilon + (i > 0 ? 1 - i : 0);
  16222. } else {
  16223. mu = spqcds[b].mu;
  16224. epsilon = spqcds[b].epsilon;
  16225. b++;
  16226. }
  16227. var subband = resolution.subbands[j];
  16228. var gainLog2 = SubbandsGainLog2[subband.type];
  16229. var delta = reversible ? 1 : Math.pow(2, precision + gainLog2 - epsilon) * (1 + mu / 2048);
  16230. var mb = guardBits + epsilon - 1;
  16231. copyCoefficients(coefficients, width, height, subband, delta, mb, reversible, segmentationSymbolUsed);
  16232. }
  16233. subbandCoefficients.push({
  16234. width: width,
  16235. height: height,
  16236. items: coefficients
  16237. });
  16238. }
  16239. var result = transform.calculate(subbandCoefficients, component.tcx0, component.tcy0);
  16240. return {
  16241. left: component.tcx0,
  16242. top: component.tcy0,
  16243. width: result.width,
  16244. height: result.height,
  16245. items: result.items
  16246. };
  16247. }
  16248. function transformComponents(context) {
  16249. var siz = context.SIZ;
  16250. var components = context.components;
  16251. var componentsCount = siz.Csiz;
  16252. var resultImages = [];
  16253. for (var i = 0, ii = context.tiles.length; i < ii; i++) {
  16254. var tile = context.tiles[i];
  16255. var transformedTiles = [];
  16256. var c;
  16257. for (c = 0; c < componentsCount; c++) {
  16258. transformedTiles[c] = transformTile(context, tile, c);
  16259. }
  16260. var tile0 = transformedTiles[0];
  16261. var out = new Uint8Array(tile0.items.length * componentsCount);
  16262. var result = {
  16263. left: tile0.left,
  16264. top: tile0.top,
  16265. width: tile0.width,
  16266. height: tile0.height,
  16267. items: out
  16268. };
  16269. var shift, offset, max, min, maxK;
  16270. var pos = 0, j, jj, y0, y1, y2, r, g, b, k, val;
  16271. if (tile.codingStyleDefaultParameters.multipleComponentTransform) {
  16272. var fourComponents = componentsCount === 4;
  16273. var y0items = transformedTiles[0].items;
  16274. var y1items = transformedTiles[1].items;
  16275. var y2items = transformedTiles[2].items;
  16276. var y3items = fourComponents ? transformedTiles[3].items : null;
  16277. shift = components[0].precision - 8;
  16278. offset = (128 << shift) + 0.5;
  16279. max = 255 * (1 << shift);
  16280. maxK = max * 0.5;
  16281. min = -maxK;
  16282. var component0 = tile.components[0];
  16283. var alpha01 = componentsCount - 3;
  16284. jj = y0items.length;
  16285. if (!component0.codingStyleParameters.reversibleTransformation) {
  16286. for (j = 0; j < jj; j++, pos += alpha01) {
  16287. y0 = y0items[j] + offset;
  16288. y1 = y1items[j];
  16289. y2 = y2items[j];
  16290. r = y0 + 1.402 * y2;
  16291. g = y0 - 0.34413 * y1 - 0.71414 * y2;
  16292. b = y0 + 1.772 * y1;
  16293. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16294. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16295. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16296. }
  16297. } else {
  16298. for (j = 0; j < jj; j++, pos += alpha01) {
  16299. y0 = y0items[j] + offset;
  16300. y1 = y1items[j];
  16301. y2 = y2items[j];
  16302. g = y0 - (y2 + y1 >> 2);
  16303. r = g + y2;
  16304. b = g + y1;
  16305. out[pos++] = r <= 0 ? 0 : r >= max ? 255 : r >> shift;
  16306. out[pos++] = g <= 0 ? 0 : g >= max ? 255 : g >> shift;
  16307. out[pos++] = b <= 0 ? 0 : b >= max ? 255 : b >> shift;
  16308. }
  16309. }
  16310. if (fourComponents) {
  16311. for (j = 0, pos = 3; j < jj; j++, pos += 4) {
  16312. k = y3items[j];
  16313. out[pos] = k <= min ? 0 : k >= maxK ? 255 : k + offset >> shift;
  16314. }
  16315. }
  16316. } else {
  16317. for (c = 0; c < componentsCount; c++) {
  16318. var items = transformedTiles[c].items;
  16319. shift = components[c].precision - 8;
  16320. offset = (128 << shift) + 0.5;
  16321. max = 127.5 * (1 << shift);
  16322. min = -max;
  16323. for (pos = c, j = 0, jj = items.length; j < jj; j++) {
  16324. val = items[j];
  16325. out[pos] = val <= min ? 0 : val >= max ? 255 : val + offset >> shift;
  16326. pos += componentsCount;
  16327. }
  16328. }
  16329. }
  16330. resultImages.push(result);
  16331. }
  16332. return resultImages;
  16333. }
  16334. function initializeTile(context, tileIndex) {
  16335. var siz = context.SIZ;
  16336. var componentsCount = siz.Csiz;
  16337. var tile = context.tiles[tileIndex];
  16338. for (var c = 0; c < componentsCount; c++) {
  16339. var component = tile.components[c];
  16340. var qcdOrQcc = context.currentTile.QCC[c] !== undefined ? context.currentTile.QCC[c] : context.currentTile.QCD;
  16341. component.quantizationParameters = qcdOrQcc;
  16342. var codOrCoc = context.currentTile.COC[c] !== undefined ? context.currentTile.COC[c] : context.currentTile.COD;
  16343. component.codingStyleParameters = codOrCoc;
  16344. }
  16345. tile.codingStyleDefaultParameters = context.currentTile.COD;
  16346. }
  16347. var TagTree = function TagTreeClosure() {
  16348. function TagTree(width, height) {
  16349. var levelsLength = log2(Math.max(width, height)) + 1;
  16350. this.levels = [];
  16351. for (var i = 0; i < levelsLength; i++) {
  16352. var level = {
  16353. width: width,
  16354. height: height,
  16355. items: []
  16356. };
  16357. this.levels.push(level);
  16358. width = Math.ceil(width / 2);
  16359. height = Math.ceil(height / 2);
  16360. }
  16361. }
  16362. TagTree.prototype = {
  16363. reset: function TagTree_reset(i, j) {
  16364. var currentLevel = 0, value = 0, level;
  16365. while (currentLevel < this.levels.length) {
  16366. level = this.levels[currentLevel];
  16367. var index = i + j * level.width;
  16368. if (level.items[index] !== undefined) {
  16369. value = level.items[index];
  16370. break;
  16371. }
  16372. level.index = index;
  16373. i >>= 1;
  16374. j >>= 1;
  16375. currentLevel++;
  16376. }
  16377. currentLevel--;
  16378. level = this.levels[currentLevel];
  16379. level.items[level.index] = value;
  16380. this.currentLevel = currentLevel;
  16381. delete this.value;
  16382. },
  16383. incrementValue: function TagTree_incrementValue() {
  16384. var level = this.levels[this.currentLevel];
  16385. level.items[level.index]++;
  16386. },
  16387. nextLevel: function TagTree_nextLevel() {
  16388. var currentLevel = this.currentLevel;
  16389. var level = this.levels[currentLevel];
  16390. var value = level.items[level.index];
  16391. currentLevel--;
  16392. if (currentLevel < 0) {
  16393. this.value = value;
  16394. return false;
  16395. }
  16396. this.currentLevel = currentLevel;
  16397. level = this.levels[currentLevel];
  16398. level.items[level.index] = value;
  16399. return true;
  16400. }
  16401. };
  16402. return TagTree;
  16403. }();
  16404. var InclusionTree = function InclusionTreeClosure() {
  16405. function InclusionTree(width, height, defaultValue) {
  16406. var levelsLength = log2(Math.max(width, height)) + 1;
  16407. this.levels = [];
  16408. for (var i = 0; i < levelsLength; i++) {
  16409. var items = new Uint8Array(width * height);
  16410. for (var j = 0, jj = items.length; j < jj; j++) {
  16411. items[j] = defaultValue;
  16412. }
  16413. var level = {
  16414. width: width,
  16415. height: height,
  16416. items: items
  16417. };
  16418. this.levels.push(level);
  16419. width = Math.ceil(width / 2);
  16420. height = Math.ceil(height / 2);
  16421. }
  16422. }
  16423. InclusionTree.prototype = {
  16424. reset: function InclusionTree_reset(i, j, stopValue) {
  16425. var currentLevel = 0;
  16426. while (currentLevel < this.levels.length) {
  16427. var level = this.levels[currentLevel];
  16428. var index = i + j * level.width;
  16429. level.index = index;
  16430. var value = level.items[index];
  16431. if (value === 0xFF) {
  16432. break;
  16433. }
  16434. if (value > stopValue) {
  16435. this.currentLevel = currentLevel;
  16436. this.propagateValues();
  16437. return false;
  16438. }
  16439. i >>= 1;
  16440. j >>= 1;
  16441. currentLevel++;
  16442. }
  16443. this.currentLevel = currentLevel - 1;
  16444. return true;
  16445. },
  16446. incrementValue: function InclusionTree_incrementValue(stopValue) {
  16447. var level = this.levels[this.currentLevel];
  16448. level.items[level.index] = stopValue + 1;
  16449. this.propagateValues();
  16450. },
  16451. propagateValues: function InclusionTree_propagateValues() {
  16452. var levelIndex = this.currentLevel;
  16453. var level = this.levels[levelIndex];
  16454. var currentValue = level.items[level.index];
  16455. while (--levelIndex >= 0) {
  16456. level = this.levels[levelIndex];
  16457. level.items[level.index] = currentValue;
  16458. }
  16459. },
  16460. nextLevel: function InclusionTree_nextLevel() {
  16461. var currentLevel = this.currentLevel;
  16462. var level = this.levels[currentLevel];
  16463. var value = level.items[level.index];
  16464. level.items[level.index] = 0xFF;
  16465. currentLevel--;
  16466. if (currentLevel < 0) {
  16467. return false;
  16468. }
  16469. this.currentLevel = currentLevel;
  16470. level = this.levels[currentLevel];
  16471. level.items[level.index] = value;
  16472. return true;
  16473. }
  16474. };
  16475. return InclusionTree;
  16476. }();
  16477. var BitModel = function BitModelClosure() {
  16478. var UNIFORM_CONTEXT = 17;
  16479. var RUNLENGTH_CONTEXT = 18;
  16480. var LLAndLHContextsLabel = new Uint8Array([
  16481. 0,
  16482. 5,
  16483. 8,
  16484. 0,
  16485. 3,
  16486. 7,
  16487. 8,
  16488. 0,
  16489. 4,
  16490. 7,
  16491. 8,
  16492. 0,
  16493. 0,
  16494. 0,
  16495. 0,
  16496. 0,
  16497. 1,
  16498. 6,
  16499. 8,
  16500. 0,
  16501. 3,
  16502. 7,
  16503. 8,
  16504. 0,
  16505. 4,
  16506. 7,
  16507. 8,
  16508. 0,
  16509. 0,
  16510. 0,
  16511. 0,
  16512. 0,
  16513. 2,
  16514. 6,
  16515. 8,
  16516. 0,
  16517. 3,
  16518. 7,
  16519. 8,
  16520. 0,
  16521. 4,
  16522. 7,
  16523. 8,
  16524. 0,
  16525. 0,
  16526. 0,
  16527. 0,
  16528. 0,
  16529. 2,
  16530. 6,
  16531. 8,
  16532. 0,
  16533. 3,
  16534. 7,
  16535. 8,
  16536. 0,
  16537. 4,
  16538. 7,
  16539. 8,
  16540. 0,
  16541. 0,
  16542. 0,
  16543. 0,
  16544. 0,
  16545. 2,
  16546. 6,
  16547. 8,
  16548. 0,
  16549. 3,
  16550. 7,
  16551. 8,
  16552. 0,
  16553. 4,
  16554. 7,
  16555. 8
  16556. ]);
  16557. var HLContextLabel = new Uint8Array([
  16558. 0,
  16559. 3,
  16560. 4,
  16561. 0,
  16562. 5,
  16563. 7,
  16564. 7,
  16565. 0,
  16566. 8,
  16567. 8,
  16568. 8,
  16569. 0,
  16570. 0,
  16571. 0,
  16572. 0,
  16573. 0,
  16574. 1,
  16575. 3,
  16576. 4,
  16577. 0,
  16578. 6,
  16579. 7,
  16580. 7,
  16581. 0,
  16582. 8,
  16583. 8,
  16584. 8,
  16585. 0,
  16586. 0,
  16587. 0,
  16588. 0,
  16589. 0,
  16590. 2,
  16591. 3,
  16592. 4,
  16593. 0,
  16594. 6,
  16595. 7,
  16596. 7,
  16597. 0,
  16598. 8,
  16599. 8,
  16600. 8,
  16601. 0,
  16602. 0,
  16603. 0,
  16604. 0,
  16605. 0,
  16606. 2,
  16607. 3,
  16608. 4,
  16609. 0,
  16610. 6,
  16611. 7,
  16612. 7,
  16613. 0,
  16614. 8,
  16615. 8,
  16616. 8,
  16617. 0,
  16618. 0,
  16619. 0,
  16620. 0,
  16621. 0,
  16622. 2,
  16623. 3,
  16624. 4,
  16625. 0,
  16626. 6,
  16627. 7,
  16628. 7,
  16629. 0,
  16630. 8,
  16631. 8,
  16632. 8
  16633. ]);
  16634. var HHContextLabel = new Uint8Array([
  16635. 0,
  16636. 1,
  16637. 2,
  16638. 0,
  16639. 1,
  16640. 2,
  16641. 2,
  16642. 0,
  16643. 2,
  16644. 2,
  16645. 2,
  16646. 0,
  16647. 0,
  16648. 0,
  16649. 0,
  16650. 0,
  16651. 3,
  16652. 4,
  16653. 5,
  16654. 0,
  16655. 4,
  16656. 5,
  16657. 5,
  16658. 0,
  16659. 5,
  16660. 5,
  16661. 5,
  16662. 0,
  16663. 0,
  16664. 0,
  16665. 0,
  16666. 0,
  16667. 6,
  16668. 7,
  16669. 7,
  16670. 0,
  16671. 7,
  16672. 7,
  16673. 7,
  16674. 0,
  16675. 7,
  16676. 7,
  16677. 7,
  16678. 0,
  16679. 0,
  16680. 0,
  16681. 0,
  16682. 0,
  16683. 8,
  16684. 8,
  16685. 8,
  16686. 0,
  16687. 8,
  16688. 8,
  16689. 8,
  16690. 0,
  16691. 8,
  16692. 8,
  16693. 8,
  16694. 0,
  16695. 0,
  16696. 0,
  16697. 0,
  16698. 0,
  16699. 8,
  16700. 8,
  16701. 8,
  16702. 0,
  16703. 8,
  16704. 8,
  16705. 8,
  16706. 0,
  16707. 8,
  16708. 8,
  16709. 8
  16710. ]);
  16711. function BitModel(width, height, subband, zeroBitPlanes, mb) {
  16712. this.width = width;
  16713. this.height = height;
  16714. this.contextLabelTable = subband === 'HH' ? HHContextLabel : subband === 'HL' ? HLContextLabel : LLAndLHContextsLabel;
  16715. var coefficientCount = width * height;
  16716. this.neighborsSignificance = new Uint8Array(coefficientCount);
  16717. this.coefficentsSign = new Uint8Array(coefficientCount);
  16718. this.coefficentsMagnitude = mb > 14 ? new Uint32Array(coefficientCount) : mb > 6 ? new Uint16Array(coefficientCount) : new Uint8Array(coefficientCount);
  16719. this.processingFlags = new Uint8Array(coefficientCount);
  16720. var bitsDecoded = new Uint8Array(coefficientCount);
  16721. if (zeroBitPlanes !== 0) {
  16722. for (var i = 0; i < coefficientCount; i++) {
  16723. bitsDecoded[i] = zeroBitPlanes;
  16724. }
  16725. }
  16726. this.bitsDecoded = bitsDecoded;
  16727. this.reset();
  16728. }
  16729. BitModel.prototype = {
  16730. setDecoder: function BitModel_setDecoder(decoder) {
  16731. this.decoder = decoder;
  16732. },
  16733. reset: function BitModel_reset() {
  16734. this.contexts = new Int8Array(19);
  16735. this.contexts[0] = 4 << 1 | 0;
  16736. this.contexts[UNIFORM_CONTEXT] = 46 << 1 | 0;
  16737. this.contexts[RUNLENGTH_CONTEXT] = 3 << 1 | 0;
  16738. },
  16739. setNeighborsSignificance: function BitModel_setNeighborsSignificance(row, column, index) {
  16740. var neighborsSignificance = this.neighborsSignificance;
  16741. var width = this.width, height = this.height;
  16742. var left = column > 0;
  16743. var right = column + 1 < width;
  16744. var i;
  16745. if (row > 0) {
  16746. i = index - width;
  16747. if (left) {
  16748. neighborsSignificance[i - 1] += 0x10;
  16749. }
  16750. if (right) {
  16751. neighborsSignificance[i + 1] += 0x10;
  16752. }
  16753. neighborsSignificance[i] += 0x04;
  16754. }
  16755. if (row + 1 < height) {
  16756. i = index + width;
  16757. if (left) {
  16758. neighborsSignificance[i - 1] += 0x10;
  16759. }
  16760. if (right) {
  16761. neighborsSignificance[i + 1] += 0x10;
  16762. }
  16763. neighborsSignificance[i] += 0x04;
  16764. }
  16765. if (left) {
  16766. neighborsSignificance[index - 1] += 0x01;
  16767. }
  16768. if (right) {
  16769. neighborsSignificance[index + 1] += 0x01;
  16770. }
  16771. neighborsSignificance[index] |= 0x80;
  16772. },
  16773. runSignificancePropagationPass: function BitModel_runSignificancePropagationPass() {
  16774. var decoder = this.decoder;
  16775. var width = this.width, height = this.height;
  16776. var coefficentsMagnitude = this.coefficentsMagnitude;
  16777. var coefficentsSign = this.coefficentsSign;
  16778. var neighborsSignificance = this.neighborsSignificance;
  16779. var processingFlags = this.processingFlags;
  16780. var contexts = this.contexts;
  16781. var labels = this.contextLabelTable;
  16782. var bitsDecoded = this.bitsDecoded;
  16783. var processedInverseMask = ~1;
  16784. var processedMask = 1;
  16785. var firstMagnitudeBitMask = 2;
  16786. for (var i0 = 0; i0 < height; i0 += 4) {
  16787. for (var j = 0; j < width; j++) {
  16788. var index = i0 * width + j;
  16789. for (var i1 = 0; i1 < 4; i1++, index += width) {
  16790. var i = i0 + i1;
  16791. if (i >= height) {
  16792. break;
  16793. }
  16794. processingFlags[index] &= processedInverseMask;
  16795. if (coefficentsMagnitude[index] || !neighborsSignificance[index]) {
  16796. continue;
  16797. }
  16798. var contextLabel = labels[neighborsSignificance[index]];
  16799. var decision = decoder.readBit(contexts, contextLabel);
  16800. if (decision) {
  16801. var sign = this.decodeSignBit(i, j, index);
  16802. coefficentsSign[index] = sign;
  16803. coefficentsMagnitude[index] = 1;
  16804. this.setNeighborsSignificance(i, j, index);
  16805. processingFlags[index] |= firstMagnitudeBitMask;
  16806. }
  16807. bitsDecoded[index]++;
  16808. processingFlags[index] |= processedMask;
  16809. }
  16810. }
  16811. }
  16812. },
  16813. decodeSignBit: function BitModel_decodeSignBit(row, column, index) {
  16814. var width = this.width, height = this.height;
  16815. var coefficentsMagnitude = this.coefficentsMagnitude;
  16816. var coefficentsSign = this.coefficentsSign;
  16817. var contribution, sign0, sign1, significance1;
  16818. var contextLabel, decoded;
  16819. significance1 = column > 0 && coefficentsMagnitude[index - 1] !== 0;
  16820. if (column + 1 < width && coefficentsMagnitude[index + 1] !== 0) {
  16821. sign1 = coefficentsSign[index + 1];
  16822. if (significance1) {
  16823. sign0 = coefficentsSign[index - 1];
  16824. contribution = 1 - sign1 - sign0;
  16825. } else {
  16826. contribution = 1 - sign1 - sign1;
  16827. }
  16828. } else if (significance1) {
  16829. sign0 = coefficentsSign[index - 1];
  16830. contribution = 1 - sign0 - sign0;
  16831. } else {
  16832. contribution = 0;
  16833. }
  16834. var horizontalContribution = 3 * contribution;
  16835. significance1 = row > 0 && coefficentsMagnitude[index - width] !== 0;
  16836. if (row + 1 < height && coefficentsMagnitude[index + width] !== 0) {
  16837. sign1 = coefficentsSign[index + width];
  16838. if (significance1) {
  16839. sign0 = coefficentsSign[index - width];
  16840. contribution = 1 - sign1 - sign0 + horizontalContribution;
  16841. } else {
  16842. contribution = 1 - sign1 - sign1 + horizontalContribution;
  16843. }
  16844. } else if (significance1) {
  16845. sign0 = coefficentsSign[index - width];
  16846. contribution = 1 - sign0 - sign0 + horizontalContribution;
  16847. } else {
  16848. contribution = horizontalContribution;
  16849. }
  16850. if (contribution >= 0) {
  16851. contextLabel = 9 + contribution;
  16852. decoded = this.decoder.readBit(this.contexts, contextLabel);
  16853. } else {
  16854. contextLabel = 9 - contribution;
  16855. decoded = this.decoder.readBit(this.contexts, contextLabel) ^ 1;
  16856. }
  16857. return decoded;
  16858. },
  16859. runMagnitudeRefinementPass: function BitModel_runMagnitudeRefinementPass() {
  16860. var decoder = this.decoder;
  16861. var width = this.width, height = this.height;
  16862. var coefficentsMagnitude = this.coefficentsMagnitude;
  16863. var neighborsSignificance = this.neighborsSignificance;
  16864. var contexts = this.contexts;
  16865. var bitsDecoded = this.bitsDecoded;
  16866. var processingFlags = this.processingFlags;
  16867. var processedMask = 1;
  16868. var firstMagnitudeBitMask = 2;
  16869. var length = width * height;
  16870. var width4 = width * 4;
  16871. for (var index0 = 0, indexNext; index0 < length; index0 = indexNext) {
  16872. indexNext = Math.min(length, index0 + width4);
  16873. for (var j = 0; j < width; j++) {
  16874. for (var index = index0 + j; index < indexNext; index += width) {
  16875. if (!coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16876. continue;
  16877. }
  16878. var contextLabel = 16;
  16879. if ((processingFlags[index] & firstMagnitudeBitMask) !== 0) {
  16880. processingFlags[index] ^= firstMagnitudeBitMask;
  16881. var significance = neighborsSignificance[index] & 127;
  16882. contextLabel = significance === 0 ? 15 : 14;
  16883. }
  16884. var bit = decoder.readBit(contexts, contextLabel);
  16885. coefficentsMagnitude[index] = coefficentsMagnitude[index] << 1 | bit;
  16886. bitsDecoded[index]++;
  16887. processingFlags[index] |= processedMask;
  16888. }
  16889. }
  16890. }
  16891. },
  16892. runCleanupPass: function BitModel_runCleanupPass() {
  16893. var decoder = this.decoder;
  16894. var width = this.width, height = this.height;
  16895. var neighborsSignificance = this.neighborsSignificance;
  16896. var coefficentsMagnitude = this.coefficentsMagnitude;
  16897. var coefficentsSign = this.coefficentsSign;
  16898. var contexts = this.contexts;
  16899. var labels = this.contextLabelTable;
  16900. var bitsDecoded = this.bitsDecoded;
  16901. var processingFlags = this.processingFlags;
  16902. var processedMask = 1;
  16903. var firstMagnitudeBitMask = 2;
  16904. var oneRowDown = width;
  16905. var twoRowsDown = width * 2;
  16906. var threeRowsDown = width * 3;
  16907. var iNext;
  16908. for (var i0 = 0; i0 < height; i0 = iNext) {
  16909. iNext = Math.min(i0 + 4, height);
  16910. var indexBase = i0 * width;
  16911. var checkAllEmpty = i0 + 3 < height;
  16912. for (var j = 0; j < width; j++) {
  16913. var index0 = indexBase + j;
  16914. var allEmpty = checkAllEmpty && processingFlags[index0] === 0 && processingFlags[index0 + oneRowDown] === 0 && processingFlags[index0 + twoRowsDown] === 0 && processingFlags[index0 + threeRowsDown] === 0 && neighborsSignificance[index0] === 0 && neighborsSignificance[index0 + oneRowDown] === 0 && neighborsSignificance[index0 + twoRowsDown] === 0 && neighborsSignificance[index0 + threeRowsDown] === 0;
  16915. var i1 = 0, index = index0;
  16916. var i = i0, sign;
  16917. if (allEmpty) {
  16918. var hasSignificantCoefficent = decoder.readBit(contexts, RUNLENGTH_CONTEXT);
  16919. if (!hasSignificantCoefficent) {
  16920. bitsDecoded[index0]++;
  16921. bitsDecoded[index0 + oneRowDown]++;
  16922. bitsDecoded[index0 + twoRowsDown]++;
  16923. bitsDecoded[index0 + threeRowsDown]++;
  16924. continue;
  16925. }
  16926. i1 = decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  16927. if (i1 !== 0) {
  16928. i = i0 + i1;
  16929. index += i1 * width;
  16930. }
  16931. sign = this.decodeSignBit(i, j, index);
  16932. coefficentsSign[index] = sign;
  16933. coefficentsMagnitude[index] = 1;
  16934. this.setNeighborsSignificance(i, j, index);
  16935. processingFlags[index] |= firstMagnitudeBitMask;
  16936. index = index0;
  16937. for (var i2 = i0; i2 <= i; i2++, index += width) {
  16938. bitsDecoded[index]++;
  16939. }
  16940. i1++;
  16941. }
  16942. for (i = i0 + i1; i < iNext; i++, index += width) {
  16943. if (coefficentsMagnitude[index] || (processingFlags[index] & processedMask) !== 0) {
  16944. continue;
  16945. }
  16946. var contextLabel = labels[neighborsSignificance[index]];
  16947. var decision = decoder.readBit(contexts, contextLabel);
  16948. if (decision === 1) {
  16949. sign = this.decodeSignBit(i, j, index);
  16950. coefficentsSign[index] = sign;
  16951. coefficentsMagnitude[index] = 1;
  16952. this.setNeighborsSignificance(i, j, index);
  16953. processingFlags[index] |= firstMagnitudeBitMask;
  16954. }
  16955. bitsDecoded[index]++;
  16956. }
  16957. }
  16958. }
  16959. },
  16960. checkSegmentationSymbol: function BitModel_checkSegmentationSymbol() {
  16961. var decoder = this.decoder;
  16962. var contexts = this.contexts;
  16963. var symbol = decoder.readBit(contexts, UNIFORM_CONTEXT) << 3 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 2 | decoder.readBit(contexts, UNIFORM_CONTEXT) << 1 | decoder.readBit(contexts, UNIFORM_CONTEXT);
  16964. if (symbol !== 0xA) {
  16965. error('JPX Error: Invalid segmentation symbol');
  16966. }
  16967. }
  16968. };
  16969. return BitModel;
  16970. }();
  16971. var Transform = function TransformClosure() {
  16972. function Transform() {
  16973. }
  16974. Transform.prototype.calculate = function transformCalculate(subbands, u0, v0) {
  16975. var ll = subbands[0];
  16976. for (var i = 1, ii = subbands.length; i < ii; i++) {
  16977. ll = this.iterate(ll, subbands[i], u0, v0);
  16978. }
  16979. return ll;
  16980. };
  16981. Transform.prototype.extend = function extend(buffer, offset, size) {
  16982. var i1 = offset - 1, j1 = offset + 1;
  16983. var i2 = offset + size - 2, j2 = offset + size;
  16984. buffer[i1--] = buffer[j1++];
  16985. buffer[j2++] = buffer[i2--];
  16986. buffer[i1--] = buffer[j1++];
  16987. buffer[j2++] = buffer[i2--];
  16988. buffer[i1--] = buffer[j1++];
  16989. buffer[j2++] = buffer[i2--];
  16990. buffer[i1] = buffer[j1];
  16991. buffer[j2] = buffer[i2];
  16992. };
  16993. Transform.prototype.iterate = function Transform_iterate(ll, hl_lh_hh, u0, v0) {
  16994. var llWidth = ll.width, llHeight = ll.height, llItems = ll.items;
  16995. var width = hl_lh_hh.width;
  16996. var height = hl_lh_hh.height;
  16997. var items = hl_lh_hh.items;
  16998. var i, j, k, l, u, v;
  16999. for (k = 0, i = 0; i < llHeight; i++) {
  17000. l = i * 2 * width;
  17001. for (j = 0; j < llWidth; j++, k++, l += 2) {
  17002. items[l] = llItems[k];
  17003. }
  17004. }
  17005. llItems = ll.items = null;
  17006. var bufferPadding = 4;
  17007. var rowBuffer = new Float32Array(width + 2 * bufferPadding);
  17008. if (width === 1) {
  17009. if ((u0 & 1) !== 0) {
  17010. for (v = 0, k = 0; v < height; v++, k += width) {
  17011. items[k] *= 0.5;
  17012. }
  17013. }
  17014. } else {
  17015. for (v = 0, k = 0; v < height; v++, k += width) {
  17016. rowBuffer.set(items.subarray(k, k + width), bufferPadding);
  17017. this.extend(rowBuffer, bufferPadding, width);
  17018. this.filter(rowBuffer, bufferPadding, width);
  17019. items.set(rowBuffer.subarray(bufferPadding, bufferPadding + width), k);
  17020. }
  17021. }
  17022. var numBuffers = 16;
  17023. var colBuffers = [];
  17024. for (i = 0; i < numBuffers; i++) {
  17025. colBuffers.push(new Float32Array(height + 2 * bufferPadding));
  17026. }
  17027. var b, currentBuffer = 0;
  17028. ll = bufferPadding + height;
  17029. if (height === 1) {
  17030. if ((v0 & 1) !== 0) {
  17031. for (u = 0; u < width; u++) {
  17032. items[u] *= 0.5;
  17033. }
  17034. }
  17035. } else {
  17036. for (u = 0; u < width; u++) {
  17037. if (currentBuffer === 0) {
  17038. numBuffers = Math.min(width - u, numBuffers);
  17039. for (k = u, l = bufferPadding; l < ll; k += width, l++) {
  17040. for (b = 0; b < numBuffers; b++) {
  17041. colBuffers[b][l] = items[k + b];
  17042. }
  17043. }
  17044. currentBuffer = numBuffers;
  17045. }
  17046. currentBuffer--;
  17047. var buffer = colBuffers[currentBuffer];
  17048. this.extend(buffer, bufferPadding, height);
  17049. this.filter(buffer, bufferPadding, height);
  17050. if (currentBuffer === 0) {
  17051. k = u - numBuffers + 1;
  17052. for (l = bufferPadding; l < ll; k += width, l++) {
  17053. for (b = 0; b < numBuffers; b++) {
  17054. items[k + b] = colBuffers[b][l];
  17055. }
  17056. }
  17057. }
  17058. }
  17059. }
  17060. return {
  17061. width: width,
  17062. height: height,
  17063. items: items
  17064. };
  17065. };
  17066. return Transform;
  17067. }();
  17068. var IrreversibleTransform = function IrreversibleTransformClosure() {
  17069. function IrreversibleTransform() {
  17070. Transform.call(this);
  17071. }
  17072. IrreversibleTransform.prototype = Object.create(Transform.prototype);
  17073. IrreversibleTransform.prototype.filter = function irreversibleTransformFilter(x, offset, length) {
  17074. var len = length >> 1;
  17075. offset = offset | 0;
  17076. var j, n, current, next;
  17077. var alpha = -1.586134342059924;
  17078. var beta = -0.052980118572961;
  17079. var gamma = 0.882911075530934;
  17080. var delta = 0.443506852043971;
  17081. var K = 1.230174104914001;
  17082. var K_ = 1 / K;
  17083. j = offset - 3;
  17084. for (n = len + 4; n--; j += 2) {
  17085. x[j] *= K_;
  17086. }
  17087. j = offset - 2;
  17088. current = delta * x[j - 1];
  17089. for (n = len + 3; n--; j += 2) {
  17090. next = delta * x[j + 1];
  17091. x[j] = K * x[j] - current - next;
  17092. if (n--) {
  17093. j += 2;
  17094. current = delta * x[j + 1];
  17095. x[j] = K * x[j] - current - next;
  17096. } else {
  17097. break;
  17098. }
  17099. }
  17100. j = offset - 1;
  17101. current = gamma * x[j - 1];
  17102. for (n = len + 2; n--; j += 2) {
  17103. next = gamma * x[j + 1];
  17104. x[j] -= current + next;
  17105. if (n--) {
  17106. j += 2;
  17107. current = gamma * x[j + 1];
  17108. x[j] -= current + next;
  17109. } else {
  17110. break;
  17111. }
  17112. }
  17113. j = offset;
  17114. current = beta * x[j - 1];
  17115. for (n = len + 1; n--; j += 2) {
  17116. next = beta * x[j + 1];
  17117. x[j] -= current + next;
  17118. if (n--) {
  17119. j += 2;
  17120. current = beta * x[j + 1];
  17121. x[j] -= current + next;
  17122. } else {
  17123. break;
  17124. }
  17125. }
  17126. if (len !== 0) {
  17127. j = offset + 1;
  17128. current = alpha * x[j - 1];
  17129. for (n = len; n--; j += 2) {
  17130. next = alpha * x[j + 1];
  17131. x[j] -= current + next;
  17132. if (n--) {
  17133. j += 2;
  17134. current = alpha * x[j + 1];
  17135. x[j] -= current + next;
  17136. } else {
  17137. break;
  17138. }
  17139. }
  17140. }
  17141. };
  17142. return IrreversibleTransform;
  17143. }();
  17144. var ReversibleTransform = function ReversibleTransformClosure() {
  17145. function ReversibleTransform() {
  17146. Transform.call(this);
  17147. }
  17148. ReversibleTransform.prototype = Object.create(Transform.prototype);
  17149. ReversibleTransform.prototype.filter = function reversibleTransformFilter(x, offset, length) {
  17150. var len = length >> 1;
  17151. offset = offset | 0;
  17152. var j, n;
  17153. for (j = offset, n = len + 1; n--; j += 2) {
  17154. x[j] -= x[j - 1] + x[j + 1] + 2 >> 2;
  17155. }
  17156. for (j = offset + 1, n = len; n--; j += 2) {
  17157. x[j] += x[j - 1] + x[j + 1] >> 1;
  17158. }
  17159. };
  17160. return ReversibleTransform;
  17161. }();
  17162. return JpxImage;
  17163. }();
  17164. exports.JpxImage = JpxImage;
  17165. }));
  17166. (function (root, factory) {
  17167. factory(root.pdfjsCoreMetrics = {}, root.pdfjsSharedUtil);
  17168. }(this, function (exports, sharedUtil) {
  17169. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  17170. var getMetrics = getLookupTableFactory(function (t) {
  17171. t['Courier'] = 600;
  17172. t['Courier-Bold'] = 600;
  17173. t['Courier-BoldOblique'] = 600;
  17174. t['Courier-Oblique'] = 600;
  17175. t['Helvetica'] = getLookupTableFactory(function (t) {
  17176. t['space'] = 278;
  17177. t['exclam'] = 278;
  17178. t['quotedbl'] = 355;
  17179. t['numbersign'] = 556;
  17180. t['dollar'] = 556;
  17181. t['percent'] = 889;
  17182. t['ampersand'] = 667;
  17183. t['quoteright'] = 222;
  17184. t['parenleft'] = 333;
  17185. t['parenright'] = 333;
  17186. t['asterisk'] = 389;
  17187. t['plus'] = 584;
  17188. t['comma'] = 278;
  17189. t['hyphen'] = 333;
  17190. t['period'] = 278;
  17191. t['slash'] = 278;
  17192. t['zero'] = 556;
  17193. t['one'] = 556;
  17194. t['two'] = 556;
  17195. t['three'] = 556;
  17196. t['four'] = 556;
  17197. t['five'] = 556;
  17198. t['six'] = 556;
  17199. t['seven'] = 556;
  17200. t['eight'] = 556;
  17201. t['nine'] = 556;
  17202. t['colon'] = 278;
  17203. t['semicolon'] = 278;
  17204. t['less'] = 584;
  17205. t['equal'] = 584;
  17206. t['greater'] = 584;
  17207. t['question'] = 556;
  17208. t['at'] = 1015;
  17209. t['A'] = 667;
  17210. t['B'] = 667;
  17211. t['C'] = 722;
  17212. t['D'] = 722;
  17213. t['E'] = 667;
  17214. t['F'] = 611;
  17215. t['G'] = 778;
  17216. t['H'] = 722;
  17217. t['I'] = 278;
  17218. t['J'] = 500;
  17219. t['K'] = 667;
  17220. t['L'] = 556;
  17221. t['M'] = 833;
  17222. t['N'] = 722;
  17223. t['O'] = 778;
  17224. t['P'] = 667;
  17225. t['Q'] = 778;
  17226. t['R'] = 722;
  17227. t['S'] = 667;
  17228. t['T'] = 611;
  17229. t['U'] = 722;
  17230. t['V'] = 667;
  17231. t['W'] = 944;
  17232. t['X'] = 667;
  17233. t['Y'] = 667;
  17234. t['Z'] = 611;
  17235. t['bracketleft'] = 278;
  17236. t['backslash'] = 278;
  17237. t['bracketright'] = 278;
  17238. t['asciicircum'] = 469;
  17239. t['underscore'] = 556;
  17240. t['quoteleft'] = 222;
  17241. t['a'] = 556;
  17242. t['b'] = 556;
  17243. t['c'] = 500;
  17244. t['d'] = 556;
  17245. t['e'] = 556;
  17246. t['f'] = 278;
  17247. t['g'] = 556;
  17248. t['h'] = 556;
  17249. t['i'] = 222;
  17250. t['j'] = 222;
  17251. t['k'] = 500;
  17252. t['l'] = 222;
  17253. t['m'] = 833;
  17254. t['n'] = 556;
  17255. t['o'] = 556;
  17256. t['p'] = 556;
  17257. t['q'] = 556;
  17258. t['r'] = 333;
  17259. t['s'] = 500;
  17260. t['t'] = 278;
  17261. t['u'] = 556;
  17262. t['v'] = 500;
  17263. t['w'] = 722;
  17264. t['x'] = 500;
  17265. t['y'] = 500;
  17266. t['z'] = 500;
  17267. t['braceleft'] = 334;
  17268. t['bar'] = 260;
  17269. t['braceright'] = 334;
  17270. t['asciitilde'] = 584;
  17271. t['exclamdown'] = 333;
  17272. t['cent'] = 556;
  17273. t['sterling'] = 556;
  17274. t['fraction'] = 167;
  17275. t['yen'] = 556;
  17276. t['florin'] = 556;
  17277. t['section'] = 556;
  17278. t['currency'] = 556;
  17279. t['quotesingle'] = 191;
  17280. t['quotedblleft'] = 333;
  17281. t['guillemotleft'] = 556;
  17282. t['guilsinglleft'] = 333;
  17283. t['guilsinglright'] = 333;
  17284. t['fi'] = 500;
  17285. t['fl'] = 500;
  17286. t['endash'] = 556;
  17287. t['dagger'] = 556;
  17288. t['daggerdbl'] = 556;
  17289. t['periodcentered'] = 278;
  17290. t['paragraph'] = 537;
  17291. t['bullet'] = 350;
  17292. t['quotesinglbase'] = 222;
  17293. t['quotedblbase'] = 333;
  17294. t['quotedblright'] = 333;
  17295. t['guillemotright'] = 556;
  17296. t['ellipsis'] = 1000;
  17297. t['perthousand'] = 1000;
  17298. t['questiondown'] = 611;
  17299. t['grave'] = 333;
  17300. t['acute'] = 333;
  17301. t['circumflex'] = 333;
  17302. t['tilde'] = 333;
  17303. t['macron'] = 333;
  17304. t['breve'] = 333;
  17305. t['dotaccent'] = 333;
  17306. t['dieresis'] = 333;
  17307. t['ring'] = 333;
  17308. t['cedilla'] = 333;
  17309. t['hungarumlaut'] = 333;
  17310. t['ogonek'] = 333;
  17311. t['caron'] = 333;
  17312. t['emdash'] = 1000;
  17313. t['AE'] = 1000;
  17314. t['ordfeminine'] = 370;
  17315. t['Lslash'] = 556;
  17316. t['Oslash'] = 778;
  17317. t['OE'] = 1000;
  17318. t['ordmasculine'] = 365;
  17319. t['ae'] = 889;
  17320. t['dotlessi'] = 278;
  17321. t['lslash'] = 222;
  17322. t['oslash'] = 611;
  17323. t['oe'] = 944;
  17324. t['germandbls'] = 611;
  17325. t['Idieresis'] = 278;
  17326. t['eacute'] = 556;
  17327. t['abreve'] = 556;
  17328. t['uhungarumlaut'] = 556;
  17329. t['ecaron'] = 556;
  17330. t['Ydieresis'] = 667;
  17331. t['divide'] = 584;
  17332. t['Yacute'] = 667;
  17333. t['Acircumflex'] = 667;
  17334. t['aacute'] = 556;
  17335. t['Ucircumflex'] = 722;
  17336. t['yacute'] = 500;
  17337. t['scommaaccent'] = 500;
  17338. t['ecircumflex'] = 556;
  17339. t['Uring'] = 722;
  17340. t['Udieresis'] = 722;
  17341. t['aogonek'] = 556;
  17342. t['Uacute'] = 722;
  17343. t['uogonek'] = 556;
  17344. t['Edieresis'] = 667;
  17345. t['Dcroat'] = 722;
  17346. t['commaaccent'] = 250;
  17347. t['copyright'] = 737;
  17348. t['Emacron'] = 667;
  17349. t['ccaron'] = 500;
  17350. t['aring'] = 556;
  17351. t['Ncommaaccent'] = 722;
  17352. t['lacute'] = 222;
  17353. t['agrave'] = 556;
  17354. t['Tcommaaccent'] = 611;
  17355. t['Cacute'] = 722;
  17356. t['atilde'] = 556;
  17357. t['Edotaccent'] = 667;
  17358. t['scaron'] = 500;
  17359. t['scedilla'] = 500;
  17360. t['iacute'] = 278;
  17361. t['lozenge'] = 471;
  17362. t['Rcaron'] = 722;
  17363. t['Gcommaaccent'] = 778;
  17364. t['ucircumflex'] = 556;
  17365. t['acircumflex'] = 556;
  17366. t['Amacron'] = 667;
  17367. t['rcaron'] = 333;
  17368. t['ccedilla'] = 500;
  17369. t['Zdotaccent'] = 611;
  17370. t['Thorn'] = 667;
  17371. t['Omacron'] = 778;
  17372. t['Racute'] = 722;
  17373. t['Sacute'] = 667;
  17374. t['dcaron'] = 643;
  17375. t['Umacron'] = 722;
  17376. t['uring'] = 556;
  17377. t['threesuperior'] = 333;
  17378. t['Ograve'] = 778;
  17379. t['Agrave'] = 667;
  17380. t['Abreve'] = 667;
  17381. t['multiply'] = 584;
  17382. t['uacute'] = 556;
  17383. t['Tcaron'] = 611;
  17384. t['partialdiff'] = 476;
  17385. t['ydieresis'] = 500;
  17386. t['Nacute'] = 722;
  17387. t['icircumflex'] = 278;
  17388. t['Ecircumflex'] = 667;
  17389. t['adieresis'] = 556;
  17390. t['edieresis'] = 556;
  17391. t['cacute'] = 500;
  17392. t['nacute'] = 556;
  17393. t['umacron'] = 556;
  17394. t['Ncaron'] = 722;
  17395. t['Iacute'] = 278;
  17396. t['plusminus'] = 584;
  17397. t['brokenbar'] = 260;
  17398. t['registered'] = 737;
  17399. t['Gbreve'] = 778;
  17400. t['Idotaccent'] = 278;
  17401. t['summation'] = 600;
  17402. t['Egrave'] = 667;
  17403. t['racute'] = 333;
  17404. t['omacron'] = 556;
  17405. t['Zacute'] = 611;
  17406. t['Zcaron'] = 611;
  17407. t['greaterequal'] = 549;
  17408. t['Eth'] = 722;
  17409. t['Ccedilla'] = 722;
  17410. t['lcommaaccent'] = 222;
  17411. t['tcaron'] = 317;
  17412. t['eogonek'] = 556;
  17413. t['Uogonek'] = 722;
  17414. t['Aacute'] = 667;
  17415. t['Adieresis'] = 667;
  17416. t['egrave'] = 556;
  17417. t['zacute'] = 500;
  17418. t['iogonek'] = 222;
  17419. t['Oacute'] = 778;
  17420. t['oacute'] = 556;
  17421. t['amacron'] = 556;
  17422. t['sacute'] = 500;
  17423. t['idieresis'] = 278;
  17424. t['Ocircumflex'] = 778;
  17425. t['Ugrave'] = 722;
  17426. t['Delta'] = 612;
  17427. t['thorn'] = 556;
  17428. t['twosuperior'] = 333;
  17429. t['Odieresis'] = 778;
  17430. t['mu'] = 556;
  17431. t['igrave'] = 278;
  17432. t['ohungarumlaut'] = 556;
  17433. t['Eogonek'] = 667;
  17434. t['dcroat'] = 556;
  17435. t['threequarters'] = 834;
  17436. t['Scedilla'] = 667;
  17437. t['lcaron'] = 299;
  17438. t['Kcommaaccent'] = 667;
  17439. t['Lacute'] = 556;
  17440. t['trademark'] = 1000;
  17441. t['edotaccent'] = 556;
  17442. t['Igrave'] = 278;
  17443. t['Imacron'] = 278;
  17444. t['Lcaron'] = 556;
  17445. t['onehalf'] = 834;
  17446. t['lessequal'] = 549;
  17447. t['ocircumflex'] = 556;
  17448. t['ntilde'] = 556;
  17449. t['Uhungarumlaut'] = 722;
  17450. t['Eacute'] = 667;
  17451. t['emacron'] = 556;
  17452. t['gbreve'] = 556;
  17453. t['onequarter'] = 834;
  17454. t['Scaron'] = 667;
  17455. t['Scommaaccent'] = 667;
  17456. t['Ohungarumlaut'] = 778;
  17457. t['degree'] = 400;
  17458. t['ograve'] = 556;
  17459. t['Ccaron'] = 722;
  17460. t['ugrave'] = 556;
  17461. t['radical'] = 453;
  17462. t['Dcaron'] = 722;
  17463. t['rcommaaccent'] = 333;
  17464. t['Ntilde'] = 722;
  17465. t['otilde'] = 556;
  17466. t['Rcommaaccent'] = 722;
  17467. t['Lcommaaccent'] = 556;
  17468. t['Atilde'] = 667;
  17469. t['Aogonek'] = 667;
  17470. t['Aring'] = 667;
  17471. t['Otilde'] = 778;
  17472. t['zdotaccent'] = 500;
  17473. t['Ecaron'] = 667;
  17474. t['Iogonek'] = 278;
  17475. t['kcommaaccent'] = 500;
  17476. t['minus'] = 584;
  17477. t['Icircumflex'] = 278;
  17478. t['ncaron'] = 556;
  17479. t['tcommaaccent'] = 278;
  17480. t['logicalnot'] = 584;
  17481. t['odieresis'] = 556;
  17482. t['udieresis'] = 556;
  17483. t['notequal'] = 549;
  17484. t['gcommaaccent'] = 556;
  17485. t['eth'] = 556;
  17486. t['zcaron'] = 500;
  17487. t['ncommaaccent'] = 556;
  17488. t['onesuperior'] = 333;
  17489. t['imacron'] = 278;
  17490. t['Euro'] = 556;
  17491. });
  17492. t['Helvetica-Bold'] = getLookupTableFactory(function (t) {
  17493. t['space'] = 278;
  17494. t['exclam'] = 333;
  17495. t['quotedbl'] = 474;
  17496. t['numbersign'] = 556;
  17497. t['dollar'] = 556;
  17498. t['percent'] = 889;
  17499. t['ampersand'] = 722;
  17500. t['quoteright'] = 278;
  17501. t['parenleft'] = 333;
  17502. t['parenright'] = 333;
  17503. t['asterisk'] = 389;
  17504. t['plus'] = 584;
  17505. t['comma'] = 278;
  17506. t['hyphen'] = 333;
  17507. t['period'] = 278;
  17508. t['slash'] = 278;
  17509. t['zero'] = 556;
  17510. t['one'] = 556;
  17511. t['two'] = 556;
  17512. t['three'] = 556;
  17513. t['four'] = 556;
  17514. t['five'] = 556;
  17515. t['six'] = 556;
  17516. t['seven'] = 556;
  17517. t['eight'] = 556;
  17518. t['nine'] = 556;
  17519. t['colon'] = 333;
  17520. t['semicolon'] = 333;
  17521. t['less'] = 584;
  17522. t['equal'] = 584;
  17523. t['greater'] = 584;
  17524. t['question'] = 611;
  17525. t['at'] = 975;
  17526. t['A'] = 722;
  17527. t['B'] = 722;
  17528. t['C'] = 722;
  17529. t['D'] = 722;
  17530. t['E'] = 667;
  17531. t['F'] = 611;
  17532. t['G'] = 778;
  17533. t['H'] = 722;
  17534. t['I'] = 278;
  17535. t['J'] = 556;
  17536. t['K'] = 722;
  17537. t['L'] = 611;
  17538. t['M'] = 833;
  17539. t['N'] = 722;
  17540. t['O'] = 778;
  17541. t['P'] = 667;
  17542. t['Q'] = 778;
  17543. t['R'] = 722;
  17544. t['S'] = 667;
  17545. t['T'] = 611;
  17546. t['U'] = 722;
  17547. t['V'] = 667;
  17548. t['W'] = 944;
  17549. t['X'] = 667;
  17550. t['Y'] = 667;
  17551. t['Z'] = 611;
  17552. t['bracketleft'] = 333;
  17553. t['backslash'] = 278;
  17554. t['bracketright'] = 333;
  17555. t['asciicircum'] = 584;
  17556. t['underscore'] = 556;
  17557. t['quoteleft'] = 278;
  17558. t['a'] = 556;
  17559. t['b'] = 611;
  17560. t['c'] = 556;
  17561. t['d'] = 611;
  17562. t['e'] = 556;
  17563. t['f'] = 333;
  17564. t['g'] = 611;
  17565. t['h'] = 611;
  17566. t['i'] = 278;
  17567. t['j'] = 278;
  17568. t['k'] = 556;
  17569. t['l'] = 278;
  17570. t['m'] = 889;
  17571. t['n'] = 611;
  17572. t['o'] = 611;
  17573. t['p'] = 611;
  17574. t['q'] = 611;
  17575. t['r'] = 389;
  17576. t['s'] = 556;
  17577. t['t'] = 333;
  17578. t['u'] = 611;
  17579. t['v'] = 556;
  17580. t['w'] = 778;
  17581. t['x'] = 556;
  17582. t['y'] = 556;
  17583. t['z'] = 500;
  17584. t['braceleft'] = 389;
  17585. t['bar'] = 280;
  17586. t['braceright'] = 389;
  17587. t['asciitilde'] = 584;
  17588. t['exclamdown'] = 333;
  17589. t['cent'] = 556;
  17590. t['sterling'] = 556;
  17591. t['fraction'] = 167;
  17592. t['yen'] = 556;
  17593. t['florin'] = 556;
  17594. t['section'] = 556;
  17595. t['currency'] = 556;
  17596. t['quotesingle'] = 238;
  17597. t['quotedblleft'] = 500;
  17598. t['guillemotleft'] = 556;
  17599. t['guilsinglleft'] = 333;
  17600. t['guilsinglright'] = 333;
  17601. t['fi'] = 611;
  17602. t['fl'] = 611;
  17603. t['endash'] = 556;
  17604. t['dagger'] = 556;
  17605. t['daggerdbl'] = 556;
  17606. t['periodcentered'] = 278;
  17607. t['paragraph'] = 556;
  17608. t['bullet'] = 350;
  17609. t['quotesinglbase'] = 278;
  17610. t['quotedblbase'] = 500;
  17611. t['quotedblright'] = 500;
  17612. t['guillemotright'] = 556;
  17613. t['ellipsis'] = 1000;
  17614. t['perthousand'] = 1000;
  17615. t['questiondown'] = 611;
  17616. t['grave'] = 333;
  17617. t['acute'] = 333;
  17618. t['circumflex'] = 333;
  17619. t['tilde'] = 333;
  17620. t['macron'] = 333;
  17621. t['breve'] = 333;
  17622. t['dotaccent'] = 333;
  17623. t['dieresis'] = 333;
  17624. t['ring'] = 333;
  17625. t['cedilla'] = 333;
  17626. t['hungarumlaut'] = 333;
  17627. t['ogonek'] = 333;
  17628. t['caron'] = 333;
  17629. t['emdash'] = 1000;
  17630. t['AE'] = 1000;
  17631. t['ordfeminine'] = 370;
  17632. t['Lslash'] = 611;
  17633. t['Oslash'] = 778;
  17634. t['OE'] = 1000;
  17635. t['ordmasculine'] = 365;
  17636. t['ae'] = 889;
  17637. t['dotlessi'] = 278;
  17638. t['lslash'] = 278;
  17639. t['oslash'] = 611;
  17640. t['oe'] = 944;
  17641. t['germandbls'] = 611;
  17642. t['Idieresis'] = 278;
  17643. t['eacute'] = 556;
  17644. t['abreve'] = 556;
  17645. t['uhungarumlaut'] = 611;
  17646. t['ecaron'] = 556;
  17647. t['Ydieresis'] = 667;
  17648. t['divide'] = 584;
  17649. t['Yacute'] = 667;
  17650. t['Acircumflex'] = 722;
  17651. t['aacute'] = 556;
  17652. t['Ucircumflex'] = 722;
  17653. t['yacute'] = 556;
  17654. t['scommaaccent'] = 556;
  17655. t['ecircumflex'] = 556;
  17656. t['Uring'] = 722;
  17657. t['Udieresis'] = 722;
  17658. t['aogonek'] = 556;
  17659. t['Uacute'] = 722;
  17660. t['uogonek'] = 611;
  17661. t['Edieresis'] = 667;
  17662. t['Dcroat'] = 722;
  17663. t['commaaccent'] = 250;
  17664. t['copyright'] = 737;
  17665. t['Emacron'] = 667;
  17666. t['ccaron'] = 556;
  17667. t['aring'] = 556;
  17668. t['Ncommaaccent'] = 722;
  17669. t['lacute'] = 278;
  17670. t['agrave'] = 556;
  17671. t['Tcommaaccent'] = 611;
  17672. t['Cacute'] = 722;
  17673. t['atilde'] = 556;
  17674. t['Edotaccent'] = 667;
  17675. t['scaron'] = 556;
  17676. t['scedilla'] = 556;
  17677. t['iacute'] = 278;
  17678. t['lozenge'] = 494;
  17679. t['Rcaron'] = 722;
  17680. t['Gcommaaccent'] = 778;
  17681. t['ucircumflex'] = 611;
  17682. t['acircumflex'] = 556;
  17683. t['Amacron'] = 722;
  17684. t['rcaron'] = 389;
  17685. t['ccedilla'] = 556;
  17686. t['Zdotaccent'] = 611;
  17687. t['Thorn'] = 667;
  17688. t['Omacron'] = 778;
  17689. t['Racute'] = 722;
  17690. t['Sacute'] = 667;
  17691. t['dcaron'] = 743;
  17692. t['Umacron'] = 722;
  17693. t['uring'] = 611;
  17694. t['threesuperior'] = 333;
  17695. t['Ograve'] = 778;
  17696. t['Agrave'] = 722;
  17697. t['Abreve'] = 722;
  17698. t['multiply'] = 584;
  17699. t['uacute'] = 611;
  17700. t['Tcaron'] = 611;
  17701. t['partialdiff'] = 494;
  17702. t['ydieresis'] = 556;
  17703. t['Nacute'] = 722;
  17704. t['icircumflex'] = 278;
  17705. t['Ecircumflex'] = 667;
  17706. t['adieresis'] = 556;
  17707. t['edieresis'] = 556;
  17708. t['cacute'] = 556;
  17709. t['nacute'] = 611;
  17710. t['umacron'] = 611;
  17711. t['Ncaron'] = 722;
  17712. t['Iacute'] = 278;
  17713. t['plusminus'] = 584;
  17714. t['brokenbar'] = 280;
  17715. t['registered'] = 737;
  17716. t['Gbreve'] = 778;
  17717. t['Idotaccent'] = 278;
  17718. t['summation'] = 600;
  17719. t['Egrave'] = 667;
  17720. t['racute'] = 389;
  17721. t['omacron'] = 611;
  17722. t['Zacute'] = 611;
  17723. t['Zcaron'] = 611;
  17724. t['greaterequal'] = 549;
  17725. t['Eth'] = 722;
  17726. t['Ccedilla'] = 722;
  17727. t['lcommaaccent'] = 278;
  17728. t['tcaron'] = 389;
  17729. t['eogonek'] = 556;
  17730. t['Uogonek'] = 722;
  17731. t['Aacute'] = 722;
  17732. t['Adieresis'] = 722;
  17733. t['egrave'] = 556;
  17734. t['zacute'] = 500;
  17735. t['iogonek'] = 278;
  17736. t['Oacute'] = 778;
  17737. t['oacute'] = 611;
  17738. t['amacron'] = 556;
  17739. t['sacute'] = 556;
  17740. t['idieresis'] = 278;
  17741. t['Ocircumflex'] = 778;
  17742. t['Ugrave'] = 722;
  17743. t['Delta'] = 612;
  17744. t['thorn'] = 611;
  17745. t['twosuperior'] = 333;
  17746. t['Odieresis'] = 778;
  17747. t['mu'] = 611;
  17748. t['igrave'] = 278;
  17749. t['ohungarumlaut'] = 611;
  17750. t['Eogonek'] = 667;
  17751. t['dcroat'] = 611;
  17752. t['threequarters'] = 834;
  17753. t['Scedilla'] = 667;
  17754. t['lcaron'] = 400;
  17755. t['Kcommaaccent'] = 722;
  17756. t['Lacute'] = 611;
  17757. t['trademark'] = 1000;
  17758. t['edotaccent'] = 556;
  17759. t['Igrave'] = 278;
  17760. t['Imacron'] = 278;
  17761. t['Lcaron'] = 611;
  17762. t['onehalf'] = 834;
  17763. t['lessequal'] = 549;
  17764. t['ocircumflex'] = 611;
  17765. t['ntilde'] = 611;
  17766. t['Uhungarumlaut'] = 722;
  17767. t['Eacute'] = 667;
  17768. t['emacron'] = 556;
  17769. t['gbreve'] = 611;
  17770. t['onequarter'] = 834;
  17771. t['Scaron'] = 667;
  17772. t['Scommaaccent'] = 667;
  17773. t['Ohungarumlaut'] = 778;
  17774. t['degree'] = 400;
  17775. t['ograve'] = 611;
  17776. t['Ccaron'] = 722;
  17777. t['ugrave'] = 611;
  17778. t['radical'] = 549;
  17779. t['Dcaron'] = 722;
  17780. t['rcommaaccent'] = 389;
  17781. t['Ntilde'] = 722;
  17782. t['otilde'] = 611;
  17783. t['Rcommaaccent'] = 722;
  17784. t['Lcommaaccent'] = 611;
  17785. t['Atilde'] = 722;
  17786. t['Aogonek'] = 722;
  17787. t['Aring'] = 722;
  17788. t['Otilde'] = 778;
  17789. t['zdotaccent'] = 500;
  17790. t['Ecaron'] = 667;
  17791. t['Iogonek'] = 278;
  17792. t['kcommaaccent'] = 556;
  17793. t['minus'] = 584;
  17794. t['Icircumflex'] = 278;
  17795. t['ncaron'] = 611;
  17796. t['tcommaaccent'] = 333;
  17797. t['logicalnot'] = 584;
  17798. t['odieresis'] = 611;
  17799. t['udieresis'] = 611;
  17800. t['notequal'] = 549;
  17801. t['gcommaaccent'] = 611;
  17802. t['eth'] = 611;
  17803. t['zcaron'] = 500;
  17804. t['ncommaaccent'] = 611;
  17805. t['onesuperior'] = 333;
  17806. t['imacron'] = 278;
  17807. t['Euro'] = 556;
  17808. });
  17809. t['Helvetica-BoldOblique'] = getLookupTableFactory(function (t) {
  17810. t['space'] = 278;
  17811. t['exclam'] = 333;
  17812. t['quotedbl'] = 474;
  17813. t['numbersign'] = 556;
  17814. t['dollar'] = 556;
  17815. t['percent'] = 889;
  17816. t['ampersand'] = 722;
  17817. t['quoteright'] = 278;
  17818. t['parenleft'] = 333;
  17819. t['parenright'] = 333;
  17820. t['asterisk'] = 389;
  17821. t['plus'] = 584;
  17822. t['comma'] = 278;
  17823. t['hyphen'] = 333;
  17824. t['period'] = 278;
  17825. t['slash'] = 278;
  17826. t['zero'] = 556;
  17827. t['one'] = 556;
  17828. t['two'] = 556;
  17829. t['three'] = 556;
  17830. t['four'] = 556;
  17831. t['five'] = 556;
  17832. t['six'] = 556;
  17833. t['seven'] = 556;
  17834. t['eight'] = 556;
  17835. t['nine'] = 556;
  17836. t['colon'] = 333;
  17837. t['semicolon'] = 333;
  17838. t['less'] = 584;
  17839. t['equal'] = 584;
  17840. t['greater'] = 584;
  17841. t['question'] = 611;
  17842. t['at'] = 975;
  17843. t['A'] = 722;
  17844. t['B'] = 722;
  17845. t['C'] = 722;
  17846. t['D'] = 722;
  17847. t['E'] = 667;
  17848. t['F'] = 611;
  17849. t['G'] = 778;
  17850. t['H'] = 722;
  17851. t['I'] = 278;
  17852. t['J'] = 556;
  17853. t['K'] = 722;
  17854. t['L'] = 611;
  17855. t['M'] = 833;
  17856. t['N'] = 722;
  17857. t['O'] = 778;
  17858. t['P'] = 667;
  17859. t['Q'] = 778;
  17860. t['R'] = 722;
  17861. t['S'] = 667;
  17862. t['T'] = 611;
  17863. t['U'] = 722;
  17864. t['V'] = 667;
  17865. t['W'] = 944;
  17866. t['X'] = 667;
  17867. t['Y'] = 667;
  17868. t['Z'] = 611;
  17869. t['bracketleft'] = 333;
  17870. t['backslash'] = 278;
  17871. t['bracketright'] = 333;
  17872. t['asciicircum'] = 584;
  17873. t['underscore'] = 556;
  17874. t['quoteleft'] = 278;
  17875. t['a'] = 556;
  17876. t['b'] = 611;
  17877. t['c'] = 556;
  17878. t['d'] = 611;
  17879. t['e'] = 556;
  17880. t['f'] = 333;
  17881. t['g'] = 611;
  17882. t['h'] = 611;
  17883. t['i'] = 278;
  17884. t['j'] = 278;
  17885. t['k'] = 556;
  17886. t['l'] = 278;
  17887. t['m'] = 889;
  17888. t['n'] = 611;
  17889. t['o'] = 611;
  17890. t['p'] = 611;
  17891. t['q'] = 611;
  17892. t['r'] = 389;
  17893. t['s'] = 556;
  17894. t['t'] = 333;
  17895. t['u'] = 611;
  17896. t['v'] = 556;
  17897. t['w'] = 778;
  17898. t['x'] = 556;
  17899. t['y'] = 556;
  17900. t['z'] = 500;
  17901. t['braceleft'] = 389;
  17902. t['bar'] = 280;
  17903. t['braceright'] = 389;
  17904. t['asciitilde'] = 584;
  17905. t['exclamdown'] = 333;
  17906. t['cent'] = 556;
  17907. t['sterling'] = 556;
  17908. t['fraction'] = 167;
  17909. t['yen'] = 556;
  17910. t['florin'] = 556;
  17911. t['section'] = 556;
  17912. t['currency'] = 556;
  17913. t['quotesingle'] = 238;
  17914. t['quotedblleft'] = 500;
  17915. t['guillemotleft'] = 556;
  17916. t['guilsinglleft'] = 333;
  17917. t['guilsinglright'] = 333;
  17918. t['fi'] = 611;
  17919. t['fl'] = 611;
  17920. t['endash'] = 556;
  17921. t['dagger'] = 556;
  17922. t['daggerdbl'] = 556;
  17923. t['periodcentered'] = 278;
  17924. t['paragraph'] = 556;
  17925. t['bullet'] = 350;
  17926. t['quotesinglbase'] = 278;
  17927. t['quotedblbase'] = 500;
  17928. t['quotedblright'] = 500;
  17929. t['guillemotright'] = 556;
  17930. t['ellipsis'] = 1000;
  17931. t['perthousand'] = 1000;
  17932. t['questiondown'] = 611;
  17933. t['grave'] = 333;
  17934. t['acute'] = 333;
  17935. t['circumflex'] = 333;
  17936. t['tilde'] = 333;
  17937. t['macron'] = 333;
  17938. t['breve'] = 333;
  17939. t['dotaccent'] = 333;
  17940. t['dieresis'] = 333;
  17941. t['ring'] = 333;
  17942. t['cedilla'] = 333;
  17943. t['hungarumlaut'] = 333;
  17944. t['ogonek'] = 333;
  17945. t['caron'] = 333;
  17946. t['emdash'] = 1000;
  17947. t['AE'] = 1000;
  17948. t['ordfeminine'] = 370;
  17949. t['Lslash'] = 611;
  17950. t['Oslash'] = 778;
  17951. t['OE'] = 1000;
  17952. t['ordmasculine'] = 365;
  17953. t['ae'] = 889;
  17954. t['dotlessi'] = 278;
  17955. t['lslash'] = 278;
  17956. t['oslash'] = 611;
  17957. t['oe'] = 944;
  17958. t['germandbls'] = 611;
  17959. t['Idieresis'] = 278;
  17960. t['eacute'] = 556;
  17961. t['abreve'] = 556;
  17962. t['uhungarumlaut'] = 611;
  17963. t['ecaron'] = 556;
  17964. t['Ydieresis'] = 667;
  17965. t['divide'] = 584;
  17966. t['Yacute'] = 667;
  17967. t['Acircumflex'] = 722;
  17968. t['aacute'] = 556;
  17969. t['Ucircumflex'] = 722;
  17970. t['yacute'] = 556;
  17971. t['scommaaccent'] = 556;
  17972. t['ecircumflex'] = 556;
  17973. t['Uring'] = 722;
  17974. t['Udieresis'] = 722;
  17975. t['aogonek'] = 556;
  17976. t['Uacute'] = 722;
  17977. t['uogonek'] = 611;
  17978. t['Edieresis'] = 667;
  17979. t['Dcroat'] = 722;
  17980. t['commaaccent'] = 250;
  17981. t['copyright'] = 737;
  17982. t['Emacron'] = 667;
  17983. t['ccaron'] = 556;
  17984. t['aring'] = 556;
  17985. t['Ncommaaccent'] = 722;
  17986. t['lacute'] = 278;
  17987. t['agrave'] = 556;
  17988. t['Tcommaaccent'] = 611;
  17989. t['Cacute'] = 722;
  17990. t['atilde'] = 556;
  17991. t['Edotaccent'] = 667;
  17992. t['scaron'] = 556;
  17993. t['scedilla'] = 556;
  17994. t['iacute'] = 278;
  17995. t['lozenge'] = 494;
  17996. t['Rcaron'] = 722;
  17997. t['Gcommaaccent'] = 778;
  17998. t['ucircumflex'] = 611;
  17999. t['acircumflex'] = 556;
  18000. t['Amacron'] = 722;
  18001. t['rcaron'] = 389;
  18002. t['ccedilla'] = 556;
  18003. t['Zdotaccent'] = 611;
  18004. t['Thorn'] = 667;
  18005. t['Omacron'] = 778;
  18006. t['Racute'] = 722;
  18007. t['Sacute'] = 667;
  18008. t['dcaron'] = 743;
  18009. t['Umacron'] = 722;
  18010. t['uring'] = 611;
  18011. t['threesuperior'] = 333;
  18012. t['Ograve'] = 778;
  18013. t['Agrave'] = 722;
  18014. t['Abreve'] = 722;
  18015. t['multiply'] = 584;
  18016. t['uacute'] = 611;
  18017. t['Tcaron'] = 611;
  18018. t['partialdiff'] = 494;
  18019. t['ydieresis'] = 556;
  18020. t['Nacute'] = 722;
  18021. t['icircumflex'] = 278;
  18022. t['Ecircumflex'] = 667;
  18023. t['adieresis'] = 556;
  18024. t['edieresis'] = 556;
  18025. t['cacute'] = 556;
  18026. t['nacute'] = 611;
  18027. t['umacron'] = 611;
  18028. t['Ncaron'] = 722;
  18029. t['Iacute'] = 278;
  18030. t['plusminus'] = 584;
  18031. t['brokenbar'] = 280;
  18032. t['registered'] = 737;
  18033. t['Gbreve'] = 778;
  18034. t['Idotaccent'] = 278;
  18035. t['summation'] = 600;
  18036. t['Egrave'] = 667;
  18037. t['racute'] = 389;
  18038. t['omacron'] = 611;
  18039. t['Zacute'] = 611;
  18040. t['Zcaron'] = 611;
  18041. t['greaterequal'] = 549;
  18042. t['Eth'] = 722;
  18043. t['Ccedilla'] = 722;
  18044. t['lcommaaccent'] = 278;
  18045. t['tcaron'] = 389;
  18046. t['eogonek'] = 556;
  18047. t['Uogonek'] = 722;
  18048. t['Aacute'] = 722;
  18049. t['Adieresis'] = 722;
  18050. t['egrave'] = 556;
  18051. t['zacute'] = 500;
  18052. t['iogonek'] = 278;
  18053. t['Oacute'] = 778;
  18054. t['oacute'] = 611;
  18055. t['amacron'] = 556;
  18056. t['sacute'] = 556;
  18057. t['idieresis'] = 278;
  18058. t['Ocircumflex'] = 778;
  18059. t['Ugrave'] = 722;
  18060. t['Delta'] = 612;
  18061. t['thorn'] = 611;
  18062. t['twosuperior'] = 333;
  18063. t['Odieresis'] = 778;
  18064. t['mu'] = 611;
  18065. t['igrave'] = 278;
  18066. t['ohungarumlaut'] = 611;
  18067. t['Eogonek'] = 667;
  18068. t['dcroat'] = 611;
  18069. t['threequarters'] = 834;
  18070. t['Scedilla'] = 667;
  18071. t['lcaron'] = 400;
  18072. t['Kcommaaccent'] = 722;
  18073. t['Lacute'] = 611;
  18074. t['trademark'] = 1000;
  18075. t['edotaccent'] = 556;
  18076. t['Igrave'] = 278;
  18077. t['Imacron'] = 278;
  18078. t['Lcaron'] = 611;
  18079. t['onehalf'] = 834;
  18080. t['lessequal'] = 549;
  18081. t['ocircumflex'] = 611;
  18082. t['ntilde'] = 611;
  18083. t['Uhungarumlaut'] = 722;
  18084. t['Eacute'] = 667;
  18085. t['emacron'] = 556;
  18086. t['gbreve'] = 611;
  18087. t['onequarter'] = 834;
  18088. t['Scaron'] = 667;
  18089. t['Scommaaccent'] = 667;
  18090. t['Ohungarumlaut'] = 778;
  18091. t['degree'] = 400;
  18092. t['ograve'] = 611;
  18093. t['Ccaron'] = 722;
  18094. t['ugrave'] = 611;
  18095. t['radical'] = 549;
  18096. t['Dcaron'] = 722;
  18097. t['rcommaaccent'] = 389;
  18098. t['Ntilde'] = 722;
  18099. t['otilde'] = 611;
  18100. t['Rcommaaccent'] = 722;
  18101. t['Lcommaaccent'] = 611;
  18102. t['Atilde'] = 722;
  18103. t['Aogonek'] = 722;
  18104. t['Aring'] = 722;
  18105. t['Otilde'] = 778;
  18106. t['zdotaccent'] = 500;
  18107. t['Ecaron'] = 667;
  18108. t['Iogonek'] = 278;
  18109. t['kcommaaccent'] = 556;
  18110. t['minus'] = 584;
  18111. t['Icircumflex'] = 278;
  18112. t['ncaron'] = 611;
  18113. t['tcommaaccent'] = 333;
  18114. t['logicalnot'] = 584;
  18115. t['odieresis'] = 611;
  18116. t['udieresis'] = 611;
  18117. t['notequal'] = 549;
  18118. t['gcommaaccent'] = 611;
  18119. t['eth'] = 611;
  18120. t['zcaron'] = 500;
  18121. t['ncommaaccent'] = 611;
  18122. t['onesuperior'] = 333;
  18123. t['imacron'] = 278;
  18124. t['Euro'] = 556;
  18125. });
  18126. t['Helvetica-Oblique'] = getLookupTableFactory(function (t) {
  18127. t['space'] = 278;
  18128. t['exclam'] = 278;
  18129. t['quotedbl'] = 355;
  18130. t['numbersign'] = 556;
  18131. t['dollar'] = 556;
  18132. t['percent'] = 889;
  18133. t['ampersand'] = 667;
  18134. t['quoteright'] = 222;
  18135. t['parenleft'] = 333;
  18136. t['parenright'] = 333;
  18137. t['asterisk'] = 389;
  18138. t['plus'] = 584;
  18139. t['comma'] = 278;
  18140. t['hyphen'] = 333;
  18141. t['period'] = 278;
  18142. t['slash'] = 278;
  18143. t['zero'] = 556;
  18144. t['one'] = 556;
  18145. t['two'] = 556;
  18146. t['three'] = 556;
  18147. t['four'] = 556;
  18148. t['five'] = 556;
  18149. t['six'] = 556;
  18150. t['seven'] = 556;
  18151. t['eight'] = 556;
  18152. t['nine'] = 556;
  18153. t['colon'] = 278;
  18154. t['semicolon'] = 278;
  18155. t['less'] = 584;
  18156. t['equal'] = 584;
  18157. t['greater'] = 584;
  18158. t['question'] = 556;
  18159. t['at'] = 1015;
  18160. t['A'] = 667;
  18161. t['B'] = 667;
  18162. t['C'] = 722;
  18163. t['D'] = 722;
  18164. t['E'] = 667;
  18165. t['F'] = 611;
  18166. t['G'] = 778;
  18167. t['H'] = 722;
  18168. t['I'] = 278;
  18169. t['J'] = 500;
  18170. t['K'] = 667;
  18171. t['L'] = 556;
  18172. t['M'] = 833;
  18173. t['N'] = 722;
  18174. t['O'] = 778;
  18175. t['P'] = 667;
  18176. t['Q'] = 778;
  18177. t['R'] = 722;
  18178. t['S'] = 667;
  18179. t['T'] = 611;
  18180. t['U'] = 722;
  18181. t['V'] = 667;
  18182. t['W'] = 944;
  18183. t['X'] = 667;
  18184. t['Y'] = 667;
  18185. t['Z'] = 611;
  18186. t['bracketleft'] = 278;
  18187. t['backslash'] = 278;
  18188. t['bracketright'] = 278;
  18189. t['asciicircum'] = 469;
  18190. t['underscore'] = 556;
  18191. t['quoteleft'] = 222;
  18192. t['a'] = 556;
  18193. t['b'] = 556;
  18194. t['c'] = 500;
  18195. t['d'] = 556;
  18196. t['e'] = 556;
  18197. t['f'] = 278;
  18198. t['g'] = 556;
  18199. t['h'] = 556;
  18200. t['i'] = 222;
  18201. t['j'] = 222;
  18202. t['k'] = 500;
  18203. t['l'] = 222;
  18204. t['m'] = 833;
  18205. t['n'] = 556;
  18206. t['o'] = 556;
  18207. t['p'] = 556;
  18208. t['q'] = 556;
  18209. t['r'] = 333;
  18210. t['s'] = 500;
  18211. t['t'] = 278;
  18212. t['u'] = 556;
  18213. t['v'] = 500;
  18214. t['w'] = 722;
  18215. t['x'] = 500;
  18216. t['y'] = 500;
  18217. t['z'] = 500;
  18218. t['braceleft'] = 334;
  18219. t['bar'] = 260;
  18220. t['braceright'] = 334;
  18221. t['asciitilde'] = 584;
  18222. t['exclamdown'] = 333;
  18223. t['cent'] = 556;
  18224. t['sterling'] = 556;
  18225. t['fraction'] = 167;
  18226. t['yen'] = 556;
  18227. t['florin'] = 556;
  18228. t['section'] = 556;
  18229. t['currency'] = 556;
  18230. t['quotesingle'] = 191;
  18231. t['quotedblleft'] = 333;
  18232. t['guillemotleft'] = 556;
  18233. t['guilsinglleft'] = 333;
  18234. t['guilsinglright'] = 333;
  18235. t['fi'] = 500;
  18236. t['fl'] = 500;
  18237. t['endash'] = 556;
  18238. t['dagger'] = 556;
  18239. t['daggerdbl'] = 556;
  18240. t['periodcentered'] = 278;
  18241. t['paragraph'] = 537;
  18242. t['bullet'] = 350;
  18243. t['quotesinglbase'] = 222;
  18244. t['quotedblbase'] = 333;
  18245. t['quotedblright'] = 333;
  18246. t['guillemotright'] = 556;
  18247. t['ellipsis'] = 1000;
  18248. t['perthousand'] = 1000;
  18249. t['questiondown'] = 611;
  18250. t['grave'] = 333;
  18251. t['acute'] = 333;
  18252. t['circumflex'] = 333;
  18253. t['tilde'] = 333;
  18254. t['macron'] = 333;
  18255. t['breve'] = 333;
  18256. t['dotaccent'] = 333;
  18257. t['dieresis'] = 333;
  18258. t['ring'] = 333;
  18259. t['cedilla'] = 333;
  18260. t['hungarumlaut'] = 333;
  18261. t['ogonek'] = 333;
  18262. t['caron'] = 333;
  18263. t['emdash'] = 1000;
  18264. t['AE'] = 1000;
  18265. t['ordfeminine'] = 370;
  18266. t['Lslash'] = 556;
  18267. t['Oslash'] = 778;
  18268. t['OE'] = 1000;
  18269. t['ordmasculine'] = 365;
  18270. t['ae'] = 889;
  18271. t['dotlessi'] = 278;
  18272. t['lslash'] = 222;
  18273. t['oslash'] = 611;
  18274. t['oe'] = 944;
  18275. t['germandbls'] = 611;
  18276. t['Idieresis'] = 278;
  18277. t['eacute'] = 556;
  18278. t['abreve'] = 556;
  18279. t['uhungarumlaut'] = 556;
  18280. t['ecaron'] = 556;
  18281. t['Ydieresis'] = 667;
  18282. t['divide'] = 584;
  18283. t['Yacute'] = 667;
  18284. t['Acircumflex'] = 667;
  18285. t['aacute'] = 556;
  18286. t['Ucircumflex'] = 722;
  18287. t['yacute'] = 500;
  18288. t['scommaaccent'] = 500;
  18289. t['ecircumflex'] = 556;
  18290. t['Uring'] = 722;
  18291. t['Udieresis'] = 722;
  18292. t['aogonek'] = 556;
  18293. t['Uacute'] = 722;
  18294. t['uogonek'] = 556;
  18295. t['Edieresis'] = 667;
  18296. t['Dcroat'] = 722;
  18297. t['commaaccent'] = 250;
  18298. t['copyright'] = 737;
  18299. t['Emacron'] = 667;
  18300. t['ccaron'] = 500;
  18301. t['aring'] = 556;
  18302. t['Ncommaaccent'] = 722;
  18303. t['lacute'] = 222;
  18304. t['agrave'] = 556;
  18305. t['Tcommaaccent'] = 611;
  18306. t['Cacute'] = 722;
  18307. t['atilde'] = 556;
  18308. t['Edotaccent'] = 667;
  18309. t['scaron'] = 500;
  18310. t['scedilla'] = 500;
  18311. t['iacute'] = 278;
  18312. t['lozenge'] = 471;
  18313. t['Rcaron'] = 722;
  18314. t['Gcommaaccent'] = 778;
  18315. t['ucircumflex'] = 556;
  18316. t['acircumflex'] = 556;
  18317. t['Amacron'] = 667;
  18318. t['rcaron'] = 333;
  18319. t['ccedilla'] = 500;
  18320. t['Zdotaccent'] = 611;
  18321. t['Thorn'] = 667;
  18322. t['Omacron'] = 778;
  18323. t['Racute'] = 722;
  18324. t['Sacute'] = 667;
  18325. t['dcaron'] = 643;
  18326. t['Umacron'] = 722;
  18327. t['uring'] = 556;
  18328. t['threesuperior'] = 333;
  18329. t['Ograve'] = 778;
  18330. t['Agrave'] = 667;
  18331. t['Abreve'] = 667;
  18332. t['multiply'] = 584;
  18333. t['uacute'] = 556;
  18334. t['Tcaron'] = 611;
  18335. t['partialdiff'] = 476;
  18336. t['ydieresis'] = 500;
  18337. t['Nacute'] = 722;
  18338. t['icircumflex'] = 278;
  18339. t['Ecircumflex'] = 667;
  18340. t['adieresis'] = 556;
  18341. t['edieresis'] = 556;
  18342. t['cacute'] = 500;
  18343. t['nacute'] = 556;
  18344. t['umacron'] = 556;
  18345. t['Ncaron'] = 722;
  18346. t['Iacute'] = 278;
  18347. t['plusminus'] = 584;
  18348. t['brokenbar'] = 260;
  18349. t['registered'] = 737;
  18350. t['Gbreve'] = 778;
  18351. t['Idotaccent'] = 278;
  18352. t['summation'] = 600;
  18353. t['Egrave'] = 667;
  18354. t['racute'] = 333;
  18355. t['omacron'] = 556;
  18356. t['Zacute'] = 611;
  18357. t['Zcaron'] = 611;
  18358. t['greaterequal'] = 549;
  18359. t['Eth'] = 722;
  18360. t['Ccedilla'] = 722;
  18361. t['lcommaaccent'] = 222;
  18362. t['tcaron'] = 317;
  18363. t['eogonek'] = 556;
  18364. t['Uogonek'] = 722;
  18365. t['Aacute'] = 667;
  18366. t['Adieresis'] = 667;
  18367. t['egrave'] = 556;
  18368. t['zacute'] = 500;
  18369. t['iogonek'] = 222;
  18370. t['Oacute'] = 778;
  18371. t['oacute'] = 556;
  18372. t['amacron'] = 556;
  18373. t['sacute'] = 500;
  18374. t['idieresis'] = 278;
  18375. t['Ocircumflex'] = 778;
  18376. t['Ugrave'] = 722;
  18377. t['Delta'] = 612;
  18378. t['thorn'] = 556;
  18379. t['twosuperior'] = 333;
  18380. t['Odieresis'] = 778;
  18381. t['mu'] = 556;
  18382. t['igrave'] = 278;
  18383. t['ohungarumlaut'] = 556;
  18384. t['Eogonek'] = 667;
  18385. t['dcroat'] = 556;
  18386. t['threequarters'] = 834;
  18387. t['Scedilla'] = 667;
  18388. t['lcaron'] = 299;
  18389. t['Kcommaaccent'] = 667;
  18390. t['Lacute'] = 556;
  18391. t['trademark'] = 1000;
  18392. t['edotaccent'] = 556;
  18393. t['Igrave'] = 278;
  18394. t['Imacron'] = 278;
  18395. t['Lcaron'] = 556;
  18396. t['onehalf'] = 834;
  18397. t['lessequal'] = 549;
  18398. t['ocircumflex'] = 556;
  18399. t['ntilde'] = 556;
  18400. t['Uhungarumlaut'] = 722;
  18401. t['Eacute'] = 667;
  18402. t['emacron'] = 556;
  18403. t['gbreve'] = 556;
  18404. t['onequarter'] = 834;
  18405. t['Scaron'] = 667;
  18406. t['Scommaaccent'] = 667;
  18407. t['Ohungarumlaut'] = 778;
  18408. t['degree'] = 400;
  18409. t['ograve'] = 556;
  18410. t['Ccaron'] = 722;
  18411. t['ugrave'] = 556;
  18412. t['radical'] = 453;
  18413. t['Dcaron'] = 722;
  18414. t['rcommaaccent'] = 333;
  18415. t['Ntilde'] = 722;
  18416. t['otilde'] = 556;
  18417. t['Rcommaaccent'] = 722;
  18418. t['Lcommaaccent'] = 556;
  18419. t['Atilde'] = 667;
  18420. t['Aogonek'] = 667;
  18421. t['Aring'] = 667;
  18422. t['Otilde'] = 778;
  18423. t['zdotaccent'] = 500;
  18424. t['Ecaron'] = 667;
  18425. t['Iogonek'] = 278;
  18426. t['kcommaaccent'] = 500;
  18427. t['minus'] = 584;
  18428. t['Icircumflex'] = 278;
  18429. t['ncaron'] = 556;
  18430. t['tcommaaccent'] = 278;
  18431. t['logicalnot'] = 584;
  18432. t['odieresis'] = 556;
  18433. t['udieresis'] = 556;
  18434. t['notequal'] = 549;
  18435. t['gcommaaccent'] = 556;
  18436. t['eth'] = 556;
  18437. t['zcaron'] = 500;
  18438. t['ncommaaccent'] = 556;
  18439. t['onesuperior'] = 333;
  18440. t['imacron'] = 278;
  18441. t['Euro'] = 556;
  18442. });
  18443. t['Symbol'] = getLookupTableFactory(function (t) {
  18444. t['space'] = 250;
  18445. t['exclam'] = 333;
  18446. t['universal'] = 713;
  18447. t['numbersign'] = 500;
  18448. t['existential'] = 549;
  18449. t['percent'] = 833;
  18450. t['ampersand'] = 778;
  18451. t['suchthat'] = 439;
  18452. t['parenleft'] = 333;
  18453. t['parenright'] = 333;
  18454. t['asteriskmath'] = 500;
  18455. t['plus'] = 549;
  18456. t['comma'] = 250;
  18457. t['minus'] = 549;
  18458. t['period'] = 250;
  18459. t['slash'] = 278;
  18460. t['zero'] = 500;
  18461. t['one'] = 500;
  18462. t['two'] = 500;
  18463. t['three'] = 500;
  18464. t['four'] = 500;
  18465. t['five'] = 500;
  18466. t['six'] = 500;
  18467. t['seven'] = 500;
  18468. t['eight'] = 500;
  18469. t['nine'] = 500;
  18470. t['colon'] = 278;
  18471. t['semicolon'] = 278;
  18472. t['less'] = 549;
  18473. t['equal'] = 549;
  18474. t['greater'] = 549;
  18475. t['question'] = 444;
  18476. t['congruent'] = 549;
  18477. t['Alpha'] = 722;
  18478. t['Beta'] = 667;
  18479. t['Chi'] = 722;
  18480. t['Delta'] = 612;
  18481. t['Epsilon'] = 611;
  18482. t['Phi'] = 763;
  18483. t['Gamma'] = 603;
  18484. t['Eta'] = 722;
  18485. t['Iota'] = 333;
  18486. t['theta1'] = 631;
  18487. t['Kappa'] = 722;
  18488. t['Lambda'] = 686;
  18489. t['Mu'] = 889;
  18490. t['Nu'] = 722;
  18491. t['Omicron'] = 722;
  18492. t['Pi'] = 768;
  18493. t['Theta'] = 741;
  18494. t['Rho'] = 556;
  18495. t['Sigma'] = 592;
  18496. t['Tau'] = 611;
  18497. t['Upsilon'] = 690;
  18498. t['sigma1'] = 439;
  18499. t['Omega'] = 768;
  18500. t['Xi'] = 645;
  18501. t['Psi'] = 795;
  18502. t['Zeta'] = 611;
  18503. t['bracketleft'] = 333;
  18504. t['therefore'] = 863;
  18505. t['bracketright'] = 333;
  18506. t['perpendicular'] = 658;
  18507. t['underscore'] = 500;
  18508. t['radicalex'] = 500;
  18509. t['alpha'] = 631;
  18510. t['beta'] = 549;
  18511. t['chi'] = 549;
  18512. t['delta'] = 494;
  18513. t['epsilon'] = 439;
  18514. t['phi'] = 521;
  18515. t['gamma'] = 411;
  18516. t['eta'] = 603;
  18517. t['iota'] = 329;
  18518. t['phi1'] = 603;
  18519. t['kappa'] = 549;
  18520. t['lambda'] = 549;
  18521. t['mu'] = 576;
  18522. t['nu'] = 521;
  18523. t['omicron'] = 549;
  18524. t['pi'] = 549;
  18525. t['theta'] = 521;
  18526. t['rho'] = 549;
  18527. t['sigma'] = 603;
  18528. t['tau'] = 439;
  18529. t['upsilon'] = 576;
  18530. t['omega1'] = 713;
  18531. t['omega'] = 686;
  18532. t['xi'] = 493;
  18533. t['psi'] = 686;
  18534. t['zeta'] = 494;
  18535. t['braceleft'] = 480;
  18536. t['bar'] = 200;
  18537. t['braceright'] = 480;
  18538. t['similar'] = 549;
  18539. t['Euro'] = 750;
  18540. t['Upsilon1'] = 620;
  18541. t['minute'] = 247;
  18542. t['lessequal'] = 549;
  18543. t['fraction'] = 167;
  18544. t['infinity'] = 713;
  18545. t['florin'] = 500;
  18546. t['club'] = 753;
  18547. t['diamond'] = 753;
  18548. t['heart'] = 753;
  18549. t['spade'] = 753;
  18550. t['arrowboth'] = 1042;
  18551. t['arrowleft'] = 987;
  18552. t['arrowup'] = 603;
  18553. t['arrowright'] = 987;
  18554. t['arrowdown'] = 603;
  18555. t['degree'] = 400;
  18556. t['plusminus'] = 549;
  18557. t['second'] = 411;
  18558. t['greaterequal'] = 549;
  18559. t['multiply'] = 549;
  18560. t['proportional'] = 713;
  18561. t['partialdiff'] = 494;
  18562. t['bullet'] = 460;
  18563. t['divide'] = 549;
  18564. t['notequal'] = 549;
  18565. t['equivalence'] = 549;
  18566. t['approxequal'] = 549;
  18567. t['ellipsis'] = 1000;
  18568. t['arrowvertex'] = 603;
  18569. t['arrowhorizex'] = 1000;
  18570. t['carriagereturn'] = 658;
  18571. t['aleph'] = 823;
  18572. t['Ifraktur'] = 686;
  18573. t['Rfraktur'] = 795;
  18574. t['weierstrass'] = 987;
  18575. t['circlemultiply'] = 768;
  18576. t['circleplus'] = 768;
  18577. t['emptyset'] = 823;
  18578. t['intersection'] = 768;
  18579. t['union'] = 768;
  18580. t['propersuperset'] = 713;
  18581. t['reflexsuperset'] = 713;
  18582. t['notsubset'] = 713;
  18583. t['propersubset'] = 713;
  18584. t['reflexsubset'] = 713;
  18585. t['element'] = 713;
  18586. t['notelement'] = 713;
  18587. t['angle'] = 768;
  18588. t['gradient'] = 713;
  18589. t['registerserif'] = 790;
  18590. t['copyrightserif'] = 790;
  18591. t['trademarkserif'] = 890;
  18592. t['product'] = 823;
  18593. t['radical'] = 549;
  18594. t['dotmath'] = 250;
  18595. t['logicalnot'] = 713;
  18596. t['logicaland'] = 603;
  18597. t['logicalor'] = 603;
  18598. t['arrowdblboth'] = 1042;
  18599. t['arrowdblleft'] = 987;
  18600. t['arrowdblup'] = 603;
  18601. t['arrowdblright'] = 987;
  18602. t['arrowdbldown'] = 603;
  18603. t['lozenge'] = 494;
  18604. t['angleleft'] = 329;
  18605. t['registersans'] = 790;
  18606. t['copyrightsans'] = 790;
  18607. t['trademarksans'] = 786;
  18608. t['summation'] = 713;
  18609. t['parenlefttp'] = 384;
  18610. t['parenleftex'] = 384;
  18611. t['parenleftbt'] = 384;
  18612. t['bracketlefttp'] = 384;
  18613. t['bracketleftex'] = 384;
  18614. t['bracketleftbt'] = 384;
  18615. t['bracelefttp'] = 494;
  18616. t['braceleftmid'] = 494;
  18617. t['braceleftbt'] = 494;
  18618. t['braceex'] = 494;
  18619. t['angleright'] = 329;
  18620. t['integral'] = 274;
  18621. t['integraltp'] = 686;
  18622. t['integralex'] = 686;
  18623. t['integralbt'] = 686;
  18624. t['parenrighttp'] = 384;
  18625. t['parenrightex'] = 384;
  18626. t['parenrightbt'] = 384;
  18627. t['bracketrighttp'] = 384;
  18628. t['bracketrightex'] = 384;
  18629. t['bracketrightbt'] = 384;
  18630. t['bracerighttp'] = 494;
  18631. t['bracerightmid'] = 494;
  18632. t['bracerightbt'] = 494;
  18633. t['apple'] = 790;
  18634. });
  18635. t['Times-Roman'] = getLookupTableFactory(function (t) {
  18636. t['space'] = 250;
  18637. t['exclam'] = 333;
  18638. t['quotedbl'] = 408;
  18639. t['numbersign'] = 500;
  18640. t['dollar'] = 500;
  18641. t['percent'] = 833;
  18642. t['ampersand'] = 778;
  18643. t['quoteright'] = 333;
  18644. t['parenleft'] = 333;
  18645. t['parenright'] = 333;
  18646. t['asterisk'] = 500;
  18647. t['plus'] = 564;
  18648. t['comma'] = 250;
  18649. t['hyphen'] = 333;
  18650. t['period'] = 250;
  18651. t['slash'] = 278;
  18652. t['zero'] = 500;
  18653. t['one'] = 500;
  18654. t['two'] = 500;
  18655. t['three'] = 500;
  18656. t['four'] = 500;
  18657. t['five'] = 500;
  18658. t['six'] = 500;
  18659. t['seven'] = 500;
  18660. t['eight'] = 500;
  18661. t['nine'] = 500;
  18662. t['colon'] = 278;
  18663. t['semicolon'] = 278;
  18664. t['less'] = 564;
  18665. t['equal'] = 564;
  18666. t['greater'] = 564;
  18667. t['question'] = 444;
  18668. t['at'] = 921;
  18669. t['A'] = 722;
  18670. t['B'] = 667;
  18671. t['C'] = 667;
  18672. t['D'] = 722;
  18673. t['E'] = 611;
  18674. t['F'] = 556;
  18675. t['G'] = 722;
  18676. t['H'] = 722;
  18677. t['I'] = 333;
  18678. t['J'] = 389;
  18679. t['K'] = 722;
  18680. t['L'] = 611;
  18681. t['M'] = 889;
  18682. t['N'] = 722;
  18683. t['O'] = 722;
  18684. t['P'] = 556;
  18685. t['Q'] = 722;
  18686. t['R'] = 667;
  18687. t['S'] = 556;
  18688. t['T'] = 611;
  18689. t['U'] = 722;
  18690. t['V'] = 722;
  18691. t['W'] = 944;
  18692. t['X'] = 722;
  18693. t['Y'] = 722;
  18694. t['Z'] = 611;
  18695. t['bracketleft'] = 333;
  18696. t['backslash'] = 278;
  18697. t['bracketright'] = 333;
  18698. t['asciicircum'] = 469;
  18699. t['underscore'] = 500;
  18700. t['quoteleft'] = 333;
  18701. t['a'] = 444;
  18702. t['b'] = 500;
  18703. t['c'] = 444;
  18704. t['d'] = 500;
  18705. t['e'] = 444;
  18706. t['f'] = 333;
  18707. t['g'] = 500;
  18708. t['h'] = 500;
  18709. t['i'] = 278;
  18710. t['j'] = 278;
  18711. t['k'] = 500;
  18712. t['l'] = 278;
  18713. t['m'] = 778;
  18714. t['n'] = 500;
  18715. t['o'] = 500;
  18716. t['p'] = 500;
  18717. t['q'] = 500;
  18718. t['r'] = 333;
  18719. t['s'] = 389;
  18720. t['t'] = 278;
  18721. t['u'] = 500;
  18722. t['v'] = 500;
  18723. t['w'] = 722;
  18724. t['x'] = 500;
  18725. t['y'] = 500;
  18726. t['z'] = 444;
  18727. t['braceleft'] = 480;
  18728. t['bar'] = 200;
  18729. t['braceright'] = 480;
  18730. t['asciitilde'] = 541;
  18731. t['exclamdown'] = 333;
  18732. t['cent'] = 500;
  18733. t['sterling'] = 500;
  18734. t['fraction'] = 167;
  18735. t['yen'] = 500;
  18736. t['florin'] = 500;
  18737. t['section'] = 500;
  18738. t['currency'] = 500;
  18739. t['quotesingle'] = 180;
  18740. t['quotedblleft'] = 444;
  18741. t['guillemotleft'] = 500;
  18742. t['guilsinglleft'] = 333;
  18743. t['guilsinglright'] = 333;
  18744. t['fi'] = 556;
  18745. t['fl'] = 556;
  18746. t['endash'] = 500;
  18747. t['dagger'] = 500;
  18748. t['daggerdbl'] = 500;
  18749. t['periodcentered'] = 250;
  18750. t['paragraph'] = 453;
  18751. t['bullet'] = 350;
  18752. t['quotesinglbase'] = 333;
  18753. t['quotedblbase'] = 444;
  18754. t['quotedblright'] = 444;
  18755. t['guillemotright'] = 500;
  18756. t['ellipsis'] = 1000;
  18757. t['perthousand'] = 1000;
  18758. t['questiondown'] = 444;
  18759. t['grave'] = 333;
  18760. t['acute'] = 333;
  18761. t['circumflex'] = 333;
  18762. t['tilde'] = 333;
  18763. t['macron'] = 333;
  18764. t['breve'] = 333;
  18765. t['dotaccent'] = 333;
  18766. t['dieresis'] = 333;
  18767. t['ring'] = 333;
  18768. t['cedilla'] = 333;
  18769. t['hungarumlaut'] = 333;
  18770. t['ogonek'] = 333;
  18771. t['caron'] = 333;
  18772. t['emdash'] = 1000;
  18773. t['AE'] = 889;
  18774. t['ordfeminine'] = 276;
  18775. t['Lslash'] = 611;
  18776. t['Oslash'] = 722;
  18777. t['OE'] = 889;
  18778. t['ordmasculine'] = 310;
  18779. t['ae'] = 667;
  18780. t['dotlessi'] = 278;
  18781. t['lslash'] = 278;
  18782. t['oslash'] = 500;
  18783. t['oe'] = 722;
  18784. t['germandbls'] = 500;
  18785. t['Idieresis'] = 333;
  18786. t['eacute'] = 444;
  18787. t['abreve'] = 444;
  18788. t['uhungarumlaut'] = 500;
  18789. t['ecaron'] = 444;
  18790. t['Ydieresis'] = 722;
  18791. t['divide'] = 564;
  18792. t['Yacute'] = 722;
  18793. t['Acircumflex'] = 722;
  18794. t['aacute'] = 444;
  18795. t['Ucircumflex'] = 722;
  18796. t['yacute'] = 500;
  18797. t['scommaaccent'] = 389;
  18798. t['ecircumflex'] = 444;
  18799. t['Uring'] = 722;
  18800. t['Udieresis'] = 722;
  18801. t['aogonek'] = 444;
  18802. t['Uacute'] = 722;
  18803. t['uogonek'] = 500;
  18804. t['Edieresis'] = 611;
  18805. t['Dcroat'] = 722;
  18806. t['commaaccent'] = 250;
  18807. t['copyright'] = 760;
  18808. t['Emacron'] = 611;
  18809. t['ccaron'] = 444;
  18810. t['aring'] = 444;
  18811. t['Ncommaaccent'] = 722;
  18812. t['lacute'] = 278;
  18813. t['agrave'] = 444;
  18814. t['Tcommaaccent'] = 611;
  18815. t['Cacute'] = 667;
  18816. t['atilde'] = 444;
  18817. t['Edotaccent'] = 611;
  18818. t['scaron'] = 389;
  18819. t['scedilla'] = 389;
  18820. t['iacute'] = 278;
  18821. t['lozenge'] = 471;
  18822. t['Rcaron'] = 667;
  18823. t['Gcommaaccent'] = 722;
  18824. t['ucircumflex'] = 500;
  18825. t['acircumflex'] = 444;
  18826. t['Amacron'] = 722;
  18827. t['rcaron'] = 333;
  18828. t['ccedilla'] = 444;
  18829. t['Zdotaccent'] = 611;
  18830. t['Thorn'] = 556;
  18831. t['Omacron'] = 722;
  18832. t['Racute'] = 667;
  18833. t['Sacute'] = 556;
  18834. t['dcaron'] = 588;
  18835. t['Umacron'] = 722;
  18836. t['uring'] = 500;
  18837. t['threesuperior'] = 300;
  18838. t['Ograve'] = 722;
  18839. t['Agrave'] = 722;
  18840. t['Abreve'] = 722;
  18841. t['multiply'] = 564;
  18842. t['uacute'] = 500;
  18843. t['Tcaron'] = 611;
  18844. t['partialdiff'] = 476;
  18845. t['ydieresis'] = 500;
  18846. t['Nacute'] = 722;
  18847. t['icircumflex'] = 278;
  18848. t['Ecircumflex'] = 611;
  18849. t['adieresis'] = 444;
  18850. t['edieresis'] = 444;
  18851. t['cacute'] = 444;
  18852. t['nacute'] = 500;
  18853. t['umacron'] = 500;
  18854. t['Ncaron'] = 722;
  18855. t['Iacute'] = 333;
  18856. t['plusminus'] = 564;
  18857. t['brokenbar'] = 200;
  18858. t['registered'] = 760;
  18859. t['Gbreve'] = 722;
  18860. t['Idotaccent'] = 333;
  18861. t['summation'] = 600;
  18862. t['Egrave'] = 611;
  18863. t['racute'] = 333;
  18864. t['omacron'] = 500;
  18865. t['Zacute'] = 611;
  18866. t['Zcaron'] = 611;
  18867. t['greaterequal'] = 549;
  18868. t['Eth'] = 722;
  18869. t['Ccedilla'] = 667;
  18870. t['lcommaaccent'] = 278;
  18871. t['tcaron'] = 326;
  18872. t['eogonek'] = 444;
  18873. t['Uogonek'] = 722;
  18874. t['Aacute'] = 722;
  18875. t['Adieresis'] = 722;
  18876. t['egrave'] = 444;
  18877. t['zacute'] = 444;
  18878. t['iogonek'] = 278;
  18879. t['Oacute'] = 722;
  18880. t['oacute'] = 500;
  18881. t['amacron'] = 444;
  18882. t['sacute'] = 389;
  18883. t['idieresis'] = 278;
  18884. t['Ocircumflex'] = 722;
  18885. t['Ugrave'] = 722;
  18886. t['Delta'] = 612;
  18887. t['thorn'] = 500;
  18888. t['twosuperior'] = 300;
  18889. t['Odieresis'] = 722;
  18890. t['mu'] = 500;
  18891. t['igrave'] = 278;
  18892. t['ohungarumlaut'] = 500;
  18893. t['Eogonek'] = 611;
  18894. t['dcroat'] = 500;
  18895. t['threequarters'] = 750;
  18896. t['Scedilla'] = 556;
  18897. t['lcaron'] = 344;
  18898. t['Kcommaaccent'] = 722;
  18899. t['Lacute'] = 611;
  18900. t['trademark'] = 980;
  18901. t['edotaccent'] = 444;
  18902. t['Igrave'] = 333;
  18903. t['Imacron'] = 333;
  18904. t['Lcaron'] = 611;
  18905. t['onehalf'] = 750;
  18906. t['lessequal'] = 549;
  18907. t['ocircumflex'] = 500;
  18908. t['ntilde'] = 500;
  18909. t['Uhungarumlaut'] = 722;
  18910. t['Eacute'] = 611;
  18911. t['emacron'] = 444;
  18912. t['gbreve'] = 500;
  18913. t['onequarter'] = 750;
  18914. t['Scaron'] = 556;
  18915. t['Scommaaccent'] = 556;
  18916. t['Ohungarumlaut'] = 722;
  18917. t['degree'] = 400;
  18918. t['ograve'] = 500;
  18919. t['Ccaron'] = 667;
  18920. t['ugrave'] = 500;
  18921. t['radical'] = 453;
  18922. t['Dcaron'] = 722;
  18923. t['rcommaaccent'] = 333;
  18924. t['Ntilde'] = 722;
  18925. t['otilde'] = 500;
  18926. t['Rcommaaccent'] = 667;
  18927. t['Lcommaaccent'] = 611;
  18928. t['Atilde'] = 722;
  18929. t['Aogonek'] = 722;
  18930. t['Aring'] = 722;
  18931. t['Otilde'] = 722;
  18932. t['zdotaccent'] = 444;
  18933. t['Ecaron'] = 611;
  18934. t['Iogonek'] = 333;
  18935. t['kcommaaccent'] = 500;
  18936. t['minus'] = 564;
  18937. t['Icircumflex'] = 333;
  18938. t['ncaron'] = 500;
  18939. t['tcommaaccent'] = 278;
  18940. t['logicalnot'] = 564;
  18941. t['odieresis'] = 500;
  18942. t['udieresis'] = 500;
  18943. t['notequal'] = 549;
  18944. t['gcommaaccent'] = 500;
  18945. t['eth'] = 500;
  18946. t['zcaron'] = 444;
  18947. t['ncommaaccent'] = 500;
  18948. t['onesuperior'] = 300;
  18949. t['imacron'] = 278;
  18950. t['Euro'] = 500;
  18951. });
  18952. t['Times-Bold'] = getLookupTableFactory(function (t) {
  18953. t['space'] = 250;
  18954. t['exclam'] = 333;
  18955. t['quotedbl'] = 555;
  18956. t['numbersign'] = 500;
  18957. t['dollar'] = 500;
  18958. t['percent'] = 1000;
  18959. t['ampersand'] = 833;
  18960. t['quoteright'] = 333;
  18961. t['parenleft'] = 333;
  18962. t['parenright'] = 333;
  18963. t['asterisk'] = 500;
  18964. t['plus'] = 570;
  18965. t['comma'] = 250;
  18966. t['hyphen'] = 333;
  18967. t['period'] = 250;
  18968. t['slash'] = 278;
  18969. t['zero'] = 500;
  18970. t['one'] = 500;
  18971. t['two'] = 500;
  18972. t['three'] = 500;
  18973. t['four'] = 500;
  18974. t['five'] = 500;
  18975. t['six'] = 500;
  18976. t['seven'] = 500;
  18977. t['eight'] = 500;
  18978. t['nine'] = 500;
  18979. t['colon'] = 333;
  18980. t['semicolon'] = 333;
  18981. t['less'] = 570;
  18982. t['equal'] = 570;
  18983. t['greater'] = 570;
  18984. t['question'] = 500;
  18985. t['at'] = 930;
  18986. t['A'] = 722;
  18987. t['B'] = 667;
  18988. t['C'] = 722;
  18989. t['D'] = 722;
  18990. t['E'] = 667;
  18991. t['F'] = 611;
  18992. t['G'] = 778;
  18993. t['H'] = 778;
  18994. t['I'] = 389;
  18995. t['J'] = 500;
  18996. t['K'] = 778;
  18997. t['L'] = 667;
  18998. t['M'] = 944;
  18999. t['N'] = 722;
  19000. t['O'] = 778;
  19001. t['P'] = 611;
  19002. t['Q'] = 778;
  19003. t['R'] = 722;
  19004. t['S'] = 556;
  19005. t['T'] = 667;
  19006. t['U'] = 722;
  19007. t['V'] = 722;
  19008. t['W'] = 1000;
  19009. t['X'] = 722;
  19010. t['Y'] = 722;
  19011. t['Z'] = 667;
  19012. t['bracketleft'] = 333;
  19013. t['backslash'] = 278;
  19014. t['bracketright'] = 333;
  19015. t['asciicircum'] = 581;
  19016. t['underscore'] = 500;
  19017. t['quoteleft'] = 333;
  19018. t['a'] = 500;
  19019. t['b'] = 556;
  19020. t['c'] = 444;
  19021. t['d'] = 556;
  19022. t['e'] = 444;
  19023. t['f'] = 333;
  19024. t['g'] = 500;
  19025. t['h'] = 556;
  19026. t['i'] = 278;
  19027. t['j'] = 333;
  19028. t['k'] = 556;
  19029. t['l'] = 278;
  19030. t['m'] = 833;
  19031. t['n'] = 556;
  19032. t['o'] = 500;
  19033. t['p'] = 556;
  19034. t['q'] = 556;
  19035. t['r'] = 444;
  19036. t['s'] = 389;
  19037. t['t'] = 333;
  19038. t['u'] = 556;
  19039. t['v'] = 500;
  19040. t['w'] = 722;
  19041. t['x'] = 500;
  19042. t['y'] = 500;
  19043. t['z'] = 444;
  19044. t['braceleft'] = 394;
  19045. t['bar'] = 220;
  19046. t['braceright'] = 394;
  19047. t['asciitilde'] = 520;
  19048. t['exclamdown'] = 333;
  19049. t['cent'] = 500;
  19050. t['sterling'] = 500;
  19051. t['fraction'] = 167;
  19052. t['yen'] = 500;
  19053. t['florin'] = 500;
  19054. t['section'] = 500;
  19055. t['currency'] = 500;
  19056. t['quotesingle'] = 278;
  19057. t['quotedblleft'] = 500;
  19058. t['guillemotleft'] = 500;
  19059. t['guilsinglleft'] = 333;
  19060. t['guilsinglright'] = 333;
  19061. t['fi'] = 556;
  19062. t['fl'] = 556;
  19063. t['endash'] = 500;
  19064. t['dagger'] = 500;
  19065. t['daggerdbl'] = 500;
  19066. t['periodcentered'] = 250;
  19067. t['paragraph'] = 540;
  19068. t['bullet'] = 350;
  19069. t['quotesinglbase'] = 333;
  19070. t['quotedblbase'] = 500;
  19071. t['quotedblright'] = 500;
  19072. t['guillemotright'] = 500;
  19073. t['ellipsis'] = 1000;
  19074. t['perthousand'] = 1000;
  19075. t['questiondown'] = 500;
  19076. t['grave'] = 333;
  19077. t['acute'] = 333;
  19078. t['circumflex'] = 333;
  19079. t['tilde'] = 333;
  19080. t['macron'] = 333;
  19081. t['breve'] = 333;
  19082. t['dotaccent'] = 333;
  19083. t['dieresis'] = 333;
  19084. t['ring'] = 333;
  19085. t['cedilla'] = 333;
  19086. t['hungarumlaut'] = 333;
  19087. t['ogonek'] = 333;
  19088. t['caron'] = 333;
  19089. t['emdash'] = 1000;
  19090. t['AE'] = 1000;
  19091. t['ordfeminine'] = 300;
  19092. t['Lslash'] = 667;
  19093. t['Oslash'] = 778;
  19094. t['OE'] = 1000;
  19095. t['ordmasculine'] = 330;
  19096. t['ae'] = 722;
  19097. t['dotlessi'] = 278;
  19098. t['lslash'] = 278;
  19099. t['oslash'] = 500;
  19100. t['oe'] = 722;
  19101. t['germandbls'] = 556;
  19102. t['Idieresis'] = 389;
  19103. t['eacute'] = 444;
  19104. t['abreve'] = 500;
  19105. t['uhungarumlaut'] = 556;
  19106. t['ecaron'] = 444;
  19107. t['Ydieresis'] = 722;
  19108. t['divide'] = 570;
  19109. t['Yacute'] = 722;
  19110. t['Acircumflex'] = 722;
  19111. t['aacute'] = 500;
  19112. t['Ucircumflex'] = 722;
  19113. t['yacute'] = 500;
  19114. t['scommaaccent'] = 389;
  19115. t['ecircumflex'] = 444;
  19116. t['Uring'] = 722;
  19117. t['Udieresis'] = 722;
  19118. t['aogonek'] = 500;
  19119. t['Uacute'] = 722;
  19120. t['uogonek'] = 556;
  19121. t['Edieresis'] = 667;
  19122. t['Dcroat'] = 722;
  19123. t['commaaccent'] = 250;
  19124. t['copyright'] = 747;
  19125. t['Emacron'] = 667;
  19126. t['ccaron'] = 444;
  19127. t['aring'] = 500;
  19128. t['Ncommaaccent'] = 722;
  19129. t['lacute'] = 278;
  19130. t['agrave'] = 500;
  19131. t['Tcommaaccent'] = 667;
  19132. t['Cacute'] = 722;
  19133. t['atilde'] = 500;
  19134. t['Edotaccent'] = 667;
  19135. t['scaron'] = 389;
  19136. t['scedilla'] = 389;
  19137. t['iacute'] = 278;
  19138. t['lozenge'] = 494;
  19139. t['Rcaron'] = 722;
  19140. t['Gcommaaccent'] = 778;
  19141. t['ucircumflex'] = 556;
  19142. t['acircumflex'] = 500;
  19143. t['Amacron'] = 722;
  19144. t['rcaron'] = 444;
  19145. t['ccedilla'] = 444;
  19146. t['Zdotaccent'] = 667;
  19147. t['Thorn'] = 611;
  19148. t['Omacron'] = 778;
  19149. t['Racute'] = 722;
  19150. t['Sacute'] = 556;
  19151. t['dcaron'] = 672;
  19152. t['Umacron'] = 722;
  19153. t['uring'] = 556;
  19154. t['threesuperior'] = 300;
  19155. t['Ograve'] = 778;
  19156. t['Agrave'] = 722;
  19157. t['Abreve'] = 722;
  19158. t['multiply'] = 570;
  19159. t['uacute'] = 556;
  19160. t['Tcaron'] = 667;
  19161. t['partialdiff'] = 494;
  19162. t['ydieresis'] = 500;
  19163. t['Nacute'] = 722;
  19164. t['icircumflex'] = 278;
  19165. t['Ecircumflex'] = 667;
  19166. t['adieresis'] = 500;
  19167. t['edieresis'] = 444;
  19168. t['cacute'] = 444;
  19169. t['nacute'] = 556;
  19170. t['umacron'] = 556;
  19171. t['Ncaron'] = 722;
  19172. t['Iacute'] = 389;
  19173. t['plusminus'] = 570;
  19174. t['brokenbar'] = 220;
  19175. t['registered'] = 747;
  19176. t['Gbreve'] = 778;
  19177. t['Idotaccent'] = 389;
  19178. t['summation'] = 600;
  19179. t['Egrave'] = 667;
  19180. t['racute'] = 444;
  19181. t['omacron'] = 500;
  19182. t['Zacute'] = 667;
  19183. t['Zcaron'] = 667;
  19184. t['greaterequal'] = 549;
  19185. t['Eth'] = 722;
  19186. t['Ccedilla'] = 722;
  19187. t['lcommaaccent'] = 278;
  19188. t['tcaron'] = 416;
  19189. t['eogonek'] = 444;
  19190. t['Uogonek'] = 722;
  19191. t['Aacute'] = 722;
  19192. t['Adieresis'] = 722;
  19193. t['egrave'] = 444;
  19194. t['zacute'] = 444;
  19195. t['iogonek'] = 278;
  19196. t['Oacute'] = 778;
  19197. t['oacute'] = 500;
  19198. t['amacron'] = 500;
  19199. t['sacute'] = 389;
  19200. t['idieresis'] = 278;
  19201. t['Ocircumflex'] = 778;
  19202. t['Ugrave'] = 722;
  19203. t['Delta'] = 612;
  19204. t['thorn'] = 556;
  19205. t['twosuperior'] = 300;
  19206. t['Odieresis'] = 778;
  19207. t['mu'] = 556;
  19208. t['igrave'] = 278;
  19209. t['ohungarumlaut'] = 500;
  19210. t['Eogonek'] = 667;
  19211. t['dcroat'] = 556;
  19212. t['threequarters'] = 750;
  19213. t['Scedilla'] = 556;
  19214. t['lcaron'] = 394;
  19215. t['Kcommaaccent'] = 778;
  19216. t['Lacute'] = 667;
  19217. t['trademark'] = 1000;
  19218. t['edotaccent'] = 444;
  19219. t['Igrave'] = 389;
  19220. t['Imacron'] = 389;
  19221. t['Lcaron'] = 667;
  19222. t['onehalf'] = 750;
  19223. t['lessequal'] = 549;
  19224. t['ocircumflex'] = 500;
  19225. t['ntilde'] = 556;
  19226. t['Uhungarumlaut'] = 722;
  19227. t['Eacute'] = 667;
  19228. t['emacron'] = 444;
  19229. t['gbreve'] = 500;
  19230. t['onequarter'] = 750;
  19231. t['Scaron'] = 556;
  19232. t['Scommaaccent'] = 556;
  19233. t['Ohungarumlaut'] = 778;
  19234. t['degree'] = 400;
  19235. t['ograve'] = 500;
  19236. t['Ccaron'] = 722;
  19237. t['ugrave'] = 556;
  19238. t['radical'] = 549;
  19239. t['Dcaron'] = 722;
  19240. t['rcommaaccent'] = 444;
  19241. t['Ntilde'] = 722;
  19242. t['otilde'] = 500;
  19243. t['Rcommaaccent'] = 722;
  19244. t['Lcommaaccent'] = 667;
  19245. t['Atilde'] = 722;
  19246. t['Aogonek'] = 722;
  19247. t['Aring'] = 722;
  19248. t['Otilde'] = 778;
  19249. t['zdotaccent'] = 444;
  19250. t['Ecaron'] = 667;
  19251. t['Iogonek'] = 389;
  19252. t['kcommaaccent'] = 556;
  19253. t['minus'] = 570;
  19254. t['Icircumflex'] = 389;
  19255. t['ncaron'] = 556;
  19256. t['tcommaaccent'] = 333;
  19257. t['logicalnot'] = 570;
  19258. t['odieresis'] = 500;
  19259. t['udieresis'] = 556;
  19260. t['notequal'] = 549;
  19261. t['gcommaaccent'] = 500;
  19262. t['eth'] = 500;
  19263. t['zcaron'] = 444;
  19264. t['ncommaaccent'] = 556;
  19265. t['onesuperior'] = 300;
  19266. t['imacron'] = 278;
  19267. t['Euro'] = 500;
  19268. });
  19269. t['Times-BoldItalic'] = getLookupTableFactory(function (t) {
  19270. t['space'] = 250;
  19271. t['exclam'] = 389;
  19272. t['quotedbl'] = 555;
  19273. t['numbersign'] = 500;
  19274. t['dollar'] = 500;
  19275. t['percent'] = 833;
  19276. t['ampersand'] = 778;
  19277. t['quoteright'] = 333;
  19278. t['parenleft'] = 333;
  19279. t['parenright'] = 333;
  19280. t['asterisk'] = 500;
  19281. t['plus'] = 570;
  19282. t['comma'] = 250;
  19283. t['hyphen'] = 333;
  19284. t['period'] = 250;
  19285. t['slash'] = 278;
  19286. t['zero'] = 500;
  19287. t['one'] = 500;
  19288. t['two'] = 500;
  19289. t['three'] = 500;
  19290. t['four'] = 500;
  19291. t['five'] = 500;
  19292. t['six'] = 500;
  19293. t['seven'] = 500;
  19294. t['eight'] = 500;
  19295. t['nine'] = 500;
  19296. t['colon'] = 333;
  19297. t['semicolon'] = 333;
  19298. t['less'] = 570;
  19299. t['equal'] = 570;
  19300. t['greater'] = 570;
  19301. t['question'] = 500;
  19302. t['at'] = 832;
  19303. t['A'] = 667;
  19304. t['B'] = 667;
  19305. t['C'] = 667;
  19306. t['D'] = 722;
  19307. t['E'] = 667;
  19308. t['F'] = 667;
  19309. t['G'] = 722;
  19310. t['H'] = 778;
  19311. t['I'] = 389;
  19312. t['J'] = 500;
  19313. t['K'] = 667;
  19314. t['L'] = 611;
  19315. t['M'] = 889;
  19316. t['N'] = 722;
  19317. t['O'] = 722;
  19318. t['P'] = 611;
  19319. t['Q'] = 722;
  19320. t['R'] = 667;
  19321. t['S'] = 556;
  19322. t['T'] = 611;
  19323. t['U'] = 722;
  19324. t['V'] = 667;
  19325. t['W'] = 889;
  19326. t['X'] = 667;
  19327. t['Y'] = 611;
  19328. t['Z'] = 611;
  19329. t['bracketleft'] = 333;
  19330. t['backslash'] = 278;
  19331. t['bracketright'] = 333;
  19332. t['asciicircum'] = 570;
  19333. t['underscore'] = 500;
  19334. t['quoteleft'] = 333;
  19335. t['a'] = 500;
  19336. t['b'] = 500;
  19337. t['c'] = 444;
  19338. t['d'] = 500;
  19339. t['e'] = 444;
  19340. t['f'] = 333;
  19341. t['g'] = 500;
  19342. t['h'] = 556;
  19343. t['i'] = 278;
  19344. t['j'] = 278;
  19345. t['k'] = 500;
  19346. t['l'] = 278;
  19347. t['m'] = 778;
  19348. t['n'] = 556;
  19349. t['o'] = 500;
  19350. t['p'] = 500;
  19351. t['q'] = 500;
  19352. t['r'] = 389;
  19353. t['s'] = 389;
  19354. t['t'] = 278;
  19355. t['u'] = 556;
  19356. t['v'] = 444;
  19357. t['w'] = 667;
  19358. t['x'] = 500;
  19359. t['y'] = 444;
  19360. t['z'] = 389;
  19361. t['braceleft'] = 348;
  19362. t['bar'] = 220;
  19363. t['braceright'] = 348;
  19364. t['asciitilde'] = 570;
  19365. t['exclamdown'] = 389;
  19366. t['cent'] = 500;
  19367. t['sterling'] = 500;
  19368. t['fraction'] = 167;
  19369. t['yen'] = 500;
  19370. t['florin'] = 500;
  19371. t['section'] = 500;
  19372. t['currency'] = 500;
  19373. t['quotesingle'] = 278;
  19374. t['quotedblleft'] = 500;
  19375. t['guillemotleft'] = 500;
  19376. t['guilsinglleft'] = 333;
  19377. t['guilsinglright'] = 333;
  19378. t['fi'] = 556;
  19379. t['fl'] = 556;
  19380. t['endash'] = 500;
  19381. t['dagger'] = 500;
  19382. t['daggerdbl'] = 500;
  19383. t['periodcentered'] = 250;
  19384. t['paragraph'] = 500;
  19385. t['bullet'] = 350;
  19386. t['quotesinglbase'] = 333;
  19387. t['quotedblbase'] = 500;
  19388. t['quotedblright'] = 500;
  19389. t['guillemotright'] = 500;
  19390. t['ellipsis'] = 1000;
  19391. t['perthousand'] = 1000;
  19392. t['questiondown'] = 500;
  19393. t['grave'] = 333;
  19394. t['acute'] = 333;
  19395. t['circumflex'] = 333;
  19396. t['tilde'] = 333;
  19397. t['macron'] = 333;
  19398. t['breve'] = 333;
  19399. t['dotaccent'] = 333;
  19400. t['dieresis'] = 333;
  19401. t['ring'] = 333;
  19402. t['cedilla'] = 333;
  19403. t['hungarumlaut'] = 333;
  19404. t['ogonek'] = 333;
  19405. t['caron'] = 333;
  19406. t['emdash'] = 1000;
  19407. t['AE'] = 944;
  19408. t['ordfeminine'] = 266;
  19409. t['Lslash'] = 611;
  19410. t['Oslash'] = 722;
  19411. t['OE'] = 944;
  19412. t['ordmasculine'] = 300;
  19413. t['ae'] = 722;
  19414. t['dotlessi'] = 278;
  19415. t['lslash'] = 278;
  19416. t['oslash'] = 500;
  19417. t['oe'] = 722;
  19418. t['germandbls'] = 500;
  19419. t['Idieresis'] = 389;
  19420. t['eacute'] = 444;
  19421. t['abreve'] = 500;
  19422. t['uhungarumlaut'] = 556;
  19423. t['ecaron'] = 444;
  19424. t['Ydieresis'] = 611;
  19425. t['divide'] = 570;
  19426. t['Yacute'] = 611;
  19427. t['Acircumflex'] = 667;
  19428. t['aacute'] = 500;
  19429. t['Ucircumflex'] = 722;
  19430. t['yacute'] = 444;
  19431. t['scommaaccent'] = 389;
  19432. t['ecircumflex'] = 444;
  19433. t['Uring'] = 722;
  19434. t['Udieresis'] = 722;
  19435. t['aogonek'] = 500;
  19436. t['Uacute'] = 722;
  19437. t['uogonek'] = 556;
  19438. t['Edieresis'] = 667;
  19439. t['Dcroat'] = 722;
  19440. t['commaaccent'] = 250;
  19441. t['copyright'] = 747;
  19442. t['Emacron'] = 667;
  19443. t['ccaron'] = 444;
  19444. t['aring'] = 500;
  19445. t['Ncommaaccent'] = 722;
  19446. t['lacute'] = 278;
  19447. t['agrave'] = 500;
  19448. t['Tcommaaccent'] = 611;
  19449. t['Cacute'] = 667;
  19450. t['atilde'] = 500;
  19451. t['Edotaccent'] = 667;
  19452. t['scaron'] = 389;
  19453. t['scedilla'] = 389;
  19454. t['iacute'] = 278;
  19455. t['lozenge'] = 494;
  19456. t['Rcaron'] = 667;
  19457. t['Gcommaaccent'] = 722;
  19458. t['ucircumflex'] = 556;
  19459. t['acircumflex'] = 500;
  19460. t['Amacron'] = 667;
  19461. t['rcaron'] = 389;
  19462. t['ccedilla'] = 444;
  19463. t['Zdotaccent'] = 611;
  19464. t['Thorn'] = 611;
  19465. t['Omacron'] = 722;
  19466. t['Racute'] = 667;
  19467. t['Sacute'] = 556;
  19468. t['dcaron'] = 608;
  19469. t['Umacron'] = 722;
  19470. t['uring'] = 556;
  19471. t['threesuperior'] = 300;
  19472. t['Ograve'] = 722;
  19473. t['Agrave'] = 667;
  19474. t['Abreve'] = 667;
  19475. t['multiply'] = 570;
  19476. t['uacute'] = 556;
  19477. t['Tcaron'] = 611;
  19478. t['partialdiff'] = 494;
  19479. t['ydieresis'] = 444;
  19480. t['Nacute'] = 722;
  19481. t['icircumflex'] = 278;
  19482. t['Ecircumflex'] = 667;
  19483. t['adieresis'] = 500;
  19484. t['edieresis'] = 444;
  19485. t['cacute'] = 444;
  19486. t['nacute'] = 556;
  19487. t['umacron'] = 556;
  19488. t['Ncaron'] = 722;
  19489. t['Iacute'] = 389;
  19490. t['plusminus'] = 570;
  19491. t['brokenbar'] = 220;
  19492. t['registered'] = 747;
  19493. t['Gbreve'] = 722;
  19494. t['Idotaccent'] = 389;
  19495. t['summation'] = 600;
  19496. t['Egrave'] = 667;
  19497. t['racute'] = 389;
  19498. t['omacron'] = 500;
  19499. t['Zacute'] = 611;
  19500. t['Zcaron'] = 611;
  19501. t['greaterequal'] = 549;
  19502. t['Eth'] = 722;
  19503. t['Ccedilla'] = 667;
  19504. t['lcommaaccent'] = 278;
  19505. t['tcaron'] = 366;
  19506. t['eogonek'] = 444;
  19507. t['Uogonek'] = 722;
  19508. t['Aacute'] = 667;
  19509. t['Adieresis'] = 667;
  19510. t['egrave'] = 444;
  19511. t['zacute'] = 389;
  19512. t['iogonek'] = 278;
  19513. t['Oacute'] = 722;
  19514. t['oacute'] = 500;
  19515. t['amacron'] = 500;
  19516. t['sacute'] = 389;
  19517. t['idieresis'] = 278;
  19518. t['Ocircumflex'] = 722;
  19519. t['Ugrave'] = 722;
  19520. t['Delta'] = 612;
  19521. t['thorn'] = 500;
  19522. t['twosuperior'] = 300;
  19523. t['Odieresis'] = 722;
  19524. t['mu'] = 576;
  19525. t['igrave'] = 278;
  19526. t['ohungarumlaut'] = 500;
  19527. t['Eogonek'] = 667;
  19528. t['dcroat'] = 500;
  19529. t['threequarters'] = 750;
  19530. t['Scedilla'] = 556;
  19531. t['lcaron'] = 382;
  19532. t['Kcommaaccent'] = 667;
  19533. t['Lacute'] = 611;
  19534. t['trademark'] = 1000;
  19535. t['edotaccent'] = 444;
  19536. t['Igrave'] = 389;
  19537. t['Imacron'] = 389;
  19538. t['Lcaron'] = 611;
  19539. t['onehalf'] = 750;
  19540. t['lessequal'] = 549;
  19541. t['ocircumflex'] = 500;
  19542. t['ntilde'] = 556;
  19543. t['Uhungarumlaut'] = 722;
  19544. t['Eacute'] = 667;
  19545. t['emacron'] = 444;
  19546. t['gbreve'] = 500;
  19547. t['onequarter'] = 750;
  19548. t['Scaron'] = 556;
  19549. t['Scommaaccent'] = 556;
  19550. t['Ohungarumlaut'] = 722;
  19551. t['degree'] = 400;
  19552. t['ograve'] = 500;
  19553. t['Ccaron'] = 667;
  19554. t['ugrave'] = 556;
  19555. t['radical'] = 549;
  19556. t['Dcaron'] = 722;
  19557. t['rcommaaccent'] = 389;
  19558. t['Ntilde'] = 722;
  19559. t['otilde'] = 500;
  19560. t['Rcommaaccent'] = 667;
  19561. t['Lcommaaccent'] = 611;
  19562. t['Atilde'] = 667;
  19563. t['Aogonek'] = 667;
  19564. t['Aring'] = 667;
  19565. t['Otilde'] = 722;
  19566. t['zdotaccent'] = 389;
  19567. t['Ecaron'] = 667;
  19568. t['Iogonek'] = 389;
  19569. t['kcommaaccent'] = 500;
  19570. t['minus'] = 606;
  19571. t['Icircumflex'] = 389;
  19572. t['ncaron'] = 556;
  19573. t['tcommaaccent'] = 278;
  19574. t['logicalnot'] = 606;
  19575. t['odieresis'] = 500;
  19576. t['udieresis'] = 556;
  19577. t['notequal'] = 549;
  19578. t['gcommaaccent'] = 500;
  19579. t['eth'] = 500;
  19580. t['zcaron'] = 389;
  19581. t['ncommaaccent'] = 556;
  19582. t['onesuperior'] = 300;
  19583. t['imacron'] = 278;
  19584. t['Euro'] = 500;
  19585. });
  19586. t['Times-Italic'] = getLookupTableFactory(function (t) {
  19587. t['space'] = 250;
  19588. t['exclam'] = 333;
  19589. t['quotedbl'] = 420;
  19590. t['numbersign'] = 500;
  19591. t['dollar'] = 500;
  19592. t['percent'] = 833;
  19593. t['ampersand'] = 778;
  19594. t['quoteright'] = 333;
  19595. t['parenleft'] = 333;
  19596. t['parenright'] = 333;
  19597. t['asterisk'] = 500;
  19598. t['plus'] = 675;
  19599. t['comma'] = 250;
  19600. t['hyphen'] = 333;
  19601. t['period'] = 250;
  19602. t['slash'] = 278;
  19603. t['zero'] = 500;
  19604. t['one'] = 500;
  19605. t['two'] = 500;
  19606. t['three'] = 500;
  19607. t['four'] = 500;
  19608. t['five'] = 500;
  19609. t['six'] = 500;
  19610. t['seven'] = 500;
  19611. t['eight'] = 500;
  19612. t['nine'] = 500;
  19613. t['colon'] = 333;
  19614. t['semicolon'] = 333;
  19615. t['less'] = 675;
  19616. t['equal'] = 675;
  19617. t['greater'] = 675;
  19618. t['question'] = 500;
  19619. t['at'] = 920;
  19620. t['A'] = 611;
  19621. t['B'] = 611;
  19622. t['C'] = 667;
  19623. t['D'] = 722;
  19624. t['E'] = 611;
  19625. t['F'] = 611;
  19626. t['G'] = 722;
  19627. t['H'] = 722;
  19628. t['I'] = 333;
  19629. t['J'] = 444;
  19630. t['K'] = 667;
  19631. t['L'] = 556;
  19632. t['M'] = 833;
  19633. t['N'] = 667;
  19634. t['O'] = 722;
  19635. t['P'] = 611;
  19636. t['Q'] = 722;
  19637. t['R'] = 611;
  19638. t['S'] = 500;
  19639. t['T'] = 556;
  19640. t['U'] = 722;
  19641. t['V'] = 611;
  19642. t['W'] = 833;
  19643. t['X'] = 611;
  19644. t['Y'] = 556;
  19645. t['Z'] = 556;
  19646. t['bracketleft'] = 389;
  19647. t['backslash'] = 278;
  19648. t['bracketright'] = 389;
  19649. t['asciicircum'] = 422;
  19650. t['underscore'] = 500;
  19651. t['quoteleft'] = 333;
  19652. t['a'] = 500;
  19653. t['b'] = 500;
  19654. t['c'] = 444;
  19655. t['d'] = 500;
  19656. t['e'] = 444;
  19657. t['f'] = 278;
  19658. t['g'] = 500;
  19659. t['h'] = 500;
  19660. t['i'] = 278;
  19661. t['j'] = 278;
  19662. t['k'] = 444;
  19663. t['l'] = 278;
  19664. t['m'] = 722;
  19665. t['n'] = 500;
  19666. t['o'] = 500;
  19667. t['p'] = 500;
  19668. t['q'] = 500;
  19669. t['r'] = 389;
  19670. t['s'] = 389;
  19671. t['t'] = 278;
  19672. t['u'] = 500;
  19673. t['v'] = 444;
  19674. t['w'] = 667;
  19675. t['x'] = 444;
  19676. t['y'] = 444;
  19677. t['z'] = 389;
  19678. t['braceleft'] = 400;
  19679. t['bar'] = 275;
  19680. t['braceright'] = 400;
  19681. t['asciitilde'] = 541;
  19682. t['exclamdown'] = 389;
  19683. t['cent'] = 500;
  19684. t['sterling'] = 500;
  19685. t['fraction'] = 167;
  19686. t['yen'] = 500;
  19687. t['florin'] = 500;
  19688. t['section'] = 500;
  19689. t['currency'] = 500;
  19690. t['quotesingle'] = 214;
  19691. t['quotedblleft'] = 556;
  19692. t['guillemotleft'] = 500;
  19693. t['guilsinglleft'] = 333;
  19694. t['guilsinglright'] = 333;
  19695. t['fi'] = 500;
  19696. t['fl'] = 500;
  19697. t['endash'] = 500;
  19698. t['dagger'] = 500;
  19699. t['daggerdbl'] = 500;
  19700. t['periodcentered'] = 250;
  19701. t['paragraph'] = 523;
  19702. t['bullet'] = 350;
  19703. t['quotesinglbase'] = 333;
  19704. t['quotedblbase'] = 556;
  19705. t['quotedblright'] = 556;
  19706. t['guillemotright'] = 500;
  19707. t['ellipsis'] = 889;
  19708. t['perthousand'] = 1000;
  19709. t['questiondown'] = 500;
  19710. t['grave'] = 333;
  19711. t['acute'] = 333;
  19712. t['circumflex'] = 333;
  19713. t['tilde'] = 333;
  19714. t['macron'] = 333;
  19715. t['breve'] = 333;
  19716. t['dotaccent'] = 333;
  19717. t['dieresis'] = 333;
  19718. t['ring'] = 333;
  19719. t['cedilla'] = 333;
  19720. t['hungarumlaut'] = 333;
  19721. t['ogonek'] = 333;
  19722. t['caron'] = 333;
  19723. t['emdash'] = 889;
  19724. t['AE'] = 889;
  19725. t['ordfeminine'] = 276;
  19726. t['Lslash'] = 556;
  19727. t['Oslash'] = 722;
  19728. t['OE'] = 944;
  19729. t['ordmasculine'] = 310;
  19730. t['ae'] = 667;
  19731. t['dotlessi'] = 278;
  19732. t['lslash'] = 278;
  19733. t['oslash'] = 500;
  19734. t['oe'] = 667;
  19735. t['germandbls'] = 500;
  19736. t['Idieresis'] = 333;
  19737. t['eacute'] = 444;
  19738. t['abreve'] = 500;
  19739. t['uhungarumlaut'] = 500;
  19740. t['ecaron'] = 444;
  19741. t['Ydieresis'] = 556;
  19742. t['divide'] = 675;
  19743. t['Yacute'] = 556;
  19744. t['Acircumflex'] = 611;
  19745. t['aacute'] = 500;
  19746. t['Ucircumflex'] = 722;
  19747. t['yacute'] = 444;
  19748. t['scommaaccent'] = 389;
  19749. t['ecircumflex'] = 444;
  19750. t['Uring'] = 722;
  19751. t['Udieresis'] = 722;
  19752. t['aogonek'] = 500;
  19753. t['Uacute'] = 722;
  19754. t['uogonek'] = 500;
  19755. t['Edieresis'] = 611;
  19756. t['Dcroat'] = 722;
  19757. t['commaaccent'] = 250;
  19758. t['copyright'] = 760;
  19759. t['Emacron'] = 611;
  19760. t['ccaron'] = 444;
  19761. t['aring'] = 500;
  19762. t['Ncommaaccent'] = 667;
  19763. t['lacute'] = 278;
  19764. t['agrave'] = 500;
  19765. t['Tcommaaccent'] = 556;
  19766. t['Cacute'] = 667;
  19767. t['atilde'] = 500;
  19768. t['Edotaccent'] = 611;
  19769. t['scaron'] = 389;
  19770. t['scedilla'] = 389;
  19771. t['iacute'] = 278;
  19772. t['lozenge'] = 471;
  19773. t['Rcaron'] = 611;
  19774. t['Gcommaaccent'] = 722;
  19775. t['ucircumflex'] = 500;
  19776. t['acircumflex'] = 500;
  19777. t['Amacron'] = 611;
  19778. t['rcaron'] = 389;
  19779. t['ccedilla'] = 444;
  19780. t['Zdotaccent'] = 556;
  19781. t['Thorn'] = 611;
  19782. t['Omacron'] = 722;
  19783. t['Racute'] = 611;
  19784. t['Sacute'] = 500;
  19785. t['dcaron'] = 544;
  19786. t['Umacron'] = 722;
  19787. t['uring'] = 500;
  19788. t['threesuperior'] = 300;
  19789. t['Ograve'] = 722;
  19790. t['Agrave'] = 611;
  19791. t['Abreve'] = 611;
  19792. t['multiply'] = 675;
  19793. t['uacute'] = 500;
  19794. t['Tcaron'] = 556;
  19795. t['partialdiff'] = 476;
  19796. t['ydieresis'] = 444;
  19797. t['Nacute'] = 667;
  19798. t['icircumflex'] = 278;
  19799. t['Ecircumflex'] = 611;
  19800. t['adieresis'] = 500;
  19801. t['edieresis'] = 444;
  19802. t['cacute'] = 444;
  19803. t['nacute'] = 500;
  19804. t['umacron'] = 500;
  19805. t['Ncaron'] = 667;
  19806. t['Iacute'] = 333;
  19807. t['plusminus'] = 675;
  19808. t['brokenbar'] = 275;
  19809. t['registered'] = 760;
  19810. t['Gbreve'] = 722;
  19811. t['Idotaccent'] = 333;
  19812. t['summation'] = 600;
  19813. t['Egrave'] = 611;
  19814. t['racute'] = 389;
  19815. t['omacron'] = 500;
  19816. t['Zacute'] = 556;
  19817. t['Zcaron'] = 556;
  19818. t['greaterequal'] = 549;
  19819. t['Eth'] = 722;
  19820. t['Ccedilla'] = 667;
  19821. t['lcommaaccent'] = 278;
  19822. t['tcaron'] = 300;
  19823. t['eogonek'] = 444;
  19824. t['Uogonek'] = 722;
  19825. t['Aacute'] = 611;
  19826. t['Adieresis'] = 611;
  19827. t['egrave'] = 444;
  19828. t['zacute'] = 389;
  19829. t['iogonek'] = 278;
  19830. t['Oacute'] = 722;
  19831. t['oacute'] = 500;
  19832. t['amacron'] = 500;
  19833. t['sacute'] = 389;
  19834. t['idieresis'] = 278;
  19835. t['Ocircumflex'] = 722;
  19836. t['Ugrave'] = 722;
  19837. t['Delta'] = 612;
  19838. t['thorn'] = 500;
  19839. t['twosuperior'] = 300;
  19840. t['Odieresis'] = 722;
  19841. t['mu'] = 500;
  19842. t['igrave'] = 278;
  19843. t['ohungarumlaut'] = 500;
  19844. t['Eogonek'] = 611;
  19845. t['dcroat'] = 500;
  19846. t['threequarters'] = 750;
  19847. t['Scedilla'] = 500;
  19848. t['lcaron'] = 300;
  19849. t['Kcommaaccent'] = 667;
  19850. t['Lacute'] = 556;
  19851. t['trademark'] = 980;
  19852. t['edotaccent'] = 444;
  19853. t['Igrave'] = 333;
  19854. t['Imacron'] = 333;
  19855. t['Lcaron'] = 611;
  19856. t['onehalf'] = 750;
  19857. t['lessequal'] = 549;
  19858. t['ocircumflex'] = 500;
  19859. t['ntilde'] = 500;
  19860. t['Uhungarumlaut'] = 722;
  19861. t['Eacute'] = 611;
  19862. t['emacron'] = 444;
  19863. t['gbreve'] = 500;
  19864. t['onequarter'] = 750;
  19865. t['Scaron'] = 500;
  19866. t['Scommaaccent'] = 500;
  19867. t['Ohungarumlaut'] = 722;
  19868. t['degree'] = 400;
  19869. t['ograve'] = 500;
  19870. t['Ccaron'] = 667;
  19871. t['ugrave'] = 500;
  19872. t['radical'] = 453;
  19873. t['Dcaron'] = 722;
  19874. t['rcommaaccent'] = 389;
  19875. t['Ntilde'] = 667;
  19876. t['otilde'] = 500;
  19877. t['Rcommaaccent'] = 611;
  19878. t['Lcommaaccent'] = 556;
  19879. t['Atilde'] = 611;
  19880. t['Aogonek'] = 611;
  19881. t['Aring'] = 611;
  19882. t['Otilde'] = 722;
  19883. t['zdotaccent'] = 389;
  19884. t['Ecaron'] = 611;
  19885. t['Iogonek'] = 333;
  19886. t['kcommaaccent'] = 444;
  19887. t['minus'] = 675;
  19888. t['Icircumflex'] = 333;
  19889. t['ncaron'] = 500;
  19890. t['tcommaaccent'] = 278;
  19891. t['logicalnot'] = 675;
  19892. t['odieresis'] = 500;
  19893. t['udieresis'] = 500;
  19894. t['notequal'] = 549;
  19895. t['gcommaaccent'] = 500;
  19896. t['eth'] = 500;
  19897. t['zcaron'] = 389;
  19898. t['ncommaaccent'] = 500;
  19899. t['onesuperior'] = 300;
  19900. t['imacron'] = 278;
  19901. t['Euro'] = 500;
  19902. });
  19903. t['ZapfDingbats'] = getLookupTableFactory(function (t) {
  19904. t['space'] = 278;
  19905. t['a1'] = 974;
  19906. t['a2'] = 961;
  19907. t['a202'] = 974;
  19908. t['a3'] = 980;
  19909. t['a4'] = 719;
  19910. t['a5'] = 789;
  19911. t['a119'] = 790;
  19912. t['a118'] = 791;
  19913. t['a117'] = 690;
  19914. t['a11'] = 960;
  19915. t['a12'] = 939;
  19916. t['a13'] = 549;
  19917. t['a14'] = 855;
  19918. t['a15'] = 911;
  19919. t['a16'] = 933;
  19920. t['a105'] = 911;
  19921. t['a17'] = 945;
  19922. t['a18'] = 974;
  19923. t['a19'] = 755;
  19924. t['a20'] = 846;
  19925. t['a21'] = 762;
  19926. t['a22'] = 761;
  19927. t['a23'] = 571;
  19928. t['a24'] = 677;
  19929. t['a25'] = 763;
  19930. t['a26'] = 760;
  19931. t['a27'] = 759;
  19932. t['a28'] = 754;
  19933. t['a6'] = 494;
  19934. t['a7'] = 552;
  19935. t['a8'] = 537;
  19936. t['a9'] = 577;
  19937. t['a10'] = 692;
  19938. t['a29'] = 786;
  19939. t['a30'] = 788;
  19940. t['a31'] = 788;
  19941. t['a32'] = 790;
  19942. t['a33'] = 793;
  19943. t['a34'] = 794;
  19944. t['a35'] = 816;
  19945. t['a36'] = 823;
  19946. t['a37'] = 789;
  19947. t['a38'] = 841;
  19948. t['a39'] = 823;
  19949. t['a40'] = 833;
  19950. t['a41'] = 816;
  19951. t['a42'] = 831;
  19952. t['a43'] = 923;
  19953. t['a44'] = 744;
  19954. t['a45'] = 723;
  19955. t['a46'] = 749;
  19956. t['a47'] = 790;
  19957. t['a48'] = 792;
  19958. t['a49'] = 695;
  19959. t['a50'] = 776;
  19960. t['a51'] = 768;
  19961. t['a52'] = 792;
  19962. t['a53'] = 759;
  19963. t['a54'] = 707;
  19964. t['a55'] = 708;
  19965. t['a56'] = 682;
  19966. t['a57'] = 701;
  19967. t['a58'] = 826;
  19968. t['a59'] = 815;
  19969. t['a60'] = 789;
  19970. t['a61'] = 789;
  19971. t['a62'] = 707;
  19972. t['a63'] = 687;
  19973. t['a64'] = 696;
  19974. t['a65'] = 689;
  19975. t['a66'] = 786;
  19976. t['a67'] = 787;
  19977. t['a68'] = 713;
  19978. t['a69'] = 791;
  19979. t['a70'] = 785;
  19980. t['a71'] = 791;
  19981. t['a72'] = 873;
  19982. t['a73'] = 761;
  19983. t['a74'] = 762;
  19984. t['a203'] = 762;
  19985. t['a75'] = 759;
  19986. t['a204'] = 759;
  19987. t['a76'] = 892;
  19988. t['a77'] = 892;
  19989. t['a78'] = 788;
  19990. t['a79'] = 784;
  19991. t['a81'] = 438;
  19992. t['a82'] = 138;
  19993. t['a83'] = 277;
  19994. t['a84'] = 415;
  19995. t['a97'] = 392;
  19996. t['a98'] = 392;
  19997. t['a99'] = 668;
  19998. t['a100'] = 668;
  19999. t['a89'] = 390;
  20000. t['a90'] = 390;
  20001. t['a93'] = 317;
  20002. t['a94'] = 317;
  20003. t['a91'] = 276;
  20004. t['a92'] = 276;
  20005. t['a205'] = 509;
  20006. t['a85'] = 509;
  20007. t['a206'] = 410;
  20008. t['a86'] = 410;
  20009. t['a87'] = 234;
  20010. t['a88'] = 234;
  20011. t['a95'] = 334;
  20012. t['a96'] = 334;
  20013. t['a101'] = 732;
  20014. t['a102'] = 544;
  20015. t['a103'] = 544;
  20016. t['a104'] = 910;
  20017. t['a106'] = 667;
  20018. t['a107'] = 760;
  20019. t['a108'] = 760;
  20020. t['a112'] = 776;
  20021. t['a111'] = 595;
  20022. t['a110'] = 694;
  20023. t['a109'] = 626;
  20024. t['a120'] = 788;
  20025. t['a121'] = 788;
  20026. t['a122'] = 788;
  20027. t['a123'] = 788;
  20028. t['a124'] = 788;
  20029. t['a125'] = 788;
  20030. t['a126'] = 788;
  20031. t['a127'] = 788;
  20032. t['a128'] = 788;
  20033. t['a129'] = 788;
  20034. t['a130'] = 788;
  20035. t['a131'] = 788;
  20036. t['a132'] = 788;
  20037. t['a133'] = 788;
  20038. t['a134'] = 788;
  20039. t['a135'] = 788;
  20040. t['a136'] = 788;
  20041. t['a137'] = 788;
  20042. t['a138'] = 788;
  20043. t['a139'] = 788;
  20044. t['a140'] = 788;
  20045. t['a141'] = 788;
  20046. t['a142'] = 788;
  20047. t['a143'] = 788;
  20048. t['a144'] = 788;
  20049. t['a145'] = 788;
  20050. t['a146'] = 788;
  20051. t['a147'] = 788;
  20052. t['a148'] = 788;
  20053. t['a149'] = 788;
  20054. t['a150'] = 788;
  20055. t['a151'] = 788;
  20056. t['a152'] = 788;
  20057. t['a153'] = 788;
  20058. t['a154'] = 788;
  20059. t['a155'] = 788;
  20060. t['a156'] = 788;
  20061. t['a157'] = 788;
  20062. t['a158'] = 788;
  20063. t['a159'] = 788;
  20064. t['a160'] = 894;
  20065. t['a161'] = 838;
  20066. t['a163'] = 1016;
  20067. t['a164'] = 458;
  20068. t['a196'] = 748;
  20069. t['a165'] = 924;
  20070. t['a192'] = 748;
  20071. t['a166'] = 918;
  20072. t['a167'] = 927;
  20073. t['a168'] = 928;
  20074. t['a169'] = 928;
  20075. t['a170'] = 834;
  20076. t['a171'] = 873;
  20077. t['a172'] = 828;
  20078. t['a173'] = 924;
  20079. t['a162'] = 924;
  20080. t['a174'] = 917;
  20081. t['a175'] = 930;
  20082. t['a176'] = 931;
  20083. t['a177'] = 463;
  20084. t['a178'] = 883;
  20085. t['a179'] = 836;
  20086. t['a193'] = 836;
  20087. t['a180'] = 867;
  20088. t['a199'] = 867;
  20089. t['a181'] = 696;
  20090. t['a200'] = 696;
  20091. t['a182'] = 874;
  20092. t['a201'] = 874;
  20093. t['a183'] = 760;
  20094. t['a184'] = 946;
  20095. t['a197'] = 771;
  20096. t['a185'] = 865;
  20097. t['a194'] = 771;
  20098. t['a198'] = 888;
  20099. t['a186'] = 967;
  20100. t['a195'] = 888;
  20101. t['a187'] = 831;
  20102. t['a188'] = 873;
  20103. t['a189'] = 927;
  20104. t['a190'] = 970;
  20105. t['a191'] = 918;
  20106. });
  20107. });
  20108. exports.getMetrics = getMetrics;
  20109. }));
  20110. (function (root, factory) {
  20111. factory(root.pdfjsCoreMurmurHash3 = {}, root.pdfjsSharedUtil);
  20112. }(this, function (exports, sharedUtil) {
  20113. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  20114. var MurmurHash3_64 = function MurmurHash3_64Closure(seed) {
  20115. var MASK_HIGH = 0xffff0000;
  20116. var MASK_LOW = 0xffff;
  20117. function MurmurHash3_64(seed) {
  20118. var SEED = 0xc3d2e1f0;
  20119. this.h1 = seed ? seed & 0xffffffff : SEED;
  20120. this.h2 = seed ? seed & 0xffffffff : SEED;
  20121. }
  20122. var alwaysUseUint32ArrayView = false;
  20123. try {
  20124. new Uint32Array(new Uint8Array(5).buffer, 0, 1);
  20125. } catch (e) {
  20126. alwaysUseUint32ArrayView = true;
  20127. }
  20128. MurmurHash3_64.prototype = {
  20129. update: function MurmurHash3_64_update(input) {
  20130. var useUint32ArrayView = alwaysUseUint32ArrayView;
  20131. var i;
  20132. if (typeof input === 'string') {
  20133. var data = new Uint8Array(input.length * 2);
  20134. var length = 0;
  20135. for (i = 0; i < input.length; i++) {
  20136. var code = input.charCodeAt(i);
  20137. if (code <= 0xff) {
  20138. data[length++] = code;
  20139. } else {
  20140. data[length++] = code >>> 8;
  20141. data[length++] = code & 0xff;
  20142. }
  20143. }
  20144. } else if (input instanceof Uint8Array) {
  20145. data = input;
  20146. length = data.length;
  20147. } else if (typeof input === 'object' && 'length' in input) {
  20148. data = input;
  20149. length = data.length;
  20150. useUint32ArrayView = true;
  20151. } else {
  20152. throw new Error('Wrong data format in MurmurHash3_64_update. ' + 'Input must be a string or array.');
  20153. }
  20154. var blockCounts = length >> 2;
  20155. var tailLength = length - blockCounts * 4;
  20156. var dataUint32 = useUint32ArrayView ? new Uint32ArrayView(data, blockCounts) : new Uint32Array(data.buffer, 0, blockCounts);
  20157. var k1 = 0;
  20158. var k2 = 0;
  20159. var h1 = this.h1;
  20160. var h2 = this.h2;
  20161. var C1 = 0xcc9e2d51;
  20162. var C2 = 0x1b873593;
  20163. var C1_LOW = C1 & MASK_LOW;
  20164. var C2_LOW = C2 & MASK_LOW;
  20165. for (i = 0; i < blockCounts; i++) {
  20166. if (i & 1) {
  20167. k1 = dataUint32[i];
  20168. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20169. k1 = k1 << 15 | k1 >>> 17;
  20170. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20171. h1 ^= k1;
  20172. h1 = h1 << 13 | h1 >>> 19;
  20173. h1 = h1 * 5 + 0xe6546b64;
  20174. } else {
  20175. k2 = dataUint32[i];
  20176. k2 = k2 * C1 & MASK_HIGH | k2 * C1_LOW & MASK_LOW;
  20177. k2 = k2 << 15 | k2 >>> 17;
  20178. k2 = k2 * C2 & MASK_HIGH | k2 * C2_LOW & MASK_LOW;
  20179. h2 ^= k2;
  20180. h2 = h2 << 13 | h2 >>> 19;
  20181. h2 = h2 * 5 + 0xe6546b64;
  20182. }
  20183. }
  20184. k1 = 0;
  20185. switch (tailLength) {
  20186. case 3:
  20187. k1 ^= data[blockCounts * 4 + 2] << 16;
  20188. case 2:
  20189. k1 ^= data[blockCounts * 4 + 1] << 8;
  20190. case 1:
  20191. k1 ^= data[blockCounts * 4];
  20192. k1 = k1 * C1 & MASK_HIGH | k1 * C1_LOW & MASK_LOW;
  20193. k1 = k1 << 15 | k1 >>> 17;
  20194. k1 = k1 * C2 & MASK_HIGH | k1 * C2_LOW & MASK_LOW;
  20195. if (blockCounts & 1) {
  20196. h1 ^= k1;
  20197. } else {
  20198. h2 ^= k1;
  20199. }
  20200. }
  20201. this.h1 = h1;
  20202. this.h2 = h2;
  20203. return this;
  20204. },
  20205. hexdigest: function MurmurHash3_64_hexdigest() {
  20206. var h1 = this.h1;
  20207. var h2 = this.h2;
  20208. h1 ^= h2 >>> 1;
  20209. h1 = h1 * 0xed558ccd & MASK_HIGH | h1 * 0x8ccd & MASK_LOW;
  20210. h2 = h2 * 0xff51afd7 & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xafd7ed55 & MASK_HIGH) >>> 16;
  20211. h1 ^= h2 >>> 1;
  20212. h1 = h1 * 0x1a85ec53 & MASK_HIGH | h1 * 0xec53 & MASK_LOW;
  20213. h2 = h2 * 0xc4ceb9fe & MASK_HIGH | ((h2 << 16 | h1 >>> 16) * 0xb9fe1a85 & MASK_HIGH) >>> 16;
  20214. h1 ^= h2 >>> 1;
  20215. for (var i = 0, arr = [
  20216. h1,
  20217. h2
  20218. ], str = ''; i < arr.length; i++) {
  20219. var hex = (arr[i] >>> 0).toString(16);
  20220. while (hex.length < 8) {
  20221. hex = '0' + hex;
  20222. }
  20223. str += hex;
  20224. }
  20225. return str;
  20226. }
  20227. };
  20228. return MurmurHash3_64;
  20229. }();
  20230. exports.MurmurHash3_64 = MurmurHash3_64;
  20231. }));
  20232. (function (root, factory) {
  20233. factory(root.pdfjsCorePrimitives = {}, root.pdfjsSharedUtil);
  20234. }(this, function (exports, sharedUtil) {
  20235. var isArray = sharedUtil.isArray;
  20236. var Name = function NameClosure() {
  20237. function Name(name) {
  20238. this.name = name;
  20239. }
  20240. Name.prototype = {};
  20241. var nameCache = Object.create(null);
  20242. Name.get = function Name_get(name) {
  20243. var nameValue = nameCache[name];
  20244. return nameValue ? nameValue : nameCache[name] = new Name(name);
  20245. };
  20246. return Name;
  20247. }();
  20248. var Cmd = function CmdClosure() {
  20249. function Cmd(cmd) {
  20250. this.cmd = cmd;
  20251. }
  20252. Cmd.prototype = {};
  20253. var cmdCache = Object.create(null);
  20254. Cmd.get = function Cmd_get(cmd) {
  20255. var cmdValue = cmdCache[cmd];
  20256. return cmdValue ? cmdValue : cmdCache[cmd] = new Cmd(cmd);
  20257. };
  20258. return Cmd;
  20259. }();
  20260. var Dict = function DictClosure() {
  20261. var nonSerializable = function nonSerializableClosure() {
  20262. return nonSerializable;
  20263. };
  20264. function Dict(xref) {
  20265. this.map = Object.create(null);
  20266. this.xref = xref;
  20267. this.objId = null;
  20268. this.suppressEncryption = false;
  20269. this.__nonSerializable__ = nonSerializable;
  20270. }
  20271. Dict.prototype = {
  20272. assignXref: function Dict_assignXref(newXref) {
  20273. this.xref = newXref;
  20274. },
  20275. get: function Dict_get(key1, key2, key3) {
  20276. var value;
  20277. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20278. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20279. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20280. }
  20281. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20282. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20283. }
  20284. value = this.map[key3] || null;
  20285. return xref ? xref.fetchIfRef(value, suppressEncryption) : value;
  20286. },
  20287. getAsync: function Dict_getAsync(key1, key2, key3) {
  20288. var value;
  20289. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20290. if (typeof (value = this.map[key1]) !== 'undefined' || key1 in this.map || typeof key2 === 'undefined') {
  20291. if (xref) {
  20292. return xref.fetchIfRefAsync(value, suppressEncryption);
  20293. }
  20294. return Promise.resolve(value);
  20295. }
  20296. if (typeof (value = this.map[key2]) !== 'undefined' || key2 in this.map || typeof key3 === 'undefined') {
  20297. if (xref) {
  20298. return xref.fetchIfRefAsync(value, suppressEncryption);
  20299. }
  20300. return Promise.resolve(value);
  20301. }
  20302. value = this.map[key3] || null;
  20303. if (xref) {
  20304. return xref.fetchIfRefAsync(value, suppressEncryption);
  20305. }
  20306. return Promise.resolve(value);
  20307. },
  20308. getArray: function Dict_getArray(key1, key2, key3) {
  20309. var value = this.get(key1, key2, key3);
  20310. var xref = this.xref, suppressEncryption = this.suppressEncryption;
  20311. if (!isArray(value) || !xref) {
  20312. return value;
  20313. }
  20314. value = value.slice();
  20315. for (var i = 0, ii = value.length; i < ii; i++) {
  20316. if (!isRef(value[i])) {
  20317. continue;
  20318. }
  20319. value[i] = xref.fetch(value[i], suppressEncryption);
  20320. }
  20321. return value;
  20322. },
  20323. getRaw: function Dict_getRaw(key) {
  20324. return this.map[key];
  20325. },
  20326. getKeys: function Dict_getKeys() {
  20327. return Object.keys(this.map);
  20328. },
  20329. set: function Dict_set(key, value) {
  20330. this.map[key] = value;
  20331. },
  20332. has: function Dict_has(key) {
  20333. return key in this.map;
  20334. },
  20335. forEach: function Dict_forEach(callback) {
  20336. for (var key in this.map) {
  20337. callback(key, this.get(key));
  20338. }
  20339. }
  20340. };
  20341. Dict.empty = new Dict(null);
  20342. Dict.merge = function Dict_merge(xref, dictArray) {
  20343. var mergedDict = new Dict(xref);
  20344. for (var i = 0, ii = dictArray.length; i < ii; i++) {
  20345. var dict = dictArray[i];
  20346. if (!isDict(dict)) {
  20347. continue;
  20348. }
  20349. for (var keyName in dict.map) {
  20350. if (mergedDict.map[keyName]) {
  20351. continue;
  20352. }
  20353. mergedDict.map[keyName] = dict.map[keyName];
  20354. }
  20355. }
  20356. return mergedDict;
  20357. };
  20358. return Dict;
  20359. }();
  20360. var Ref = function RefClosure() {
  20361. function Ref(num, gen) {
  20362. this.num = num;
  20363. this.gen = gen;
  20364. }
  20365. Ref.prototype = {
  20366. toString: function Ref_toString() {
  20367. var str = this.num + 'R';
  20368. if (this.gen !== 0) {
  20369. str += this.gen;
  20370. }
  20371. return str;
  20372. }
  20373. };
  20374. return Ref;
  20375. }();
  20376. var RefSet = function RefSetClosure() {
  20377. function RefSet() {
  20378. this.dict = Object.create(null);
  20379. }
  20380. RefSet.prototype = {
  20381. has: function RefSet_has(ref) {
  20382. return ref.toString() in this.dict;
  20383. },
  20384. put: function RefSet_put(ref) {
  20385. this.dict[ref.toString()] = true;
  20386. },
  20387. remove: function RefSet_remove(ref) {
  20388. delete this.dict[ref.toString()];
  20389. }
  20390. };
  20391. return RefSet;
  20392. }();
  20393. var RefSetCache = function RefSetCacheClosure() {
  20394. function RefSetCache() {
  20395. this.dict = Object.create(null);
  20396. }
  20397. RefSetCache.prototype = {
  20398. get: function RefSetCache_get(ref) {
  20399. return this.dict[ref.toString()];
  20400. },
  20401. has: function RefSetCache_has(ref) {
  20402. return ref.toString() in this.dict;
  20403. },
  20404. put: function RefSetCache_put(ref, obj) {
  20405. this.dict[ref.toString()] = obj;
  20406. },
  20407. putAlias: function RefSetCache_putAlias(ref, aliasRef) {
  20408. this.dict[ref.toString()] = this.get(aliasRef);
  20409. },
  20410. forEach: function RefSetCache_forEach(fn, thisArg) {
  20411. for (var i in this.dict) {
  20412. fn.call(thisArg, this.dict[i]);
  20413. }
  20414. },
  20415. clear: function RefSetCache_clear() {
  20416. this.dict = Object.create(null);
  20417. }
  20418. };
  20419. return RefSetCache;
  20420. }();
  20421. function isName(v, name) {
  20422. return v instanceof Name && (name === undefined || v.name === name);
  20423. }
  20424. function isCmd(v, cmd) {
  20425. return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
  20426. }
  20427. function isDict(v, type) {
  20428. return v instanceof Dict && (type === undefined || isName(v.get('Type'), type));
  20429. }
  20430. function isRef(v) {
  20431. return v instanceof Ref;
  20432. }
  20433. function isRefsEqual(v1, v2) {
  20434. return v1.num === v2.num && v1.gen === v2.gen;
  20435. }
  20436. function isStream(v) {
  20437. return typeof v === 'object' && v !== null && v.getBytes !== undefined;
  20438. }
  20439. exports.Cmd = Cmd;
  20440. exports.Dict = Dict;
  20441. exports.Name = Name;
  20442. exports.Ref = Ref;
  20443. exports.RefSet = RefSet;
  20444. exports.RefSetCache = RefSetCache;
  20445. exports.isCmd = isCmd;
  20446. exports.isDict = isDict;
  20447. exports.isName = isName;
  20448. exports.isRef = isRef;
  20449. exports.isRefsEqual = isRefsEqual;
  20450. exports.isStream = isStream;
  20451. }));
  20452. (function (root, factory) {
  20453. factory(root.pdfjsCoreStandardFonts = {}, root.pdfjsSharedUtil);
  20454. }(this, function (exports, sharedUtil) {
  20455. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  20456. var getStdFontMap = getLookupTableFactory(function (t) {
  20457. t['ArialNarrow'] = 'Helvetica';
  20458. t['ArialNarrow-Bold'] = 'Helvetica-Bold';
  20459. t['ArialNarrow-BoldItalic'] = 'Helvetica-BoldOblique';
  20460. t['ArialNarrow-Italic'] = 'Helvetica-Oblique';
  20461. t['ArialBlack'] = 'Helvetica';
  20462. t['ArialBlack-Bold'] = 'Helvetica-Bold';
  20463. t['ArialBlack-BoldItalic'] = 'Helvetica-BoldOblique';
  20464. t['ArialBlack-Italic'] = 'Helvetica-Oblique';
  20465. t['Arial-Black'] = 'Helvetica';
  20466. t['Arial-Black-Bold'] = 'Helvetica-Bold';
  20467. t['Arial-Black-BoldItalic'] = 'Helvetica-BoldOblique';
  20468. t['Arial-Black-Italic'] = 'Helvetica-Oblique';
  20469. t['Arial'] = 'Helvetica';
  20470. t['Arial-Bold'] = 'Helvetica-Bold';
  20471. t['Arial-BoldItalic'] = 'Helvetica-BoldOblique';
  20472. t['Arial-Italic'] = 'Helvetica-Oblique';
  20473. t['Arial-BoldItalicMT'] = 'Helvetica-BoldOblique';
  20474. t['Arial-BoldMT'] = 'Helvetica-Bold';
  20475. t['Arial-ItalicMT'] = 'Helvetica-Oblique';
  20476. t['ArialMT'] = 'Helvetica';
  20477. t['Courier-Bold'] = 'Courier-Bold';
  20478. t['Courier-BoldItalic'] = 'Courier-BoldOblique';
  20479. t['Courier-Italic'] = 'Courier-Oblique';
  20480. t['CourierNew'] = 'Courier';
  20481. t['CourierNew-Bold'] = 'Courier-Bold';
  20482. t['CourierNew-BoldItalic'] = 'Courier-BoldOblique';
  20483. t['CourierNew-Italic'] = 'Courier-Oblique';
  20484. t['CourierNewPS-BoldItalicMT'] = 'Courier-BoldOblique';
  20485. t['CourierNewPS-BoldMT'] = 'Courier-Bold';
  20486. t['CourierNewPS-ItalicMT'] = 'Courier-Oblique';
  20487. t['CourierNewPSMT'] = 'Courier';
  20488. t['Helvetica'] = 'Helvetica';
  20489. t['Helvetica-Bold'] = 'Helvetica-Bold';
  20490. t['Helvetica-BoldItalic'] = 'Helvetica-BoldOblique';
  20491. t['Helvetica-BoldOblique'] = 'Helvetica-BoldOblique';
  20492. t['Helvetica-Italic'] = 'Helvetica-Oblique';
  20493. t['Helvetica-Oblique'] = 'Helvetica-Oblique';
  20494. t['Symbol-Bold'] = 'Symbol';
  20495. t['Symbol-BoldItalic'] = 'Symbol';
  20496. t['Symbol-Italic'] = 'Symbol';
  20497. t['TimesNewRoman'] = 'Times-Roman';
  20498. t['TimesNewRoman-Bold'] = 'Times-Bold';
  20499. t['TimesNewRoman-BoldItalic'] = 'Times-BoldItalic';
  20500. t['TimesNewRoman-Italic'] = 'Times-Italic';
  20501. t['TimesNewRomanPS'] = 'Times-Roman';
  20502. t['TimesNewRomanPS-Bold'] = 'Times-Bold';
  20503. t['TimesNewRomanPS-BoldItalic'] = 'Times-BoldItalic';
  20504. t['TimesNewRomanPS-BoldItalicMT'] = 'Times-BoldItalic';
  20505. t['TimesNewRomanPS-BoldMT'] = 'Times-Bold';
  20506. t['TimesNewRomanPS-Italic'] = 'Times-Italic';
  20507. t['TimesNewRomanPS-ItalicMT'] = 'Times-Italic';
  20508. t['TimesNewRomanPSMT'] = 'Times-Roman';
  20509. t['TimesNewRomanPSMT-Bold'] = 'Times-Bold';
  20510. t['TimesNewRomanPSMT-BoldItalic'] = 'Times-BoldItalic';
  20511. t['TimesNewRomanPSMT-Italic'] = 'Times-Italic';
  20512. });
  20513. var getNonStdFontMap = getLookupTableFactory(function (t) {
  20514. t['CenturyGothic'] = 'Helvetica';
  20515. t['CenturyGothic-Bold'] = 'Helvetica-Bold';
  20516. t['CenturyGothic-BoldItalic'] = 'Helvetica-BoldOblique';
  20517. t['CenturyGothic-Italic'] = 'Helvetica-Oblique';
  20518. t['ComicSansMS'] = 'Comic Sans MS';
  20519. t['ComicSansMS-Bold'] = 'Comic Sans MS-Bold';
  20520. t['ComicSansMS-BoldItalic'] = 'Comic Sans MS-BoldItalic';
  20521. t['ComicSansMS-Italic'] = 'Comic Sans MS-Italic';
  20522. t['LucidaConsole'] = 'Courier';
  20523. t['LucidaConsole-Bold'] = 'Courier-Bold';
  20524. t['LucidaConsole-BoldItalic'] = 'Courier-BoldOblique';
  20525. t['LucidaConsole-Italic'] = 'Courier-Oblique';
  20526. t['MS-Gothic'] = 'MS Gothic';
  20527. t['MS-Gothic-Bold'] = 'MS Gothic-Bold';
  20528. t['MS-Gothic-BoldItalic'] = 'MS Gothic-BoldItalic';
  20529. t['MS-Gothic-Italic'] = 'MS Gothic-Italic';
  20530. t['MS-Mincho'] = 'MS Mincho';
  20531. t['MS-Mincho-Bold'] = 'MS Mincho-Bold';
  20532. t['MS-Mincho-BoldItalic'] = 'MS Mincho-BoldItalic';
  20533. t['MS-Mincho-Italic'] = 'MS Mincho-Italic';
  20534. t['MS-PGothic'] = 'MS PGothic';
  20535. t['MS-PGothic-Bold'] = 'MS PGothic-Bold';
  20536. t['MS-PGothic-BoldItalic'] = 'MS PGothic-BoldItalic';
  20537. t['MS-PGothic-Italic'] = 'MS PGothic-Italic';
  20538. t['MS-PMincho'] = 'MS PMincho';
  20539. t['MS-PMincho-Bold'] = 'MS PMincho-Bold';
  20540. t['MS-PMincho-BoldItalic'] = 'MS PMincho-BoldItalic';
  20541. t['MS-PMincho-Italic'] = 'MS PMincho-Italic';
  20542. t['NuptialScript'] = 'Times-Italic';
  20543. t['Wingdings'] = 'ZapfDingbats';
  20544. });
  20545. var getSerifFonts = getLookupTableFactory(function (t) {
  20546. t['Adobe Jenson'] = true;
  20547. t['Adobe Text'] = true;
  20548. t['Albertus'] = true;
  20549. t['Aldus'] = true;
  20550. t['Alexandria'] = true;
  20551. t['Algerian'] = true;
  20552. t['American Typewriter'] = true;
  20553. t['Antiqua'] = true;
  20554. t['Apex'] = true;
  20555. t['Arno'] = true;
  20556. t['Aster'] = true;
  20557. t['Aurora'] = true;
  20558. t['Baskerville'] = true;
  20559. t['Bell'] = true;
  20560. t['Bembo'] = true;
  20561. t['Bembo Schoolbook'] = true;
  20562. t['Benguiat'] = true;
  20563. t['Berkeley Old Style'] = true;
  20564. t['Bernhard Modern'] = true;
  20565. t['Berthold City'] = true;
  20566. t['Bodoni'] = true;
  20567. t['Bauer Bodoni'] = true;
  20568. t['Book Antiqua'] = true;
  20569. t['Bookman'] = true;
  20570. t['Bordeaux Roman'] = true;
  20571. t['Californian FB'] = true;
  20572. t['Calisto'] = true;
  20573. t['Calvert'] = true;
  20574. t['Capitals'] = true;
  20575. t['Cambria'] = true;
  20576. t['Cartier'] = true;
  20577. t['Caslon'] = true;
  20578. t['Catull'] = true;
  20579. t['Centaur'] = true;
  20580. t['Century Old Style'] = true;
  20581. t['Century Schoolbook'] = true;
  20582. t['Chaparral'] = true;
  20583. t['Charis SIL'] = true;
  20584. t['Cheltenham'] = true;
  20585. t['Cholla Slab'] = true;
  20586. t['Clarendon'] = true;
  20587. t['Clearface'] = true;
  20588. t['Cochin'] = true;
  20589. t['Colonna'] = true;
  20590. t['Computer Modern'] = true;
  20591. t['Concrete Roman'] = true;
  20592. t['Constantia'] = true;
  20593. t['Cooper Black'] = true;
  20594. t['Corona'] = true;
  20595. t['Ecotype'] = true;
  20596. t['Egyptienne'] = true;
  20597. t['Elephant'] = true;
  20598. t['Excelsior'] = true;
  20599. t['Fairfield'] = true;
  20600. t['FF Scala'] = true;
  20601. t['Folkard'] = true;
  20602. t['Footlight'] = true;
  20603. t['FreeSerif'] = true;
  20604. t['Friz Quadrata'] = true;
  20605. t['Garamond'] = true;
  20606. t['Gentium'] = true;
  20607. t['Georgia'] = true;
  20608. t['Gloucester'] = true;
  20609. t['Goudy Old Style'] = true;
  20610. t['Goudy Schoolbook'] = true;
  20611. t['Goudy Pro Font'] = true;
  20612. t['Granjon'] = true;
  20613. t['Guardian Egyptian'] = true;
  20614. t['Heather'] = true;
  20615. t['Hercules'] = true;
  20616. t['High Tower Text'] = true;
  20617. t['Hiroshige'] = true;
  20618. t['Hoefler Text'] = true;
  20619. t['Humana Serif'] = true;
  20620. t['Imprint'] = true;
  20621. t['Ionic No. 5'] = true;
  20622. t['Janson'] = true;
  20623. t['Joanna'] = true;
  20624. t['Korinna'] = true;
  20625. t['Lexicon'] = true;
  20626. t['Liberation Serif'] = true;
  20627. t['Linux Libertine'] = true;
  20628. t['Literaturnaya'] = true;
  20629. t['Lucida'] = true;
  20630. t['Lucida Bright'] = true;
  20631. t['Melior'] = true;
  20632. t['Memphis'] = true;
  20633. t['Miller'] = true;
  20634. t['Minion'] = true;
  20635. t['Modern'] = true;
  20636. t['Mona Lisa'] = true;
  20637. t['Mrs Eaves'] = true;
  20638. t['MS Serif'] = true;
  20639. t['Museo Slab'] = true;
  20640. t['New York'] = true;
  20641. t['Nimbus Roman'] = true;
  20642. t['NPS Rawlinson Roadway'] = true;
  20643. t['NuptialScript'] = true;
  20644. t['Palatino'] = true;
  20645. t['Perpetua'] = true;
  20646. t['Plantin'] = true;
  20647. t['Plantin Schoolbook'] = true;
  20648. t['Playbill'] = true;
  20649. t['Poor Richard'] = true;
  20650. t['Rawlinson Roadway'] = true;
  20651. t['Renault'] = true;
  20652. t['Requiem'] = true;
  20653. t['Rockwell'] = true;
  20654. t['Roman'] = true;
  20655. t['Rotis Serif'] = true;
  20656. t['Sabon'] = true;
  20657. t['Scala'] = true;
  20658. t['Seagull'] = true;
  20659. t['Sistina'] = true;
  20660. t['Souvenir'] = true;
  20661. t['STIX'] = true;
  20662. t['Stone Informal'] = true;
  20663. t['Stone Serif'] = true;
  20664. t['Sylfaen'] = true;
  20665. t['Times'] = true;
  20666. t['Trajan'] = true;
  20667. t['Trinité'] = true;
  20668. t['Trump Mediaeval'] = true;
  20669. t['Utopia'] = true;
  20670. t['Vale Type'] = true;
  20671. t['Bitstream Vera'] = true;
  20672. t['Vera Serif'] = true;
  20673. t['Versailles'] = true;
  20674. t['Wanted'] = true;
  20675. t['Weiss'] = true;
  20676. t['Wide Latin'] = true;
  20677. t['Windsor'] = true;
  20678. t['XITS'] = true;
  20679. });
  20680. var getSymbolsFonts = getLookupTableFactory(function (t) {
  20681. t['Dingbats'] = true;
  20682. t['Symbol'] = true;
  20683. t['ZapfDingbats'] = true;
  20684. });
  20685. var getGlyphMapForStandardFonts = getLookupTableFactory(function (t) {
  20686. t[2] = 10;
  20687. t[3] = 32;
  20688. t[4] = 33;
  20689. t[5] = 34;
  20690. t[6] = 35;
  20691. t[7] = 36;
  20692. t[8] = 37;
  20693. t[9] = 38;
  20694. t[10] = 39;
  20695. t[11] = 40;
  20696. t[12] = 41;
  20697. t[13] = 42;
  20698. t[14] = 43;
  20699. t[15] = 44;
  20700. t[16] = 45;
  20701. t[17] = 46;
  20702. t[18] = 47;
  20703. t[19] = 48;
  20704. t[20] = 49;
  20705. t[21] = 50;
  20706. t[22] = 51;
  20707. t[23] = 52;
  20708. t[24] = 53;
  20709. t[25] = 54;
  20710. t[26] = 55;
  20711. t[27] = 56;
  20712. t[28] = 57;
  20713. t[29] = 58;
  20714. t[30] = 894;
  20715. t[31] = 60;
  20716. t[32] = 61;
  20717. t[33] = 62;
  20718. t[34] = 63;
  20719. t[35] = 64;
  20720. t[36] = 65;
  20721. t[37] = 66;
  20722. t[38] = 67;
  20723. t[39] = 68;
  20724. t[40] = 69;
  20725. t[41] = 70;
  20726. t[42] = 71;
  20727. t[43] = 72;
  20728. t[44] = 73;
  20729. t[45] = 74;
  20730. t[46] = 75;
  20731. t[47] = 76;
  20732. t[48] = 77;
  20733. t[49] = 78;
  20734. t[50] = 79;
  20735. t[51] = 80;
  20736. t[52] = 81;
  20737. t[53] = 82;
  20738. t[54] = 83;
  20739. t[55] = 84;
  20740. t[56] = 85;
  20741. t[57] = 86;
  20742. t[58] = 87;
  20743. t[59] = 88;
  20744. t[60] = 89;
  20745. t[61] = 90;
  20746. t[62] = 91;
  20747. t[63] = 92;
  20748. t[64] = 93;
  20749. t[65] = 94;
  20750. t[66] = 95;
  20751. t[67] = 96;
  20752. t[68] = 97;
  20753. t[69] = 98;
  20754. t[70] = 99;
  20755. t[71] = 100;
  20756. t[72] = 101;
  20757. t[73] = 102;
  20758. t[74] = 103;
  20759. t[75] = 104;
  20760. t[76] = 105;
  20761. t[77] = 106;
  20762. t[78] = 107;
  20763. t[79] = 108;
  20764. t[80] = 109;
  20765. t[81] = 110;
  20766. t[82] = 111;
  20767. t[83] = 112;
  20768. t[84] = 113;
  20769. t[85] = 114;
  20770. t[86] = 115;
  20771. t[87] = 116;
  20772. t[88] = 117;
  20773. t[89] = 118;
  20774. t[90] = 119;
  20775. t[91] = 120;
  20776. t[92] = 121;
  20777. t[93] = 122;
  20778. t[94] = 123;
  20779. t[95] = 124;
  20780. t[96] = 125;
  20781. t[97] = 126;
  20782. t[98] = 196;
  20783. t[99] = 197;
  20784. t[100] = 199;
  20785. t[101] = 201;
  20786. t[102] = 209;
  20787. t[103] = 214;
  20788. t[104] = 220;
  20789. t[105] = 225;
  20790. t[106] = 224;
  20791. t[107] = 226;
  20792. t[108] = 228;
  20793. t[109] = 227;
  20794. t[110] = 229;
  20795. t[111] = 231;
  20796. t[112] = 233;
  20797. t[113] = 232;
  20798. t[114] = 234;
  20799. t[115] = 235;
  20800. t[116] = 237;
  20801. t[117] = 236;
  20802. t[118] = 238;
  20803. t[119] = 239;
  20804. t[120] = 241;
  20805. t[121] = 243;
  20806. t[122] = 242;
  20807. t[123] = 244;
  20808. t[124] = 246;
  20809. t[125] = 245;
  20810. t[126] = 250;
  20811. t[127] = 249;
  20812. t[128] = 251;
  20813. t[129] = 252;
  20814. t[130] = 8224;
  20815. t[131] = 176;
  20816. t[132] = 162;
  20817. t[133] = 163;
  20818. t[134] = 167;
  20819. t[135] = 8226;
  20820. t[136] = 182;
  20821. t[137] = 223;
  20822. t[138] = 174;
  20823. t[139] = 169;
  20824. t[140] = 8482;
  20825. t[141] = 180;
  20826. t[142] = 168;
  20827. t[143] = 8800;
  20828. t[144] = 198;
  20829. t[145] = 216;
  20830. t[146] = 8734;
  20831. t[147] = 177;
  20832. t[148] = 8804;
  20833. t[149] = 8805;
  20834. t[150] = 165;
  20835. t[151] = 181;
  20836. t[152] = 8706;
  20837. t[153] = 8721;
  20838. t[154] = 8719;
  20839. t[156] = 8747;
  20840. t[157] = 170;
  20841. t[158] = 186;
  20842. t[159] = 8486;
  20843. t[160] = 230;
  20844. t[161] = 248;
  20845. t[162] = 191;
  20846. t[163] = 161;
  20847. t[164] = 172;
  20848. t[165] = 8730;
  20849. t[166] = 402;
  20850. t[167] = 8776;
  20851. t[168] = 8710;
  20852. t[169] = 171;
  20853. t[170] = 187;
  20854. t[171] = 8230;
  20855. t[210] = 218;
  20856. t[223] = 711;
  20857. t[224] = 321;
  20858. t[225] = 322;
  20859. t[227] = 353;
  20860. t[229] = 382;
  20861. t[234] = 253;
  20862. t[252] = 263;
  20863. t[253] = 268;
  20864. t[254] = 269;
  20865. t[258] = 258;
  20866. t[260] = 260;
  20867. t[261] = 261;
  20868. t[265] = 280;
  20869. t[266] = 281;
  20870. t[268] = 283;
  20871. t[269] = 313;
  20872. t[275] = 323;
  20873. t[276] = 324;
  20874. t[278] = 328;
  20875. t[284] = 345;
  20876. t[285] = 346;
  20877. t[286] = 347;
  20878. t[292] = 367;
  20879. t[295] = 377;
  20880. t[296] = 378;
  20881. t[298] = 380;
  20882. t[305] = 963;
  20883. t[306] = 964;
  20884. t[307] = 966;
  20885. t[308] = 8215;
  20886. t[309] = 8252;
  20887. t[310] = 8319;
  20888. t[311] = 8359;
  20889. t[312] = 8592;
  20890. t[313] = 8593;
  20891. t[337] = 9552;
  20892. t[493] = 1039;
  20893. t[494] = 1040;
  20894. t[705] = 1524;
  20895. t[706] = 8362;
  20896. t[710] = 64288;
  20897. t[711] = 64298;
  20898. t[759] = 1617;
  20899. t[761] = 1776;
  20900. t[763] = 1778;
  20901. t[775] = 1652;
  20902. t[777] = 1764;
  20903. t[778] = 1780;
  20904. t[779] = 1781;
  20905. t[780] = 1782;
  20906. t[782] = 771;
  20907. t[783] = 64726;
  20908. t[786] = 8363;
  20909. t[788] = 8532;
  20910. t[790] = 768;
  20911. t[791] = 769;
  20912. t[792] = 768;
  20913. t[795] = 803;
  20914. t[797] = 64336;
  20915. t[798] = 64337;
  20916. t[799] = 64342;
  20917. t[800] = 64343;
  20918. t[801] = 64344;
  20919. t[802] = 64345;
  20920. t[803] = 64362;
  20921. t[804] = 64363;
  20922. t[805] = 64364;
  20923. t[2424] = 7821;
  20924. t[2425] = 7822;
  20925. t[2426] = 7823;
  20926. t[2427] = 7824;
  20927. t[2428] = 7825;
  20928. t[2429] = 7826;
  20929. t[2430] = 7827;
  20930. t[2433] = 7682;
  20931. t[2678] = 8045;
  20932. t[2679] = 8046;
  20933. t[2830] = 1552;
  20934. t[2838] = 686;
  20935. t[2840] = 751;
  20936. t[2842] = 753;
  20937. t[2843] = 754;
  20938. t[2844] = 755;
  20939. t[2846] = 757;
  20940. t[2856] = 767;
  20941. t[2857] = 848;
  20942. t[2858] = 849;
  20943. t[2862] = 853;
  20944. t[2863] = 854;
  20945. t[2864] = 855;
  20946. t[2865] = 861;
  20947. t[2866] = 862;
  20948. t[2906] = 7460;
  20949. t[2908] = 7462;
  20950. t[2909] = 7463;
  20951. t[2910] = 7464;
  20952. t[2912] = 7466;
  20953. t[2913] = 7467;
  20954. t[2914] = 7468;
  20955. t[2916] = 7470;
  20956. t[2917] = 7471;
  20957. t[2918] = 7472;
  20958. t[2920] = 7474;
  20959. t[2921] = 7475;
  20960. t[2922] = 7476;
  20961. t[2924] = 7478;
  20962. t[2925] = 7479;
  20963. t[2926] = 7480;
  20964. t[2928] = 7482;
  20965. t[2929] = 7483;
  20966. t[2930] = 7484;
  20967. t[2932] = 7486;
  20968. t[2933] = 7487;
  20969. t[2934] = 7488;
  20970. t[2936] = 7490;
  20971. t[2937] = 7491;
  20972. t[2938] = 7492;
  20973. t[2940] = 7494;
  20974. t[2941] = 7495;
  20975. t[2942] = 7496;
  20976. t[2944] = 7498;
  20977. t[2946] = 7500;
  20978. t[2948] = 7502;
  20979. t[2950] = 7504;
  20980. t[2951] = 7505;
  20981. t[2952] = 7506;
  20982. t[2954] = 7508;
  20983. t[2955] = 7509;
  20984. t[2956] = 7510;
  20985. t[2958] = 7512;
  20986. t[2959] = 7513;
  20987. t[2960] = 7514;
  20988. t[2962] = 7516;
  20989. t[2963] = 7517;
  20990. t[2964] = 7518;
  20991. t[2966] = 7520;
  20992. t[2967] = 7521;
  20993. t[2968] = 7522;
  20994. t[2970] = 7524;
  20995. t[2971] = 7525;
  20996. t[2972] = 7526;
  20997. t[2974] = 7528;
  20998. t[2975] = 7529;
  20999. t[2976] = 7530;
  21000. t[2978] = 1537;
  21001. t[2979] = 1538;
  21002. t[2980] = 1539;
  21003. t[2982] = 1549;
  21004. t[2983] = 1551;
  21005. t[2984] = 1552;
  21006. t[2986] = 1554;
  21007. t[2987] = 1555;
  21008. t[2988] = 1556;
  21009. t[2990] = 1623;
  21010. t[2991] = 1624;
  21011. t[2995] = 1775;
  21012. t[2999] = 1791;
  21013. t[3002] = 64290;
  21014. t[3003] = 64291;
  21015. t[3004] = 64292;
  21016. t[3006] = 64294;
  21017. t[3007] = 64295;
  21018. t[3008] = 64296;
  21019. t[3011] = 1900;
  21020. t[3014] = 8223;
  21021. t[3015] = 8244;
  21022. t[3017] = 7532;
  21023. t[3018] = 7533;
  21024. t[3019] = 7534;
  21025. t[3075] = 7590;
  21026. t[3076] = 7591;
  21027. t[3079] = 7594;
  21028. t[3080] = 7595;
  21029. t[3083] = 7598;
  21030. t[3084] = 7599;
  21031. t[3087] = 7602;
  21032. t[3088] = 7603;
  21033. t[3091] = 7606;
  21034. t[3092] = 7607;
  21035. t[3095] = 7610;
  21036. t[3096] = 7611;
  21037. t[3099] = 7614;
  21038. t[3100] = 7615;
  21039. t[3103] = 7618;
  21040. t[3104] = 7619;
  21041. t[3107] = 8337;
  21042. t[3108] = 8338;
  21043. t[3116] = 1884;
  21044. t[3119] = 1885;
  21045. t[3120] = 1885;
  21046. t[3123] = 1886;
  21047. t[3124] = 1886;
  21048. t[3127] = 1887;
  21049. t[3128] = 1887;
  21050. t[3131] = 1888;
  21051. t[3132] = 1888;
  21052. t[3135] = 1889;
  21053. t[3136] = 1889;
  21054. t[3139] = 1890;
  21055. t[3140] = 1890;
  21056. t[3143] = 1891;
  21057. t[3144] = 1891;
  21058. t[3147] = 1892;
  21059. t[3148] = 1892;
  21060. t[3153] = 580;
  21061. t[3154] = 581;
  21062. t[3157] = 584;
  21063. t[3158] = 585;
  21064. t[3161] = 588;
  21065. t[3162] = 589;
  21066. t[3165] = 891;
  21067. t[3166] = 892;
  21068. t[3169] = 1274;
  21069. t[3170] = 1275;
  21070. t[3173] = 1278;
  21071. t[3174] = 1279;
  21072. t[3181] = 7622;
  21073. t[3182] = 7623;
  21074. t[3282] = 11799;
  21075. t[3316] = 578;
  21076. t[3379] = 42785;
  21077. t[3393] = 1159;
  21078. t[3416] = 8377;
  21079. });
  21080. var getSupplementalGlyphMapForArialBlack = getLookupTableFactory(function (t) {
  21081. t[227] = 322;
  21082. t[264] = 261;
  21083. t[291] = 346;
  21084. });
  21085. exports.getStdFontMap = getStdFontMap;
  21086. exports.getNonStdFontMap = getNonStdFontMap;
  21087. exports.getSerifFonts = getSerifFonts;
  21088. exports.getSymbolsFonts = getSymbolsFonts;
  21089. exports.getGlyphMapForStandardFonts = getGlyphMapForStandardFonts;
  21090. exports.getSupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack;
  21091. }));
  21092. (function (root, factory) {
  21093. factory(root.pdfjsCoreUnicode = {}, root.pdfjsSharedUtil);
  21094. }(this, function (exports, sharedUtil) {
  21095. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  21096. var getSpecialPUASymbols = getLookupTableFactory(function (t) {
  21097. t[63721] = 0x00A9;
  21098. t[63193] = 0x00A9;
  21099. t[63720] = 0x00AE;
  21100. t[63194] = 0x00AE;
  21101. t[63722] = 0x2122;
  21102. t[63195] = 0x2122;
  21103. t[63729] = 0x23A7;
  21104. t[63730] = 0x23A8;
  21105. t[63731] = 0x23A9;
  21106. t[63740] = 0x23AB;
  21107. t[63741] = 0x23AC;
  21108. t[63742] = 0x23AD;
  21109. t[63726] = 0x23A1;
  21110. t[63727] = 0x23A2;
  21111. t[63728] = 0x23A3;
  21112. t[63737] = 0x23A4;
  21113. t[63738] = 0x23A5;
  21114. t[63739] = 0x23A6;
  21115. t[63723] = 0x239B;
  21116. t[63724] = 0x239C;
  21117. t[63725] = 0x239D;
  21118. t[63734] = 0x239E;
  21119. t[63735] = 0x239F;
  21120. t[63736] = 0x23A0;
  21121. });
  21122. function mapSpecialUnicodeValues(code) {
  21123. if (code >= 0xFFF0 && code <= 0xFFFF) {
  21124. return 0;
  21125. } else if (code >= 0xF600 && code <= 0xF8FF) {
  21126. return getSpecialPUASymbols()[code] || code;
  21127. }
  21128. return code;
  21129. }
  21130. function getUnicodeForGlyph(name, glyphsUnicodeMap) {
  21131. var unicode = glyphsUnicodeMap[name];
  21132. if (unicode !== undefined) {
  21133. return unicode;
  21134. }
  21135. if (!name) {
  21136. return -1;
  21137. }
  21138. if (name[0] === 'u') {
  21139. var nameLen = name.length, hexStr;
  21140. if (nameLen === 7 && name[1] === 'n' && name[2] === 'i') {
  21141. hexStr = name.substr(3);
  21142. } else if (nameLen >= 5 && nameLen <= 7) {
  21143. hexStr = name.substr(1);
  21144. } else {
  21145. return -1;
  21146. }
  21147. if (hexStr === hexStr.toUpperCase()) {
  21148. unicode = parseInt(hexStr, 16);
  21149. if (unicode >= 0) {
  21150. return unicode;
  21151. }
  21152. }
  21153. }
  21154. return -1;
  21155. }
  21156. var UnicodeRanges = [
  21157. {
  21158. 'begin': 0x0000,
  21159. 'end': 0x007F
  21160. },
  21161. {
  21162. 'begin': 0x0080,
  21163. 'end': 0x00FF
  21164. },
  21165. {
  21166. 'begin': 0x0100,
  21167. 'end': 0x017F
  21168. },
  21169. {
  21170. 'begin': 0x0180,
  21171. 'end': 0x024F
  21172. },
  21173. {
  21174. 'begin': 0x0250,
  21175. 'end': 0x02AF
  21176. },
  21177. {
  21178. 'begin': 0x02B0,
  21179. 'end': 0x02FF
  21180. },
  21181. {
  21182. 'begin': 0x0300,
  21183. 'end': 0x036F
  21184. },
  21185. {
  21186. 'begin': 0x0370,
  21187. 'end': 0x03FF
  21188. },
  21189. {
  21190. 'begin': 0x2C80,
  21191. 'end': 0x2CFF
  21192. },
  21193. {
  21194. 'begin': 0x0400,
  21195. 'end': 0x04FF
  21196. },
  21197. {
  21198. 'begin': 0x0530,
  21199. 'end': 0x058F
  21200. },
  21201. {
  21202. 'begin': 0x0590,
  21203. 'end': 0x05FF
  21204. },
  21205. {
  21206. 'begin': 0xA500,
  21207. 'end': 0xA63F
  21208. },
  21209. {
  21210. 'begin': 0x0600,
  21211. 'end': 0x06FF
  21212. },
  21213. {
  21214. 'begin': 0x07C0,
  21215. 'end': 0x07FF
  21216. },
  21217. {
  21218. 'begin': 0x0900,
  21219. 'end': 0x097F
  21220. },
  21221. {
  21222. 'begin': 0x0980,
  21223. 'end': 0x09FF
  21224. },
  21225. {
  21226. 'begin': 0x0A00,
  21227. 'end': 0x0A7F
  21228. },
  21229. {
  21230. 'begin': 0x0A80,
  21231. 'end': 0x0AFF
  21232. },
  21233. {
  21234. 'begin': 0x0B00,
  21235. 'end': 0x0B7F
  21236. },
  21237. {
  21238. 'begin': 0x0B80,
  21239. 'end': 0x0BFF
  21240. },
  21241. {
  21242. 'begin': 0x0C00,
  21243. 'end': 0x0C7F
  21244. },
  21245. {
  21246. 'begin': 0x0C80,
  21247. 'end': 0x0CFF
  21248. },
  21249. {
  21250. 'begin': 0x0D00,
  21251. 'end': 0x0D7F
  21252. },
  21253. {
  21254. 'begin': 0x0E00,
  21255. 'end': 0x0E7F
  21256. },
  21257. {
  21258. 'begin': 0x0E80,
  21259. 'end': 0x0EFF
  21260. },
  21261. {
  21262. 'begin': 0x10A0,
  21263. 'end': 0x10FF
  21264. },
  21265. {
  21266. 'begin': 0x1B00,
  21267. 'end': 0x1B7F
  21268. },
  21269. {
  21270. 'begin': 0x1100,
  21271. 'end': 0x11FF
  21272. },
  21273. {
  21274. 'begin': 0x1E00,
  21275. 'end': 0x1EFF
  21276. },
  21277. {
  21278. 'begin': 0x1F00,
  21279. 'end': 0x1FFF
  21280. },
  21281. {
  21282. 'begin': 0x2000,
  21283. 'end': 0x206F
  21284. },
  21285. {
  21286. 'begin': 0x2070,
  21287. 'end': 0x209F
  21288. },
  21289. {
  21290. 'begin': 0x20A0,
  21291. 'end': 0x20CF
  21292. },
  21293. {
  21294. 'begin': 0x20D0,
  21295. 'end': 0x20FF
  21296. },
  21297. {
  21298. 'begin': 0x2100,
  21299. 'end': 0x214F
  21300. },
  21301. {
  21302. 'begin': 0x2150,
  21303. 'end': 0x218F
  21304. },
  21305. {
  21306. 'begin': 0x2190,
  21307. 'end': 0x21FF
  21308. },
  21309. {
  21310. 'begin': 0x2200,
  21311. 'end': 0x22FF
  21312. },
  21313. {
  21314. 'begin': 0x2300,
  21315. 'end': 0x23FF
  21316. },
  21317. {
  21318. 'begin': 0x2400,
  21319. 'end': 0x243F
  21320. },
  21321. {
  21322. 'begin': 0x2440,
  21323. 'end': 0x245F
  21324. },
  21325. {
  21326. 'begin': 0x2460,
  21327. 'end': 0x24FF
  21328. },
  21329. {
  21330. 'begin': 0x2500,
  21331. 'end': 0x257F
  21332. },
  21333. {
  21334. 'begin': 0x2580,
  21335. 'end': 0x259F
  21336. },
  21337. {
  21338. 'begin': 0x25A0,
  21339. 'end': 0x25FF
  21340. },
  21341. {
  21342. 'begin': 0x2600,
  21343. 'end': 0x26FF
  21344. },
  21345. {
  21346. 'begin': 0x2700,
  21347. 'end': 0x27BF
  21348. },
  21349. {
  21350. 'begin': 0x3000,
  21351. 'end': 0x303F
  21352. },
  21353. {
  21354. 'begin': 0x3040,
  21355. 'end': 0x309F
  21356. },
  21357. {
  21358. 'begin': 0x30A0,
  21359. 'end': 0x30FF
  21360. },
  21361. {
  21362. 'begin': 0x3100,
  21363. 'end': 0x312F
  21364. },
  21365. {
  21366. 'begin': 0x3130,
  21367. 'end': 0x318F
  21368. },
  21369. {
  21370. 'begin': 0xA840,
  21371. 'end': 0xA87F
  21372. },
  21373. {
  21374. 'begin': 0x3200,
  21375. 'end': 0x32FF
  21376. },
  21377. {
  21378. 'begin': 0x3300,
  21379. 'end': 0x33FF
  21380. },
  21381. {
  21382. 'begin': 0xAC00,
  21383. 'end': 0xD7AF
  21384. },
  21385. {
  21386. 'begin': 0xD800,
  21387. 'end': 0xDFFF
  21388. },
  21389. {
  21390. 'begin': 0x10900,
  21391. 'end': 0x1091F
  21392. },
  21393. {
  21394. 'begin': 0x4E00,
  21395. 'end': 0x9FFF
  21396. },
  21397. {
  21398. 'begin': 0xE000,
  21399. 'end': 0xF8FF
  21400. },
  21401. {
  21402. 'begin': 0x31C0,
  21403. 'end': 0x31EF
  21404. },
  21405. {
  21406. 'begin': 0xFB00,
  21407. 'end': 0xFB4F
  21408. },
  21409. {
  21410. 'begin': 0xFB50,
  21411. 'end': 0xFDFF
  21412. },
  21413. {
  21414. 'begin': 0xFE20,
  21415. 'end': 0xFE2F
  21416. },
  21417. {
  21418. 'begin': 0xFE10,
  21419. 'end': 0xFE1F
  21420. },
  21421. {
  21422. 'begin': 0xFE50,
  21423. 'end': 0xFE6F
  21424. },
  21425. {
  21426. 'begin': 0xFE70,
  21427. 'end': 0xFEFF
  21428. },
  21429. {
  21430. 'begin': 0xFF00,
  21431. 'end': 0xFFEF
  21432. },
  21433. {
  21434. 'begin': 0xFFF0,
  21435. 'end': 0xFFFF
  21436. },
  21437. {
  21438. 'begin': 0x0F00,
  21439. 'end': 0x0FFF
  21440. },
  21441. {
  21442. 'begin': 0x0700,
  21443. 'end': 0x074F
  21444. },
  21445. {
  21446. 'begin': 0x0780,
  21447. 'end': 0x07BF
  21448. },
  21449. {
  21450. 'begin': 0x0D80,
  21451. 'end': 0x0DFF
  21452. },
  21453. {
  21454. 'begin': 0x1000,
  21455. 'end': 0x109F
  21456. },
  21457. {
  21458. 'begin': 0x1200,
  21459. 'end': 0x137F
  21460. },
  21461. {
  21462. 'begin': 0x13A0,
  21463. 'end': 0x13FF
  21464. },
  21465. {
  21466. 'begin': 0x1400,
  21467. 'end': 0x167F
  21468. },
  21469. {
  21470. 'begin': 0x1680,
  21471. 'end': 0x169F
  21472. },
  21473. {
  21474. 'begin': 0x16A0,
  21475. 'end': 0x16FF
  21476. },
  21477. {
  21478. 'begin': 0x1780,
  21479. 'end': 0x17FF
  21480. },
  21481. {
  21482. 'begin': 0x1800,
  21483. 'end': 0x18AF
  21484. },
  21485. {
  21486. 'begin': 0x2800,
  21487. 'end': 0x28FF
  21488. },
  21489. {
  21490. 'begin': 0xA000,
  21491. 'end': 0xA48F
  21492. },
  21493. {
  21494. 'begin': 0x1700,
  21495. 'end': 0x171F
  21496. },
  21497. {
  21498. 'begin': 0x10300,
  21499. 'end': 0x1032F
  21500. },
  21501. {
  21502. 'begin': 0x10330,
  21503. 'end': 0x1034F
  21504. },
  21505. {
  21506. 'begin': 0x10400,
  21507. 'end': 0x1044F
  21508. },
  21509. {
  21510. 'begin': 0x1D000,
  21511. 'end': 0x1D0FF
  21512. },
  21513. {
  21514. 'begin': 0x1D400,
  21515. 'end': 0x1D7FF
  21516. },
  21517. {
  21518. 'begin': 0xFF000,
  21519. 'end': 0xFFFFD
  21520. },
  21521. {
  21522. 'begin': 0xFE00,
  21523. 'end': 0xFE0F
  21524. },
  21525. {
  21526. 'begin': 0xE0000,
  21527. 'end': 0xE007F
  21528. },
  21529. {
  21530. 'begin': 0x1900,
  21531. 'end': 0x194F
  21532. },
  21533. {
  21534. 'begin': 0x1950,
  21535. 'end': 0x197F
  21536. },
  21537. {
  21538. 'begin': 0x1980,
  21539. 'end': 0x19DF
  21540. },
  21541. {
  21542. 'begin': 0x1A00,
  21543. 'end': 0x1A1F
  21544. },
  21545. {
  21546. 'begin': 0x2C00,
  21547. 'end': 0x2C5F
  21548. },
  21549. {
  21550. 'begin': 0x2D30,
  21551. 'end': 0x2D7F
  21552. },
  21553. {
  21554. 'begin': 0x4DC0,
  21555. 'end': 0x4DFF
  21556. },
  21557. {
  21558. 'begin': 0xA800,
  21559. 'end': 0xA82F
  21560. },
  21561. {
  21562. 'begin': 0x10000,
  21563. 'end': 0x1007F
  21564. },
  21565. {
  21566. 'begin': 0x10140,
  21567. 'end': 0x1018F
  21568. },
  21569. {
  21570. 'begin': 0x10380,
  21571. 'end': 0x1039F
  21572. },
  21573. {
  21574. 'begin': 0x103A0,
  21575. 'end': 0x103DF
  21576. },
  21577. {
  21578. 'begin': 0x10450,
  21579. 'end': 0x1047F
  21580. },
  21581. {
  21582. 'begin': 0x10480,
  21583. 'end': 0x104AF
  21584. },
  21585. {
  21586. 'begin': 0x10800,
  21587. 'end': 0x1083F
  21588. },
  21589. {
  21590. 'begin': 0x10A00,
  21591. 'end': 0x10A5F
  21592. },
  21593. {
  21594. 'begin': 0x1D300,
  21595. 'end': 0x1D35F
  21596. },
  21597. {
  21598. 'begin': 0x12000,
  21599. 'end': 0x123FF
  21600. },
  21601. {
  21602. 'begin': 0x1D360,
  21603. 'end': 0x1D37F
  21604. },
  21605. {
  21606. 'begin': 0x1B80,
  21607. 'end': 0x1BBF
  21608. },
  21609. {
  21610. 'begin': 0x1C00,
  21611. 'end': 0x1C4F
  21612. },
  21613. {
  21614. 'begin': 0x1C50,
  21615. 'end': 0x1C7F
  21616. },
  21617. {
  21618. 'begin': 0xA880,
  21619. 'end': 0xA8DF
  21620. },
  21621. {
  21622. 'begin': 0xA900,
  21623. 'end': 0xA92F
  21624. },
  21625. {
  21626. 'begin': 0xA930,
  21627. 'end': 0xA95F
  21628. },
  21629. {
  21630. 'begin': 0xAA00,
  21631. 'end': 0xAA5F
  21632. },
  21633. {
  21634. 'begin': 0x10190,
  21635. 'end': 0x101CF
  21636. },
  21637. {
  21638. 'begin': 0x101D0,
  21639. 'end': 0x101FF
  21640. },
  21641. {
  21642. 'begin': 0x102A0,
  21643. 'end': 0x102DF
  21644. },
  21645. {
  21646. 'begin': 0x1F030,
  21647. 'end': 0x1F09F
  21648. }
  21649. ];
  21650. function getUnicodeRangeFor(value) {
  21651. for (var i = 0, ii = UnicodeRanges.length; i < ii; i++) {
  21652. var range = UnicodeRanges[i];
  21653. if (value >= range.begin && value < range.end) {
  21654. return i;
  21655. }
  21656. }
  21657. return -1;
  21658. }
  21659. function isRTLRangeFor(value) {
  21660. var range = UnicodeRanges[13];
  21661. if (value >= range.begin && value < range.end) {
  21662. return true;
  21663. }
  21664. range = UnicodeRanges[11];
  21665. if (value >= range.begin && value < range.end) {
  21666. return true;
  21667. }
  21668. return false;
  21669. }
  21670. var getNormalizedUnicodes = getLookupTableFactory(function (t) {
  21671. t['\u00A8'] = '\u0020\u0308';
  21672. t['\u00AF'] = '\u0020\u0304';
  21673. t['\u00B4'] = '\u0020\u0301';
  21674. t['\u00B5'] = '\u03BC';
  21675. t['\u00B8'] = '\u0020\u0327';
  21676. t['\u0132'] = '\u0049\u004A';
  21677. t['\u0133'] = '\u0069\u006A';
  21678. t['\u013F'] = '\u004C\u00B7';
  21679. t['\u0140'] = '\u006C\u00B7';
  21680. t['\u0149'] = '\u02BC\u006E';
  21681. t['\u017F'] = '\u0073';
  21682. t['\u01C4'] = '\u0044\u017D';
  21683. t['\u01C5'] = '\u0044\u017E';
  21684. t['\u01C6'] = '\u0064\u017E';
  21685. t['\u01C7'] = '\u004C\u004A';
  21686. t['\u01C8'] = '\u004C\u006A';
  21687. t['\u01C9'] = '\u006C\u006A';
  21688. t['\u01CA'] = '\u004E\u004A';
  21689. t['\u01CB'] = '\u004E\u006A';
  21690. t['\u01CC'] = '\u006E\u006A';
  21691. t['\u01F1'] = '\u0044\u005A';
  21692. t['\u01F2'] = '\u0044\u007A';
  21693. t['\u01F3'] = '\u0064\u007A';
  21694. t['\u02D8'] = '\u0020\u0306';
  21695. t['\u02D9'] = '\u0020\u0307';
  21696. t['\u02DA'] = '\u0020\u030A';
  21697. t['\u02DB'] = '\u0020\u0328';
  21698. t['\u02DC'] = '\u0020\u0303';
  21699. t['\u02DD'] = '\u0020\u030B';
  21700. t['\u037A'] = '\u0020\u0345';
  21701. t['\u0384'] = '\u0020\u0301';
  21702. t['\u03D0'] = '\u03B2';
  21703. t['\u03D1'] = '\u03B8';
  21704. t['\u03D2'] = '\u03A5';
  21705. t['\u03D5'] = '\u03C6';
  21706. t['\u03D6'] = '\u03C0';
  21707. t['\u03F0'] = '\u03BA';
  21708. t['\u03F1'] = '\u03C1';
  21709. t['\u03F2'] = '\u03C2';
  21710. t['\u03F4'] = '\u0398';
  21711. t['\u03F5'] = '\u03B5';
  21712. t['\u03F9'] = '\u03A3';
  21713. t['\u0587'] = '\u0565\u0582';
  21714. t['\u0675'] = '\u0627\u0674';
  21715. t['\u0676'] = '\u0648\u0674';
  21716. t['\u0677'] = '\u06C7\u0674';
  21717. t['\u0678'] = '\u064A\u0674';
  21718. t['\u0E33'] = '\u0E4D\u0E32';
  21719. t['\u0EB3'] = '\u0ECD\u0EB2';
  21720. t['\u0EDC'] = '\u0EAB\u0E99';
  21721. t['\u0EDD'] = '\u0EAB\u0EA1';
  21722. t['\u0F77'] = '\u0FB2\u0F81';
  21723. t['\u0F79'] = '\u0FB3\u0F81';
  21724. t['\u1E9A'] = '\u0061\u02BE';
  21725. t['\u1FBD'] = '\u0020\u0313';
  21726. t['\u1FBF'] = '\u0020\u0313';
  21727. t['\u1FC0'] = '\u0020\u0342';
  21728. t['\u1FFE'] = '\u0020\u0314';
  21729. t['\u2002'] = '\u0020';
  21730. t['\u2003'] = '\u0020';
  21731. t['\u2004'] = '\u0020';
  21732. t['\u2005'] = '\u0020';
  21733. t['\u2006'] = '\u0020';
  21734. t['\u2008'] = '\u0020';
  21735. t['\u2009'] = '\u0020';
  21736. t['\u200A'] = '\u0020';
  21737. t['\u2017'] = '\u0020\u0333';
  21738. t['\u2024'] = '\u002E';
  21739. t['\u2025'] = '\u002E\u002E';
  21740. t['\u2026'] = '\u002E\u002E\u002E';
  21741. t['\u2033'] = '\u2032\u2032';
  21742. t['\u2034'] = '\u2032\u2032\u2032';
  21743. t['\u2036'] = '\u2035\u2035';
  21744. t['\u2037'] = '\u2035\u2035\u2035';
  21745. t['\u203C'] = '\u0021\u0021';
  21746. t['\u203E'] = '\u0020\u0305';
  21747. t['\u2047'] = '\u003F\u003F';
  21748. t['\u2048'] = '\u003F\u0021';
  21749. t['\u2049'] = '\u0021\u003F';
  21750. t['\u2057'] = '\u2032\u2032\u2032\u2032';
  21751. t['\u205F'] = '\u0020';
  21752. t['\u20A8'] = '\u0052\u0073';
  21753. t['\u2100'] = '\u0061\u002F\u0063';
  21754. t['\u2101'] = '\u0061\u002F\u0073';
  21755. t['\u2103'] = '\u00B0\u0043';
  21756. t['\u2105'] = '\u0063\u002F\u006F';
  21757. t['\u2106'] = '\u0063\u002F\u0075';
  21758. t['\u2107'] = '\u0190';
  21759. t['\u2109'] = '\u00B0\u0046';
  21760. t['\u2116'] = '\u004E\u006F';
  21761. t['\u2121'] = '\u0054\u0045\u004C';
  21762. t['\u2135'] = '\u05D0';
  21763. t['\u2136'] = '\u05D1';
  21764. t['\u2137'] = '\u05D2';
  21765. t['\u2138'] = '\u05D3';
  21766. t['\u213B'] = '\u0046\u0041\u0058';
  21767. t['\u2160'] = '\u0049';
  21768. t['\u2161'] = '\u0049\u0049';
  21769. t['\u2162'] = '\u0049\u0049\u0049';
  21770. t['\u2163'] = '\u0049\u0056';
  21771. t['\u2164'] = '\u0056';
  21772. t['\u2165'] = '\u0056\u0049';
  21773. t['\u2166'] = '\u0056\u0049\u0049';
  21774. t['\u2167'] = '\u0056\u0049\u0049\u0049';
  21775. t['\u2168'] = '\u0049\u0058';
  21776. t['\u2169'] = '\u0058';
  21777. t['\u216A'] = '\u0058\u0049';
  21778. t['\u216B'] = '\u0058\u0049\u0049';
  21779. t['\u216C'] = '\u004C';
  21780. t['\u216D'] = '\u0043';
  21781. t['\u216E'] = '\u0044';
  21782. t['\u216F'] = '\u004D';
  21783. t['\u2170'] = '\u0069';
  21784. t['\u2171'] = '\u0069\u0069';
  21785. t['\u2172'] = '\u0069\u0069\u0069';
  21786. t['\u2173'] = '\u0069\u0076';
  21787. t['\u2174'] = '\u0076';
  21788. t['\u2175'] = '\u0076\u0069';
  21789. t['\u2176'] = '\u0076\u0069\u0069';
  21790. t['\u2177'] = '\u0076\u0069\u0069\u0069';
  21791. t['\u2178'] = '\u0069\u0078';
  21792. t['\u2179'] = '\u0078';
  21793. t['\u217A'] = '\u0078\u0069';
  21794. t['\u217B'] = '\u0078\u0069\u0069';
  21795. t['\u217C'] = '\u006C';
  21796. t['\u217D'] = '\u0063';
  21797. t['\u217E'] = '\u0064';
  21798. t['\u217F'] = '\u006D';
  21799. t['\u222C'] = '\u222B\u222B';
  21800. t['\u222D'] = '\u222B\u222B\u222B';
  21801. t['\u222F'] = '\u222E\u222E';
  21802. t['\u2230'] = '\u222E\u222E\u222E';
  21803. t['\u2474'] = '\u0028\u0031\u0029';
  21804. t['\u2475'] = '\u0028\u0032\u0029';
  21805. t['\u2476'] = '\u0028\u0033\u0029';
  21806. t['\u2477'] = '\u0028\u0034\u0029';
  21807. t['\u2478'] = '\u0028\u0035\u0029';
  21808. t['\u2479'] = '\u0028\u0036\u0029';
  21809. t['\u247A'] = '\u0028\u0037\u0029';
  21810. t['\u247B'] = '\u0028\u0038\u0029';
  21811. t['\u247C'] = '\u0028\u0039\u0029';
  21812. t['\u247D'] = '\u0028\u0031\u0030\u0029';
  21813. t['\u247E'] = '\u0028\u0031\u0031\u0029';
  21814. t['\u247F'] = '\u0028\u0031\u0032\u0029';
  21815. t['\u2480'] = '\u0028\u0031\u0033\u0029';
  21816. t['\u2481'] = '\u0028\u0031\u0034\u0029';
  21817. t['\u2482'] = '\u0028\u0031\u0035\u0029';
  21818. t['\u2483'] = '\u0028\u0031\u0036\u0029';
  21819. t['\u2484'] = '\u0028\u0031\u0037\u0029';
  21820. t['\u2485'] = '\u0028\u0031\u0038\u0029';
  21821. t['\u2486'] = '\u0028\u0031\u0039\u0029';
  21822. t['\u2487'] = '\u0028\u0032\u0030\u0029';
  21823. t['\u2488'] = '\u0031\u002E';
  21824. t['\u2489'] = '\u0032\u002E';
  21825. t['\u248A'] = '\u0033\u002E';
  21826. t['\u248B'] = '\u0034\u002E';
  21827. t['\u248C'] = '\u0035\u002E';
  21828. t['\u248D'] = '\u0036\u002E';
  21829. t['\u248E'] = '\u0037\u002E';
  21830. t['\u248F'] = '\u0038\u002E';
  21831. t['\u2490'] = '\u0039\u002E';
  21832. t['\u2491'] = '\u0031\u0030\u002E';
  21833. t['\u2492'] = '\u0031\u0031\u002E';
  21834. t['\u2493'] = '\u0031\u0032\u002E';
  21835. t['\u2494'] = '\u0031\u0033\u002E';
  21836. t['\u2495'] = '\u0031\u0034\u002E';
  21837. t['\u2496'] = '\u0031\u0035\u002E';
  21838. t['\u2497'] = '\u0031\u0036\u002E';
  21839. t['\u2498'] = '\u0031\u0037\u002E';
  21840. t['\u2499'] = '\u0031\u0038\u002E';
  21841. t['\u249A'] = '\u0031\u0039\u002E';
  21842. t['\u249B'] = '\u0032\u0030\u002E';
  21843. t['\u249C'] = '\u0028\u0061\u0029';
  21844. t['\u249D'] = '\u0028\u0062\u0029';
  21845. t['\u249E'] = '\u0028\u0063\u0029';
  21846. t['\u249F'] = '\u0028\u0064\u0029';
  21847. t['\u24A0'] = '\u0028\u0065\u0029';
  21848. t['\u24A1'] = '\u0028\u0066\u0029';
  21849. t['\u24A2'] = '\u0028\u0067\u0029';
  21850. t['\u24A3'] = '\u0028\u0068\u0029';
  21851. t['\u24A4'] = '\u0028\u0069\u0029';
  21852. t['\u24A5'] = '\u0028\u006A\u0029';
  21853. t['\u24A6'] = '\u0028\u006B\u0029';
  21854. t['\u24A7'] = '\u0028\u006C\u0029';
  21855. t['\u24A8'] = '\u0028\u006D\u0029';
  21856. t['\u24A9'] = '\u0028\u006E\u0029';
  21857. t['\u24AA'] = '\u0028\u006F\u0029';
  21858. t['\u24AB'] = '\u0028\u0070\u0029';
  21859. t['\u24AC'] = '\u0028\u0071\u0029';
  21860. t['\u24AD'] = '\u0028\u0072\u0029';
  21861. t['\u24AE'] = '\u0028\u0073\u0029';
  21862. t['\u24AF'] = '\u0028\u0074\u0029';
  21863. t['\u24B0'] = '\u0028\u0075\u0029';
  21864. t['\u24B1'] = '\u0028\u0076\u0029';
  21865. t['\u24B2'] = '\u0028\u0077\u0029';
  21866. t['\u24B3'] = '\u0028\u0078\u0029';
  21867. t['\u24B4'] = '\u0028\u0079\u0029';
  21868. t['\u24B5'] = '\u0028\u007A\u0029';
  21869. t['\u2A0C'] = '\u222B\u222B\u222B\u222B';
  21870. t['\u2A74'] = '\u003A\u003A\u003D';
  21871. t['\u2A75'] = '\u003D\u003D';
  21872. t['\u2A76'] = '\u003D\u003D\u003D';
  21873. t['\u2E9F'] = '\u6BCD';
  21874. t['\u2EF3'] = '\u9F9F';
  21875. t['\u2F00'] = '\u4E00';
  21876. t['\u2F01'] = '\u4E28';
  21877. t['\u2F02'] = '\u4E36';
  21878. t['\u2F03'] = '\u4E3F';
  21879. t['\u2F04'] = '\u4E59';
  21880. t['\u2F05'] = '\u4E85';
  21881. t['\u2F06'] = '\u4E8C';
  21882. t['\u2F07'] = '\u4EA0';
  21883. t['\u2F08'] = '\u4EBA';
  21884. t['\u2F09'] = '\u513F';
  21885. t['\u2F0A'] = '\u5165';
  21886. t['\u2F0B'] = '\u516B';
  21887. t['\u2F0C'] = '\u5182';
  21888. t['\u2F0D'] = '\u5196';
  21889. t['\u2F0E'] = '\u51AB';
  21890. t['\u2F0F'] = '\u51E0';
  21891. t['\u2F10'] = '\u51F5';
  21892. t['\u2F11'] = '\u5200';
  21893. t['\u2F12'] = '\u529B';
  21894. t['\u2F13'] = '\u52F9';
  21895. t['\u2F14'] = '\u5315';
  21896. t['\u2F15'] = '\u531A';
  21897. t['\u2F16'] = '\u5338';
  21898. t['\u2F17'] = '\u5341';
  21899. t['\u2F18'] = '\u535C';
  21900. t['\u2F19'] = '\u5369';
  21901. t['\u2F1A'] = '\u5382';
  21902. t['\u2F1B'] = '\u53B6';
  21903. t['\u2F1C'] = '\u53C8';
  21904. t['\u2F1D'] = '\u53E3';
  21905. t['\u2F1E'] = '\u56D7';
  21906. t['\u2F1F'] = '\u571F';
  21907. t['\u2F20'] = '\u58EB';
  21908. t['\u2F21'] = '\u5902';
  21909. t['\u2F22'] = '\u590A';
  21910. t['\u2F23'] = '\u5915';
  21911. t['\u2F24'] = '\u5927';
  21912. t['\u2F25'] = '\u5973';
  21913. t['\u2F26'] = '\u5B50';
  21914. t['\u2F27'] = '\u5B80';
  21915. t['\u2F28'] = '\u5BF8';
  21916. t['\u2F29'] = '\u5C0F';
  21917. t['\u2F2A'] = '\u5C22';
  21918. t['\u2F2B'] = '\u5C38';
  21919. t['\u2F2C'] = '\u5C6E';
  21920. t['\u2F2D'] = '\u5C71';
  21921. t['\u2F2E'] = '\u5DDB';
  21922. t['\u2F2F'] = '\u5DE5';
  21923. t['\u2F30'] = '\u5DF1';
  21924. t['\u2F31'] = '\u5DFE';
  21925. t['\u2F32'] = '\u5E72';
  21926. t['\u2F33'] = '\u5E7A';
  21927. t['\u2F34'] = '\u5E7F';
  21928. t['\u2F35'] = '\u5EF4';
  21929. t['\u2F36'] = '\u5EFE';
  21930. t['\u2F37'] = '\u5F0B';
  21931. t['\u2F38'] = '\u5F13';
  21932. t['\u2F39'] = '\u5F50';
  21933. t['\u2F3A'] = '\u5F61';
  21934. t['\u2F3B'] = '\u5F73';
  21935. t['\u2F3C'] = '\u5FC3';
  21936. t['\u2F3D'] = '\u6208';
  21937. t['\u2F3E'] = '\u6236';
  21938. t['\u2F3F'] = '\u624B';
  21939. t['\u2F40'] = '\u652F';
  21940. t['\u2F41'] = '\u6534';
  21941. t['\u2F42'] = '\u6587';
  21942. t['\u2F43'] = '\u6597';
  21943. t['\u2F44'] = '\u65A4';
  21944. t['\u2F45'] = '\u65B9';
  21945. t['\u2F46'] = '\u65E0';
  21946. t['\u2F47'] = '\u65E5';
  21947. t['\u2F48'] = '\u66F0';
  21948. t['\u2F49'] = '\u6708';
  21949. t['\u2F4A'] = '\u6728';
  21950. t['\u2F4B'] = '\u6B20';
  21951. t['\u2F4C'] = '\u6B62';
  21952. t['\u2F4D'] = '\u6B79';
  21953. t['\u2F4E'] = '\u6BB3';
  21954. t['\u2F4F'] = '\u6BCB';
  21955. t['\u2F50'] = '\u6BD4';
  21956. t['\u2F51'] = '\u6BDB';
  21957. t['\u2F52'] = '\u6C0F';
  21958. t['\u2F53'] = '\u6C14';
  21959. t['\u2F54'] = '\u6C34';
  21960. t['\u2F55'] = '\u706B';
  21961. t['\u2F56'] = '\u722A';
  21962. t['\u2F57'] = '\u7236';
  21963. t['\u2F58'] = '\u723B';
  21964. t['\u2F59'] = '\u723F';
  21965. t['\u2F5A'] = '\u7247';
  21966. t['\u2F5B'] = '\u7259';
  21967. t['\u2F5C'] = '\u725B';
  21968. t['\u2F5D'] = '\u72AC';
  21969. t['\u2F5E'] = '\u7384';
  21970. t['\u2F5F'] = '\u7389';
  21971. t['\u2F60'] = '\u74DC';
  21972. t['\u2F61'] = '\u74E6';
  21973. t['\u2F62'] = '\u7518';
  21974. t['\u2F63'] = '\u751F';
  21975. t['\u2F64'] = '\u7528';
  21976. t['\u2F65'] = '\u7530';
  21977. t['\u2F66'] = '\u758B';
  21978. t['\u2F67'] = '\u7592';
  21979. t['\u2F68'] = '\u7676';
  21980. t['\u2F69'] = '\u767D';
  21981. t['\u2F6A'] = '\u76AE';
  21982. t['\u2F6B'] = '\u76BF';
  21983. t['\u2F6C'] = '\u76EE';
  21984. t['\u2F6D'] = '\u77DB';
  21985. t['\u2F6E'] = '\u77E2';
  21986. t['\u2F6F'] = '\u77F3';
  21987. t['\u2F70'] = '\u793A';
  21988. t['\u2F71'] = '\u79B8';
  21989. t['\u2F72'] = '\u79BE';
  21990. t['\u2F73'] = '\u7A74';
  21991. t['\u2F74'] = '\u7ACB';
  21992. t['\u2F75'] = '\u7AF9';
  21993. t['\u2F76'] = '\u7C73';
  21994. t['\u2F77'] = '\u7CF8';
  21995. t['\u2F78'] = '\u7F36';
  21996. t['\u2F79'] = '\u7F51';
  21997. t['\u2F7A'] = '\u7F8A';
  21998. t['\u2F7B'] = '\u7FBD';
  21999. t['\u2F7C'] = '\u8001';
  22000. t['\u2F7D'] = '\u800C';
  22001. t['\u2F7E'] = '\u8012';
  22002. t['\u2F7F'] = '\u8033';
  22003. t['\u2F80'] = '\u807F';
  22004. t['\u2F81'] = '\u8089';
  22005. t['\u2F82'] = '\u81E3';
  22006. t['\u2F83'] = '\u81EA';
  22007. t['\u2F84'] = '\u81F3';
  22008. t['\u2F85'] = '\u81FC';
  22009. t['\u2F86'] = '\u820C';
  22010. t['\u2F87'] = '\u821B';
  22011. t['\u2F88'] = '\u821F';
  22012. t['\u2F89'] = '\u826E';
  22013. t['\u2F8A'] = '\u8272';
  22014. t['\u2F8B'] = '\u8278';
  22015. t['\u2F8C'] = '\u864D';
  22016. t['\u2F8D'] = '\u866B';
  22017. t['\u2F8E'] = '\u8840';
  22018. t['\u2F8F'] = '\u884C';
  22019. t['\u2F90'] = '\u8863';
  22020. t['\u2F91'] = '\u897E';
  22021. t['\u2F92'] = '\u898B';
  22022. t['\u2F93'] = '\u89D2';
  22023. t['\u2F94'] = '\u8A00';
  22024. t['\u2F95'] = '\u8C37';
  22025. t['\u2F96'] = '\u8C46';
  22026. t['\u2F97'] = '\u8C55';
  22027. t['\u2F98'] = '\u8C78';
  22028. t['\u2F99'] = '\u8C9D';
  22029. t['\u2F9A'] = '\u8D64';
  22030. t['\u2F9B'] = '\u8D70';
  22031. t['\u2F9C'] = '\u8DB3';
  22032. t['\u2F9D'] = '\u8EAB';
  22033. t['\u2F9E'] = '\u8ECA';
  22034. t['\u2F9F'] = '\u8F9B';
  22035. t['\u2FA0'] = '\u8FB0';
  22036. t['\u2FA1'] = '\u8FB5';
  22037. t['\u2FA2'] = '\u9091';
  22038. t['\u2FA3'] = '\u9149';
  22039. t['\u2FA4'] = '\u91C6';
  22040. t['\u2FA5'] = '\u91CC';
  22041. t['\u2FA6'] = '\u91D1';
  22042. t['\u2FA7'] = '\u9577';
  22043. t['\u2FA8'] = '\u9580';
  22044. t['\u2FA9'] = '\u961C';
  22045. t['\u2FAA'] = '\u96B6';
  22046. t['\u2FAB'] = '\u96B9';
  22047. t['\u2FAC'] = '\u96E8';
  22048. t['\u2FAD'] = '\u9751';
  22049. t['\u2FAE'] = '\u975E';
  22050. t['\u2FAF'] = '\u9762';
  22051. t['\u2FB0'] = '\u9769';
  22052. t['\u2FB1'] = '\u97CB';
  22053. t['\u2FB2'] = '\u97ED';
  22054. t['\u2FB3'] = '\u97F3';
  22055. t['\u2FB4'] = '\u9801';
  22056. t['\u2FB5'] = '\u98A8';
  22057. t['\u2FB6'] = '\u98DB';
  22058. t['\u2FB7'] = '\u98DF';
  22059. t['\u2FB8'] = '\u9996';
  22060. t['\u2FB9'] = '\u9999';
  22061. t['\u2FBA'] = '\u99AC';
  22062. t['\u2FBB'] = '\u9AA8';
  22063. t['\u2FBC'] = '\u9AD8';
  22064. t['\u2FBD'] = '\u9ADF';
  22065. t['\u2FBE'] = '\u9B25';
  22066. t['\u2FBF'] = '\u9B2F';
  22067. t['\u2FC0'] = '\u9B32';
  22068. t['\u2FC1'] = '\u9B3C';
  22069. t['\u2FC2'] = '\u9B5A';
  22070. t['\u2FC3'] = '\u9CE5';
  22071. t['\u2FC4'] = '\u9E75';
  22072. t['\u2FC5'] = '\u9E7F';
  22073. t['\u2FC6'] = '\u9EA5';
  22074. t['\u2FC7'] = '\u9EBB';
  22075. t['\u2FC8'] = '\u9EC3';
  22076. t['\u2FC9'] = '\u9ECD';
  22077. t['\u2FCA'] = '\u9ED1';
  22078. t['\u2FCB'] = '\u9EF9';
  22079. t['\u2FCC'] = '\u9EFD';
  22080. t['\u2FCD'] = '\u9F0E';
  22081. t['\u2FCE'] = '\u9F13';
  22082. t['\u2FCF'] = '\u9F20';
  22083. t['\u2FD0'] = '\u9F3B';
  22084. t['\u2FD1'] = '\u9F4A';
  22085. t['\u2FD2'] = '\u9F52';
  22086. t['\u2FD3'] = '\u9F8D';
  22087. t['\u2FD4'] = '\u9F9C';
  22088. t['\u2FD5'] = '\u9FA0';
  22089. t['\u3036'] = '\u3012';
  22090. t['\u3038'] = '\u5341';
  22091. t['\u3039'] = '\u5344';
  22092. t['\u303A'] = '\u5345';
  22093. t['\u309B'] = '\u0020\u3099';
  22094. t['\u309C'] = '\u0020\u309A';
  22095. t['\u3131'] = '\u1100';
  22096. t['\u3132'] = '\u1101';
  22097. t['\u3133'] = '\u11AA';
  22098. t['\u3134'] = '\u1102';
  22099. t['\u3135'] = '\u11AC';
  22100. t['\u3136'] = '\u11AD';
  22101. t['\u3137'] = '\u1103';
  22102. t['\u3138'] = '\u1104';
  22103. t['\u3139'] = '\u1105';
  22104. t['\u313A'] = '\u11B0';
  22105. t['\u313B'] = '\u11B1';
  22106. t['\u313C'] = '\u11B2';
  22107. t['\u313D'] = '\u11B3';
  22108. t['\u313E'] = '\u11B4';
  22109. t['\u313F'] = '\u11B5';
  22110. t['\u3140'] = '\u111A';
  22111. t['\u3141'] = '\u1106';
  22112. t['\u3142'] = '\u1107';
  22113. t['\u3143'] = '\u1108';
  22114. t['\u3144'] = '\u1121';
  22115. t['\u3145'] = '\u1109';
  22116. t['\u3146'] = '\u110A';
  22117. t['\u3147'] = '\u110B';
  22118. t['\u3148'] = '\u110C';
  22119. t['\u3149'] = '\u110D';
  22120. t['\u314A'] = '\u110E';
  22121. t['\u314B'] = '\u110F';
  22122. t['\u314C'] = '\u1110';
  22123. t['\u314D'] = '\u1111';
  22124. t['\u314E'] = '\u1112';
  22125. t['\u314F'] = '\u1161';
  22126. t['\u3150'] = '\u1162';
  22127. t['\u3151'] = '\u1163';
  22128. t['\u3152'] = '\u1164';
  22129. t['\u3153'] = '\u1165';
  22130. t['\u3154'] = '\u1166';
  22131. t['\u3155'] = '\u1167';
  22132. t['\u3156'] = '\u1168';
  22133. t['\u3157'] = '\u1169';
  22134. t['\u3158'] = '\u116A';
  22135. t['\u3159'] = '\u116B';
  22136. t['\u315A'] = '\u116C';
  22137. t['\u315B'] = '\u116D';
  22138. t['\u315C'] = '\u116E';
  22139. t['\u315D'] = '\u116F';
  22140. t['\u315E'] = '\u1170';
  22141. t['\u315F'] = '\u1171';
  22142. t['\u3160'] = '\u1172';
  22143. t['\u3161'] = '\u1173';
  22144. t['\u3162'] = '\u1174';
  22145. t['\u3163'] = '\u1175';
  22146. t['\u3164'] = '\u1160';
  22147. t['\u3165'] = '\u1114';
  22148. t['\u3166'] = '\u1115';
  22149. t['\u3167'] = '\u11C7';
  22150. t['\u3168'] = '\u11C8';
  22151. t['\u3169'] = '\u11CC';
  22152. t['\u316A'] = '\u11CE';
  22153. t['\u316B'] = '\u11D3';
  22154. t['\u316C'] = '\u11D7';
  22155. t['\u316D'] = '\u11D9';
  22156. t['\u316E'] = '\u111C';
  22157. t['\u316F'] = '\u11DD';
  22158. t['\u3170'] = '\u11DF';
  22159. t['\u3171'] = '\u111D';
  22160. t['\u3172'] = '\u111E';
  22161. t['\u3173'] = '\u1120';
  22162. t['\u3174'] = '\u1122';
  22163. t['\u3175'] = '\u1123';
  22164. t['\u3176'] = '\u1127';
  22165. t['\u3177'] = '\u1129';
  22166. t['\u3178'] = '\u112B';
  22167. t['\u3179'] = '\u112C';
  22168. t['\u317A'] = '\u112D';
  22169. t['\u317B'] = '\u112E';
  22170. t['\u317C'] = '\u112F';
  22171. t['\u317D'] = '\u1132';
  22172. t['\u317E'] = '\u1136';
  22173. t['\u317F'] = '\u1140';
  22174. t['\u3180'] = '\u1147';
  22175. t['\u3181'] = '\u114C';
  22176. t['\u3182'] = '\u11F1';
  22177. t['\u3183'] = '\u11F2';
  22178. t['\u3184'] = '\u1157';
  22179. t['\u3185'] = '\u1158';
  22180. t['\u3186'] = '\u1159';
  22181. t['\u3187'] = '\u1184';
  22182. t['\u3188'] = '\u1185';
  22183. t['\u3189'] = '\u1188';
  22184. t['\u318A'] = '\u1191';
  22185. t['\u318B'] = '\u1192';
  22186. t['\u318C'] = '\u1194';
  22187. t['\u318D'] = '\u119E';
  22188. t['\u318E'] = '\u11A1';
  22189. t['\u3200'] = '\u0028\u1100\u0029';
  22190. t['\u3201'] = '\u0028\u1102\u0029';
  22191. t['\u3202'] = '\u0028\u1103\u0029';
  22192. t['\u3203'] = '\u0028\u1105\u0029';
  22193. t['\u3204'] = '\u0028\u1106\u0029';
  22194. t['\u3205'] = '\u0028\u1107\u0029';
  22195. t['\u3206'] = '\u0028\u1109\u0029';
  22196. t['\u3207'] = '\u0028\u110B\u0029';
  22197. t['\u3208'] = '\u0028\u110C\u0029';
  22198. t['\u3209'] = '\u0028\u110E\u0029';
  22199. t['\u320A'] = '\u0028\u110F\u0029';
  22200. t['\u320B'] = '\u0028\u1110\u0029';
  22201. t['\u320C'] = '\u0028\u1111\u0029';
  22202. t['\u320D'] = '\u0028\u1112\u0029';
  22203. t['\u320E'] = '\u0028\u1100\u1161\u0029';
  22204. t['\u320F'] = '\u0028\u1102\u1161\u0029';
  22205. t['\u3210'] = '\u0028\u1103\u1161\u0029';
  22206. t['\u3211'] = '\u0028\u1105\u1161\u0029';
  22207. t['\u3212'] = '\u0028\u1106\u1161\u0029';
  22208. t['\u3213'] = '\u0028\u1107\u1161\u0029';
  22209. t['\u3214'] = '\u0028\u1109\u1161\u0029';
  22210. t['\u3215'] = '\u0028\u110B\u1161\u0029';
  22211. t['\u3216'] = '\u0028\u110C\u1161\u0029';
  22212. t['\u3217'] = '\u0028\u110E\u1161\u0029';
  22213. t['\u3218'] = '\u0028\u110F\u1161\u0029';
  22214. t['\u3219'] = '\u0028\u1110\u1161\u0029';
  22215. t['\u321A'] = '\u0028\u1111\u1161\u0029';
  22216. t['\u321B'] = '\u0028\u1112\u1161\u0029';
  22217. t['\u321C'] = '\u0028\u110C\u116E\u0029';
  22218. t['\u321D'] = '\u0028\u110B\u1169\u110C\u1165\u11AB\u0029';
  22219. t['\u321E'] = '\u0028\u110B\u1169\u1112\u116E\u0029';
  22220. t['\u3220'] = '\u0028\u4E00\u0029';
  22221. t['\u3221'] = '\u0028\u4E8C\u0029';
  22222. t['\u3222'] = '\u0028\u4E09\u0029';
  22223. t['\u3223'] = '\u0028\u56DB\u0029';
  22224. t['\u3224'] = '\u0028\u4E94\u0029';
  22225. t['\u3225'] = '\u0028\u516D\u0029';
  22226. t['\u3226'] = '\u0028\u4E03\u0029';
  22227. t['\u3227'] = '\u0028\u516B\u0029';
  22228. t['\u3228'] = '\u0028\u4E5D\u0029';
  22229. t['\u3229'] = '\u0028\u5341\u0029';
  22230. t['\u322A'] = '\u0028\u6708\u0029';
  22231. t['\u322B'] = '\u0028\u706B\u0029';
  22232. t['\u322C'] = '\u0028\u6C34\u0029';
  22233. t['\u322D'] = '\u0028\u6728\u0029';
  22234. t['\u322E'] = '\u0028\u91D1\u0029';
  22235. t['\u322F'] = '\u0028\u571F\u0029';
  22236. t['\u3230'] = '\u0028\u65E5\u0029';
  22237. t['\u3231'] = '\u0028\u682A\u0029';
  22238. t['\u3232'] = '\u0028\u6709\u0029';
  22239. t['\u3233'] = '\u0028\u793E\u0029';
  22240. t['\u3234'] = '\u0028\u540D\u0029';
  22241. t['\u3235'] = '\u0028\u7279\u0029';
  22242. t['\u3236'] = '\u0028\u8CA1\u0029';
  22243. t['\u3237'] = '\u0028\u795D\u0029';
  22244. t['\u3238'] = '\u0028\u52B4\u0029';
  22245. t['\u3239'] = '\u0028\u4EE3\u0029';
  22246. t['\u323A'] = '\u0028\u547C\u0029';
  22247. t['\u323B'] = '\u0028\u5B66\u0029';
  22248. t['\u323C'] = '\u0028\u76E3\u0029';
  22249. t['\u323D'] = '\u0028\u4F01\u0029';
  22250. t['\u323E'] = '\u0028\u8CC7\u0029';
  22251. t['\u323F'] = '\u0028\u5354\u0029';
  22252. t['\u3240'] = '\u0028\u796D\u0029';
  22253. t['\u3241'] = '\u0028\u4F11\u0029';
  22254. t['\u3242'] = '\u0028\u81EA\u0029';
  22255. t['\u3243'] = '\u0028\u81F3\u0029';
  22256. t['\u32C0'] = '\u0031\u6708';
  22257. t['\u32C1'] = '\u0032\u6708';
  22258. t['\u32C2'] = '\u0033\u6708';
  22259. t['\u32C3'] = '\u0034\u6708';
  22260. t['\u32C4'] = '\u0035\u6708';
  22261. t['\u32C5'] = '\u0036\u6708';
  22262. t['\u32C6'] = '\u0037\u6708';
  22263. t['\u32C7'] = '\u0038\u6708';
  22264. t['\u32C8'] = '\u0039\u6708';
  22265. t['\u32C9'] = '\u0031\u0030\u6708';
  22266. t['\u32CA'] = '\u0031\u0031\u6708';
  22267. t['\u32CB'] = '\u0031\u0032\u6708';
  22268. t['\u3358'] = '\u0030\u70B9';
  22269. t['\u3359'] = '\u0031\u70B9';
  22270. t['\u335A'] = '\u0032\u70B9';
  22271. t['\u335B'] = '\u0033\u70B9';
  22272. t['\u335C'] = '\u0034\u70B9';
  22273. t['\u335D'] = '\u0035\u70B9';
  22274. t['\u335E'] = '\u0036\u70B9';
  22275. t['\u335F'] = '\u0037\u70B9';
  22276. t['\u3360'] = '\u0038\u70B9';
  22277. t['\u3361'] = '\u0039\u70B9';
  22278. t['\u3362'] = '\u0031\u0030\u70B9';
  22279. t['\u3363'] = '\u0031\u0031\u70B9';
  22280. t['\u3364'] = '\u0031\u0032\u70B9';
  22281. t['\u3365'] = '\u0031\u0033\u70B9';
  22282. t['\u3366'] = '\u0031\u0034\u70B9';
  22283. t['\u3367'] = '\u0031\u0035\u70B9';
  22284. t['\u3368'] = '\u0031\u0036\u70B9';
  22285. t['\u3369'] = '\u0031\u0037\u70B9';
  22286. t['\u336A'] = '\u0031\u0038\u70B9';
  22287. t['\u336B'] = '\u0031\u0039\u70B9';
  22288. t['\u336C'] = '\u0032\u0030\u70B9';
  22289. t['\u336D'] = '\u0032\u0031\u70B9';
  22290. t['\u336E'] = '\u0032\u0032\u70B9';
  22291. t['\u336F'] = '\u0032\u0033\u70B9';
  22292. t['\u3370'] = '\u0032\u0034\u70B9';
  22293. t['\u33E0'] = '\u0031\u65E5';
  22294. t['\u33E1'] = '\u0032\u65E5';
  22295. t['\u33E2'] = '\u0033\u65E5';
  22296. t['\u33E3'] = '\u0034\u65E5';
  22297. t['\u33E4'] = '\u0035\u65E5';
  22298. t['\u33E5'] = '\u0036\u65E5';
  22299. t['\u33E6'] = '\u0037\u65E5';
  22300. t['\u33E7'] = '\u0038\u65E5';
  22301. t['\u33E8'] = '\u0039\u65E5';
  22302. t['\u33E9'] = '\u0031\u0030\u65E5';
  22303. t['\u33EA'] = '\u0031\u0031\u65E5';
  22304. t['\u33EB'] = '\u0031\u0032\u65E5';
  22305. t['\u33EC'] = '\u0031\u0033\u65E5';
  22306. t['\u33ED'] = '\u0031\u0034\u65E5';
  22307. t['\u33EE'] = '\u0031\u0035\u65E5';
  22308. t['\u33EF'] = '\u0031\u0036\u65E5';
  22309. t['\u33F0'] = '\u0031\u0037\u65E5';
  22310. t['\u33F1'] = '\u0031\u0038\u65E5';
  22311. t['\u33F2'] = '\u0031\u0039\u65E5';
  22312. t['\u33F3'] = '\u0032\u0030\u65E5';
  22313. t['\u33F4'] = '\u0032\u0031\u65E5';
  22314. t['\u33F5'] = '\u0032\u0032\u65E5';
  22315. t['\u33F6'] = '\u0032\u0033\u65E5';
  22316. t['\u33F7'] = '\u0032\u0034\u65E5';
  22317. t['\u33F8'] = '\u0032\u0035\u65E5';
  22318. t['\u33F9'] = '\u0032\u0036\u65E5';
  22319. t['\u33FA'] = '\u0032\u0037\u65E5';
  22320. t['\u33FB'] = '\u0032\u0038\u65E5';
  22321. t['\u33FC'] = '\u0032\u0039\u65E5';
  22322. t['\u33FD'] = '\u0033\u0030\u65E5';
  22323. t['\u33FE'] = '\u0033\u0031\u65E5';
  22324. t['\uFB00'] = '\u0066\u0066';
  22325. t['\uFB01'] = '\u0066\u0069';
  22326. t['\uFB02'] = '\u0066\u006C';
  22327. t['\uFB03'] = '\u0066\u0066\u0069';
  22328. t['\uFB04'] = '\u0066\u0066\u006C';
  22329. t['\uFB05'] = '\u017F\u0074';
  22330. t['\uFB06'] = '\u0073\u0074';
  22331. t['\uFB13'] = '\u0574\u0576';
  22332. t['\uFB14'] = '\u0574\u0565';
  22333. t['\uFB15'] = '\u0574\u056B';
  22334. t['\uFB16'] = '\u057E\u0576';
  22335. t['\uFB17'] = '\u0574\u056D';
  22336. t['\uFB4F'] = '\u05D0\u05DC';
  22337. t['\uFB50'] = '\u0671';
  22338. t['\uFB51'] = '\u0671';
  22339. t['\uFB52'] = '\u067B';
  22340. t['\uFB53'] = '\u067B';
  22341. t['\uFB54'] = '\u067B';
  22342. t['\uFB55'] = '\u067B';
  22343. t['\uFB56'] = '\u067E';
  22344. t['\uFB57'] = '\u067E';
  22345. t['\uFB58'] = '\u067E';
  22346. t['\uFB59'] = '\u067E';
  22347. t['\uFB5A'] = '\u0680';
  22348. t['\uFB5B'] = '\u0680';
  22349. t['\uFB5C'] = '\u0680';
  22350. t['\uFB5D'] = '\u0680';
  22351. t['\uFB5E'] = '\u067A';
  22352. t['\uFB5F'] = '\u067A';
  22353. t['\uFB60'] = '\u067A';
  22354. t['\uFB61'] = '\u067A';
  22355. t['\uFB62'] = '\u067F';
  22356. t['\uFB63'] = '\u067F';
  22357. t['\uFB64'] = '\u067F';
  22358. t['\uFB65'] = '\u067F';
  22359. t['\uFB66'] = '\u0679';
  22360. t['\uFB67'] = '\u0679';
  22361. t['\uFB68'] = '\u0679';
  22362. t['\uFB69'] = '\u0679';
  22363. t['\uFB6A'] = '\u06A4';
  22364. t['\uFB6B'] = '\u06A4';
  22365. t['\uFB6C'] = '\u06A4';
  22366. t['\uFB6D'] = '\u06A4';
  22367. t['\uFB6E'] = '\u06A6';
  22368. t['\uFB6F'] = '\u06A6';
  22369. t['\uFB70'] = '\u06A6';
  22370. t['\uFB71'] = '\u06A6';
  22371. t['\uFB72'] = '\u0684';
  22372. t['\uFB73'] = '\u0684';
  22373. t['\uFB74'] = '\u0684';
  22374. t['\uFB75'] = '\u0684';
  22375. t['\uFB76'] = '\u0683';
  22376. t['\uFB77'] = '\u0683';
  22377. t['\uFB78'] = '\u0683';
  22378. t['\uFB79'] = '\u0683';
  22379. t['\uFB7A'] = '\u0686';
  22380. t['\uFB7B'] = '\u0686';
  22381. t['\uFB7C'] = '\u0686';
  22382. t['\uFB7D'] = '\u0686';
  22383. t['\uFB7E'] = '\u0687';
  22384. t['\uFB7F'] = '\u0687';
  22385. t['\uFB80'] = '\u0687';
  22386. t['\uFB81'] = '\u0687';
  22387. t['\uFB82'] = '\u068D';
  22388. t['\uFB83'] = '\u068D';
  22389. t['\uFB84'] = '\u068C';
  22390. t['\uFB85'] = '\u068C';
  22391. t['\uFB86'] = '\u068E';
  22392. t['\uFB87'] = '\u068E';
  22393. t['\uFB88'] = '\u0688';
  22394. t['\uFB89'] = '\u0688';
  22395. t['\uFB8A'] = '\u0698';
  22396. t['\uFB8B'] = '\u0698';
  22397. t['\uFB8C'] = '\u0691';
  22398. t['\uFB8D'] = '\u0691';
  22399. t['\uFB8E'] = '\u06A9';
  22400. t['\uFB8F'] = '\u06A9';
  22401. t['\uFB90'] = '\u06A9';
  22402. t['\uFB91'] = '\u06A9';
  22403. t['\uFB92'] = '\u06AF';
  22404. t['\uFB93'] = '\u06AF';
  22405. t['\uFB94'] = '\u06AF';
  22406. t['\uFB95'] = '\u06AF';
  22407. t['\uFB96'] = '\u06B3';
  22408. t['\uFB97'] = '\u06B3';
  22409. t['\uFB98'] = '\u06B3';
  22410. t['\uFB99'] = '\u06B3';
  22411. t['\uFB9A'] = '\u06B1';
  22412. t['\uFB9B'] = '\u06B1';
  22413. t['\uFB9C'] = '\u06B1';
  22414. t['\uFB9D'] = '\u06B1';
  22415. t['\uFB9E'] = '\u06BA';
  22416. t['\uFB9F'] = '\u06BA';
  22417. t['\uFBA0'] = '\u06BB';
  22418. t['\uFBA1'] = '\u06BB';
  22419. t['\uFBA2'] = '\u06BB';
  22420. t['\uFBA3'] = '\u06BB';
  22421. t['\uFBA4'] = '\u06C0';
  22422. t['\uFBA5'] = '\u06C0';
  22423. t['\uFBA6'] = '\u06C1';
  22424. t['\uFBA7'] = '\u06C1';
  22425. t['\uFBA8'] = '\u06C1';
  22426. t['\uFBA9'] = '\u06C1';
  22427. t['\uFBAA'] = '\u06BE';
  22428. t['\uFBAB'] = '\u06BE';
  22429. t['\uFBAC'] = '\u06BE';
  22430. t['\uFBAD'] = '\u06BE';
  22431. t['\uFBAE'] = '\u06D2';
  22432. t['\uFBAF'] = '\u06D2';
  22433. t['\uFBB0'] = '\u06D3';
  22434. t['\uFBB1'] = '\u06D3';
  22435. t['\uFBD3'] = '\u06AD';
  22436. t['\uFBD4'] = '\u06AD';
  22437. t['\uFBD5'] = '\u06AD';
  22438. t['\uFBD6'] = '\u06AD';
  22439. t['\uFBD7'] = '\u06C7';
  22440. t['\uFBD8'] = '\u06C7';
  22441. t['\uFBD9'] = '\u06C6';
  22442. t['\uFBDA'] = '\u06C6';
  22443. t['\uFBDB'] = '\u06C8';
  22444. t['\uFBDC'] = '\u06C8';
  22445. t['\uFBDD'] = '\u0677';
  22446. t['\uFBDE'] = '\u06CB';
  22447. t['\uFBDF'] = '\u06CB';
  22448. t['\uFBE0'] = '\u06C5';
  22449. t['\uFBE1'] = '\u06C5';
  22450. t['\uFBE2'] = '\u06C9';
  22451. t['\uFBE3'] = '\u06C9';
  22452. t['\uFBE4'] = '\u06D0';
  22453. t['\uFBE5'] = '\u06D0';
  22454. t['\uFBE6'] = '\u06D0';
  22455. t['\uFBE7'] = '\u06D0';
  22456. t['\uFBE8'] = '\u0649';
  22457. t['\uFBE9'] = '\u0649';
  22458. t['\uFBEA'] = '\u0626\u0627';
  22459. t['\uFBEB'] = '\u0626\u0627';
  22460. t['\uFBEC'] = '\u0626\u06D5';
  22461. t['\uFBED'] = '\u0626\u06D5';
  22462. t['\uFBEE'] = '\u0626\u0648';
  22463. t['\uFBEF'] = '\u0626\u0648';
  22464. t['\uFBF0'] = '\u0626\u06C7';
  22465. t['\uFBF1'] = '\u0626\u06C7';
  22466. t['\uFBF2'] = '\u0626\u06C6';
  22467. t['\uFBF3'] = '\u0626\u06C6';
  22468. t['\uFBF4'] = '\u0626\u06C8';
  22469. t['\uFBF5'] = '\u0626\u06C8';
  22470. t['\uFBF6'] = '\u0626\u06D0';
  22471. t['\uFBF7'] = '\u0626\u06D0';
  22472. t['\uFBF8'] = '\u0626\u06D0';
  22473. t['\uFBF9'] = '\u0626\u0649';
  22474. t['\uFBFA'] = '\u0626\u0649';
  22475. t['\uFBFB'] = '\u0626\u0649';
  22476. t['\uFBFC'] = '\u06CC';
  22477. t['\uFBFD'] = '\u06CC';
  22478. t['\uFBFE'] = '\u06CC';
  22479. t['\uFBFF'] = '\u06CC';
  22480. t['\uFC00'] = '\u0626\u062C';
  22481. t['\uFC01'] = '\u0626\u062D';
  22482. t['\uFC02'] = '\u0626\u0645';
  22483. t['\uFC03'] = '\u0626\u0649';
  22484. t['\uFC04'] = '\u0626\u064A';
  22485. t['\uFC05'] = '\u0628\u062C';
  22486. t['\uFC06'] = '\u0628\u062D';
  22487. t['\uFC07'] = '\u0628\u062E';
  22488. t['\uFC08'] = '\u0628\u0645';
  22489. t['\uFC09'] = '\u0628\u0649';
  22490. t['\uFC0A'] = '\u0628\u064A';
  22491. t['\uFC0B'] = '\u062A\u062C';
  22492. t['\uFC0C'] = '\u062A\u062D';
  22493. t['\uFC0D'] = '\u062A\u062E';
  22494. t['\uFC0E'] = '\u062A\u0645';
  22495. t['\uFC0F'] = '\u062A\u0649';
  22496. t['\uFC10'] = '\u062A\u064A';
  22497. t['\uFC11'] = '\u062B\u062C';
  22498. t['\uFC12'] = '\u062B\u0645';
  22499. t['\uFC13'] = '\u062B\u0649';
  22500. t['\uFC14'] = '\u062B\u064A';
  22501. t['\uFC15'] = '\u062C\u062D';
  22502. t['\uFC16'] = '\u062C\u0645';
  22503. t['\uFC17'] = '\u062D\u062C';
  22504. t['\uFC18'] = '\u062D\u0645';
  22505. t['\uFC19'] = '\u062E\u062C';
  22506. t['\uFC1A'] = '\u062E\u062D';
  22507. t['\uFC1B'] = '\u062E\u0645';
  22508. t['\uFC1C'] = '\u0633\u062C';
  22509. t['\uFC1D'] = '\u0633\u062D';
  22510. t['\uFC1E'] = '\u0633\u062E';
  22511. t['\uFC1F'] = '\u0633\u0645';
  22512. t['\uFC20'] = '\u0635\u062D';
  22513. t['\uFC21'] = '\u0635\u0645';
  22514. t['\uFC22'] = '\u0636\u062C';
  22515. t['\uFC23'] = '\u0636\u062D';
  22516. t['\uFC24'] = '\u0636\u062E';
  22517. t['\uFC25'] = '\u0636\u0645';
  22518. t['\uFC26'] = '\u0637\u062D';
  22519. t['\uFC27'] = '\u0637\u0645';
  22520. t['\uFC28'] = '\u0638\u0645';
  22521. t['\uFC29'] = '\u0639\u062C';
  22522. t['\uFC2A'] = '\u0639\u0645';
  22523. t['\uFC2B'] = '\u063A\u062C';
  22524. t['\uFC2C'] = '\u063A\u0645';
  22525. t['\uFC2D'] = '\u0641\u062C';
  22526. t['\uFC2E'] = '\u0641\u062D';
  22527. t['\uFC2F'] = '\u0641\u062E';
  22528. t['\uFC30'] = '\u0641\u0645';
  22529. t['\uFC31'] = '\u0641\u0649';
  22530. t['\uFC32'] = '\u0641\u064A';
  22531. t['\uFC33'] = '\u0642\u062D';
  22532. t['\uFC34'] = '\u0642\u0645';
  22533. t['\uFC35'] = '\u0642\u0649';
  22534. t['\uFC36'] = '\u0642\u064A';
  22535. t['\uFC37'] = '\u0643\u0627';
  22536. t['\uFC38'] = '\u0643\u062C';
  22537. t['\uFC39'] = '\u0643\u062D';
  22538. t['\uFC3A'] = '\u0643\u062E';
  22539. t['\uFC3B'] = '\u0643\u0644';
  22540. t['\uFC3C'] = '\u0643\u0645';
  22541. t['\uFC3D'] = '\u0643\u0649';
  22542. t['\uFC3E'] = '\u0643\u064A';
  22543. t['\uFC3F'] = '\u0644\u062C';
  22544. t['\uFC40'] = '\u0644\u062D';
  22545. t['\uFC41'] = '\u0644\u062E';
  22546. t['\uFC42'] = '\u0644\u0645';
  22547. t['\uFC43'] = '\u0644\u0649';
  22548. t['\uFC44'] = '\u0644\u064A';
  22549. t['\uFC45'] = '\u0645\u062C';
  22550. t['\uFC46'] = '\u0645\u062D';
  22551. t['\uFC47'] = '\u0645\u062E';
  22552. t['\uFC48'] = '\u0645\u0645';
  22553. t['\uFC49'] = '\u0645\u0649';
  22554. t['\uFC4A'] = '\u0645\u064A';
  22555. t['\uFC4B'] = '\u0646\u062C';
  22556. t['\uFC4C'] = '\u0646\u062D';
  22557. t['\uFC4D'] = '\u0646\u062E';
  22558. t['\uFC4E'] = '\u0646\u0645';
  22559. t['\uFC4F'] = '\u0646\u0649';
  22560. t['\uFC50'] = '\u0646\u064A';
  22561. t['\uFC51'] = '\u0647\u062C';
  22562. t['\uFC52'] = '\u0647\u0645';
  22563. t['\uFC53'] = '\u0647\u0649';
  22564. t['\uFC54'] = '\u0647\u064A';
  22565. t['\uFC55'] = '\u064A\u062C';
  22566. t['\uFC56'] = '\u064A\u062D';
  22567. t['\uFC57'] = '\u064A\u062E';
  22568. t['\uFC58'] = '\u064A\u0645';
  22569. t['\uFC59'] = '\u064A\u0649';
  22570. t['\uFC5A'] = '\u064A\u064A';
  22571. t['\uFC5B'] = '\u0630\u0670';
  22572. t['\uFC5C'] = '\u0631\u0670';
  22573. t['\uFC5D'] = '\u0649\u0670';
  22574. t['\uFC5E'] = '\u0020\u064C\u0651';
  22575. t['\uFC5F'] = '\u0020\u064D\u0651';
  22576. t['\uFC60'] = '\u0020\u064E\u0651';
  22577. t['\uFC61'] = '\u0020\u064F\u0651';
  22578. t['\uFC62'] = '\u0020\u0650\u0651';
  22579. t['\uFC63'] = '\u0020\u0651\u0670';
  22580. t['\uFC64'] = '\u0626\u0631';
  22581. t['\uFC65'] = '\u0626\u0632';
  22582. t['\uFC66'] = '\u0626\u0645';
  22583. t['\uFC67'] = '\u0626\u0646';
  22584. t['\uFC68'] = '\u0626\u0649';
  22585. t['\uFC69'] = '\u0626\u064A';
  22586. t['\uFC6A'] = '\u0628\u0631';
  22587. t['\uFC6B'] = '\u0628\u0632';
  22588. t['\uFC6C'] = '\u0628\u0645';
  22589. t['\uFC6D'] = '\u0628\u0646';
  22590. t['\uFC6E'] = '\u0628\u0649';
  22591. t['\uFC6F'] = '\u0628\u064A';
  22592. t['\uFC70'] = '\u062A\u0631';
  22593. t['\uFC71'] = '\u062A\u0632';
  22594. t['\uFC72'] = '\u062A\u0645';
  22595. t['\uFC73'] = '\u062A\u0646';
  22596. t['\uFC74'] = '\u062A\u0649';
  22597. t['\uFC75'] = '\u062A\u064A';
  22598. t['\uFC76'] = '\u062B\u0631';
  22599. t['\uFC77'] = '\u062B\u0632';
  22600. t['\uFC78'] = '\u062B\u0645';
  22601. t['\uFC79'] = '\u062B\u0646';
  22602. t['\uFC7A'] = '\u062B\u0649';
  22603. t['\uFC7B'] = '\u062B\u064A';
  22604. t['\uFC7C'] = '\u0641\u0649';
  22605. t['\uFC7D'] = '\u0641\u064A';
  22606. t['\uFC7E'] = '\u0642\u0649';
  22607. t['\uFC7F'] = '\u0642\u064A';
  22608. t['\uFC80'] = '\u0643\u0627';
  22609. t['\uFC81'] = '\u0643\u0644';
  22610. t['\uFC82'] = '\u0643\u0645';
  22611. t['\uFC83'] = '\u0643\u0649';
  22612. t['\uFC84'] = '\u0643\u064A';
  22613. t['\uFC85'] = '\u0644\u0645';
  22614. t['\uFC86'] = '\u0644\u0649';
  22615. t['\uFC87'] = '\u0644\u064A';
  22616. t['\uFC88'] = '\u0645\u0627';
  22617. t['\uFC89'] = '\u0645\u0645';
  22618. t['\uFC8A'] = '\u0646\u0631';
  22619. t['\uFC8B'] = '\u0646\u0632';
  22620. t['\uFC8C'] = '\u0646\u0645';
  22621. t['\uFC8D'] = '\u0646\u0646';
  22622. t['\uFC8E'] = '\u0646\u0649';
  22623. t['\uFC8F'] = '\u0646\u064A';
  22624. t['\uFC90'] = '\u0649\u0670';
  22625. t['\uFC91'] = '\u064A\u0631';
  22626. t['\uFC92'] = '\u064A\u0632';
  22627. t['\uFC93'] = '\u064A\u0645';
  22628. t['\uFC94'] = '\u064A\u0646';
  22629. t['\uFC95'] = '\u064A\u0649';
  22630. t['\uFC96'] = '\u064A\u064A';
  22631. t['\uFC97'] = '\u0626\u062C';
  22632. t['\uFC98'] = '\u0626\u062D';
  22633. t['\uFC99'] = '\u0626\u062E';
  22634. t['\uFC9A'] = '\u0626\u0645';
  22635. t['\uFC9B'] = '\u0626\u0647';
  22636. t['\uFC9C'] = '\u0628\u062C';
  22637. t['\uFC9D'] = '\u0628\u062D';
  22638. t['\uFC9E'] = '\u0628\u062E';
  22639. t['\uFC9F'] = '\u0628\u0645';
  22640. t['\uFCA0'] = '\u0628\u0647';
  22641. t['\uFCA1'] = '\u062A\u062C';
  22642. t['\uFCA2'] = '\u062A\u062D';
  22643. t['\uFCA3'] = '\u062A\u062E';
  22644. t['\uFCA4'] = '\u062A\u0645';
  22645. t['\uFCA5'] = '\u062A\u0647';
  22646. t['\uFCA6'] = '\u062B\u0645';
  22647. t['\uFCA7'] = '\u062C\u062D';
  22648. t['\uFCA8'] = '\u062C\u0645';
  22649. t['\uFCA9'] = '\u062D\u062C';
  22650. t['\uFCAA'] = '\u062D\u0645';
  22651. t['\uFCAB'] = '\u062E\u062C';
  22652. t['\uFCAC'] = '\u062E\u0645';
  22653. t['\uFCAD'] = '\u0633\u062C';
  22654. t['\uFCAE'] = '\u0633\u062D';
  22655. t['\uFCAF'] = '\u0633\u062E';
  22656. t['\uFCB0'] = '\u0633\u0645';
  22657. t['\uFCB1'] = '\u0635\u062D';
  22658. t['\uFCB2'] = '\u0635\u062E';
  22659. t['\uFCB3'] = '\u0635\u0645';
  22660. t['\uFCB4'] = '\u0636\u062C';
  22661. t['\uFCB5'] = '\u0636\u062D';
  22662. t['\uFCB6'] = '\u0636\u062E';
  22663. t['\uFCB7'] = '\u0636\u0645';
  22664. t['\uFCB8'] = '\u0637\u062D';
  22665. t['\uFCB9'] = '\u0638\u0645';
  22666. t['\uFCBA'] = '\u0639\u062C';
  22667. t['\uFCBB'] = '\u0639\u0645';
  22668. t['\uFCBC'] = '\u063A\u062C';
  22669. t['\uFCBD'] = '\u063A\u0645';
  22670. t['\uFCBE'] = '\u0641\u062C';
  22671. t['\uFCBF'] = '\u0641\u062D';
  22672. t['\uFCC0'] = '\u0641\u062E';
  22673. t['\uFCC1'] = '\u0641\u0645';
  22674. t['\uFCC2'] = '\u0642\u062D';
  22675. t['\uFCC3'] = '\u0642\u0645';
  22676. t['\uFCC4'] = '\u0643\u062C';
  22677. t['\uFCC5'] = '\u0643\u062D';
  22678. t['\uFCC6'] = '\u0643\u062E';
  22679. t['\uFCC7'] = '\u0643\u0644';
  22680. t['\uFCC8'] = '\u0643\u0645';
  22681. t['\uFCC9'] = '\u0644\u062C';
  22682. t['\uFCCA'] = '\u0644\u062D';
  22683. t['\uFCCB'] = '\u0644\u062E';
  22684. t['\uFCCC'] = '\u0644\u0645';
  22685. t['\uFCCD'] = '\u0644\u0647';
  22686. t['\uFCCE'] = '\u0645\u062C';
  22687. t['\uFCCF'] = '\u0645\u062D';
  22688. t['\uFCD0'] = '\u0645\u062E';
  22689. t['\uFCD1'] = '\u0645\u0645';
  22690. t['\uFCD2'] = '\u0646\u062C';
  22691. t['\uFCD3'] = '\u0646\u062D';
  22692. t['\uFCD4'] = '\u0646\u062E';
  22693. t['\uFCD5'] = '\u0646\u0645';
  22694. t['\uFCD6'] = '\u0646\u0647';
  22695. t['\uFCD7'] = '\u0647\u062C';
  22696. t['\uFCD8'] = '\u0647\u0645';
  22697. t['\uFCD9'] = '\u0647\u0670';
  22698. t['\uFCDA'] = '\u064A\u062C';
  22699. t['\uFCDB'] = '\u064A\u062D';
  22700. t['\uFCDC'] = '\u064A\u062E';
  22701. t['\uFCDD'] = '\u064A\u0645';
  22702. t['\uFCDE'] = '\u064A\u0647';
  22703. t['\uFCDF'] = '\u0626\u0645';
  22704. t['\uFCE0'] = '\u0626\u0647';
  22705. t['\uFCE1'] = '\u0628\u0645';
  22706. t['\uFCE2'] = '\u0628\u0647';
  22707. t['\uFCE3'] = '\u062A\u0645';
  22708. t['\uFCE4'] = '\u062A\u0647';
  22709. t['\uFCE5'] = '\u062B\u0645';
  22710. t['\uFCE6'] = '\u062B\u0647';
  22711. t['\uFCE7'] = '\u0633\u0645';
  22712. t['\uFCE8'] = '\u0633\u0647';
  22713. t['\uFCE9'] = '\u0634\u0645';
  22714. t['\uFCEA'] = '\u0634\u0647';
  22715. t['\uFCEB'] = '\u0643\u0644';
  22716. t['\uFCEC'] = '\u0643\u0645';
  22717. t['\uFCED'] = '\u0644\u0645';
  22718. t['\uFCEE'] = '\u0646\u0645';
  22719. t['\uFCEF'] = '\u0646\u0647';
  22720. t['\uFCF0'] = '\u064A\u0645';
  22721. t['\uFCF1'] = '\u064A\u0647';
  22722. t['\uFCF2'] = '\u0640\u064E\u0651';
  22723. t['\uFCF3'] = '\u0640\u064F\u0651';
  22724. t['\uFCF4'] = '\u0640\u0650\u0651';
  22725. t['\uFCF5'] = '\u0637\u0649';
  22726. t['\uFCF6'] = '\u0637\u064A';
  22727. t['\uFCF7'] = '\u0639\u0649';
  22728. t['\uFCF8'] = '\u0639\u064A';
  22729. t['\uFCF9'] = '\u063A\u0649';
  22730. t['\uFCFA'] = '\u063A\u064A';
  22731. t['\uFCFB'] = '\u0633\u0649';
  22732. t['\uFCFC'] = '\u0633\u064A';
  22733. t['\uFCFD'] = '\u0634\u0649';
  22734. t['\uFCFE'] = '\u0634\u064A';
  22735. t['\uFCFF'] = '\u062D\u0649';
  22736. t['\uFD00'] = '\u062D\u064A';
  22737. t['\uFD01'] = '\u062C\u0649';
  22738. t['\uFD02'] = '\u062C\u064A';
  22739. t['\uFD03'] = '\u062E\u0649';
  22740. t['\uFD04'] = '\u062E\u064A';
  22741. t['\uFD05'] = '\u0635\u0649';
  22742. t['\uFD06'] = '\u0635\u064A';
  22743. t['\uFD07'] = '\u0636\u0649';
  22744. t['\uFD08'] = '\u0636\u064A';
  22745. t['\uFD09'] = '\u0634\u062C';
  22746. t['\uFD0A'] = '\u0634\u062D';
  22747. t['\uFD0B'] = '\u0634\u062E';
  22748. t['\uFD0C'] = '\u0634\u0645';
  22749. t['\uFD0D'] = '\u0634\u0631';
  22750. t['\uFD0E'] = '\u0633\u0631';
  22751. t['\uFD0F'] = '\u0635\u0631';
  22752. t['\uFD10'] = '\u0636\u0631';
  22753. t['\uFD11'] = '\u0637\u0649';
  22754. t['\uFD12'] = '\u0637\u064A';
  22755. t['\uFD13'] = '\u0639\u0649';
  22756. t['\uFD14'] = '\u0639\u064A';
  22757. t['\uFD15'] = '\u063A\u0649';
  22758. t['\uFD16'] = '\u063A\u064A';
  22759. t['\uFD17'] = '\u0633\u0649';
  22760. t['\uFD18'] = '\u0633\u064A';
  22761. t['\uFD19'] = '\u0634\u0649';
  22762. t['\uFD1A'] = '\u0634\u064A';
  22763. t['\uFD1B'] = '\u062D\u0649';
  22764. t['\uFD1C'] = '\u062D\u064A';
  22765. t['\uFD1D'] = '\u062C\u0649';
  22766. t['\uFD1E'] = '\u062C\u064A';
  22767. t['\uFD1F'] = '\u062E\u0649';
  22768. t['\uFD20'] = '\u062E\u064A';
  22769. t['\uFD21'] = '\u0635\u0649';
  22770. t['\uFD22'] = '\u0635\u064A';
  22771. t['\uFD23'] = '\u0636\u0649';
  22772. t['\uFD24'] = '\u0636\u064A';
  22773. t['\uFD25'] = '\u0634\u062C';
  22774. t['\uFD26'] = '\u0634\u062D';
  22775. t['\uFD27'] = '\u0634\u062E';
  22776. t['\uFD28'] = '\u0634\u0645';
  22777. t['\uFD29'] = '\u0634\u0631';
  22778. t['\uFD2A'] = '\u0633\u0631';
  22779. t['\uFD2B'] = '\u0635\u0631';
  22780. t['\uFD2C'] = '\u0636\u0631';
  22781. t['\uFD2D'] = '\u0634\u062C';
  22782. t['\uFD2E'] = '\u0634\u062D';
  22783. t['\uFD2F'] = '\u0634\u062E';
  22784. t['\uFD30'] = '\u0634\u0645';
  22785. t['\uFD31'] = '\u0633\u0647';
  22786. t['\uFD32'] = '\u0634\u0647';
  22787. t['\uFD33'] = '\u0637\u0645';
  22788. t['\uFD34'] = '\u0633\u062C';
  22789. t['\uFD35'] = '\u0633\u062D';
  22790. t['\uFD36'] = '\u0633\u062E';
  22791. t['\uFD37'] = '\u0634\u062C';
  22792. t['\uFD38'] = '\u0634\u062D';
  22793. t['\uFD39'] = '\u0634\u062E';
  22794. t['\uFD3A'] = '\u0637\u0645';
  22795. t['\uFD3B'] = '\u0638\u0645';
  22796. t['\uFD3C'] = '\u0627\u064B';
  22797. t['\uFD3D'] = '\u0627\u064B';
  22798. t['\uFD50'] = '\u062A\u062C\u0645';
  22799. t['\uFD51'] = '\u062A\u062D\u062C';
  22800. t['\uFD52'] = '\u062A\u062D\u062C';
  22801. t['\uFD53'] = '\u062A\u062D\u0645';
  22802. t['\uFD54'] = '\u062A\u062E\u0645';
  22803. t['\uFD55'] = '\u062A\u0645\u062C';
  22804. t['\uFD56'] = '\u062A\u0645\u062D';
  22805. t['\uFD57'] = '\u062A\u0645\u062E';
  22806. t['\uFD58'] = '\u062C\u0645\u062D';
  22807. t['\uFD59'] = '\u062C\u0645\u062D';
  22808. t['\uFD5A'] = '\u062D\u0645\u064A';
  22809. t['\uFD5B'] = '\u062D\u0645\u0649';
  22810. t['\uFD5C'] = '\u0633\u062D\u062C';
  22811. t['\uFD5D'] = '\u0633\u062C\u062D';
  22812. t['\uFD5E'] = '\u0633\u062C\u0649';
  22813. t['\uFD5F'] = '\u0633\u0645\u062D';
  22814. t['\uFD60'] = '\u0633\u0645\u062D';
  22815. t['\uFD61'] = '\u0633\u0645\u062C';
  22816. t['\uFD62'] = '\u0633\u0645\u0645';
  22817. t['\uFD63'] = '\u0633\u0645\u0645';
  22818. t['\uFD64'] = '\u0635\u062D\u062D';
  22819. t['\uFD65'] = '\u0635\u062D\u062D';
  22820. t['\uFD66'] = '\u0635\u0645\u0645';
  22821. t['\uFD67'] = '\u0634\u062D\u0645';
  22822. t['\uFD68'] = '\u0634\u062D\u0645';
  22823. t['\uFD69'] = '\u0634\u062C\u064A';
  22824. t['\uFD6A'] = '\u0634\u0645\u062E';
  22825. t['\uFD6B'] = '\u0634\u0645\u062E';
  22826. t['\uFD6C'] = '\u0634\u0645\u0645';
  22827. t['\uFD6D'] = '\u0634\u0645\u0645';
  22828. t['\uFD6E'] = '\u0636\u062D\u0649';
  22829. t['\uFD6F'] = '\u0636\u062E\u0645';
  22830. t['\uFD70'] = '\u0636\u062E\u0645';
  22831. t['\uFD71'] = '\u0637\u0645\u062D';
  22832. t['\uFD72'] = '\u0637\u0645\u062D';
  22833. t['\uFD73'] = '\u0637\u0645\u0645';
  22834. t['\uFD74'] = '\u0637\u0645\u064A';
  22835. t['\uFD75'] = '\u0639\u062C\u0645';
  22836. t['\uFD76'] = '\u0639\u0645\u0645';
  22837. t['\uFD77'] = '\u0639\u0645\u0645';
  22838. t['\uFD78'] = '\u0639\u0645\u0649';
  22839. t['\uFD79'] = '\u063A\u0645\u0645';
  22840. t['\uFD7A'] = '\u063A\u0645\u064A';
  22841. t['\uFD7B'] = '\u063A\u0645\u0649';
  22842. t['\uFD7C'] = '\u0641\u062E\u0645';
  22843. t['\uFD7D'] = '\u0641\u062E\u0645';
  22844. t['\uFD7E'] = '\u0642\u0645\u062D';
  22845. t['\uFD7F'] = '\u0642\u0645\u0645';
  22846. t['\uFD80'] = '\u0644\u062D\u0645';
  22847. t['\uFD81'] = '\u0644\u062D\u064A';
  22848. t['\uFD82'] = '\u0644\u062D\u0649';
  22849. t['\uFD83'] = '\u0644\u062C\u062C';
  22850. t['\uFD84'] = '\u0644\u062C\u062C';
  22851. t['\uFD85'] = '\u0644\u062E\u0645';
  22852. t['\uFD86'] = '\u0644\u062E\u0645';
  22853. t['\uFD87'] = '\u0644\u0645\u062D';
  22854. t['\uFD88'] = '\u0644\u0645\u062D';
  22855. t['\uFD89'] = '\u0645\u062D\u062C';
  22856. t['\uFD8A'] = '\u0645\u062D\u0645';
  22857. t['\uFD8B'] = '\u0645\u062D\u064A';
  22858. t['\uFD8C'] = '\u0645\u062C\u062D';
  22859. t['\uFD8D'] = '\u0645\u062C\u0645';
  22860. t['\uFD8E'] = '\u0645\u062E\u062C';
  22861. t['\uFD8F'] = '\u0645\u062E\u0645';
  22862. t['\uFD92'] = '\u0645\u062C\u062E';
  22863. t['\uFD93'] = '\u0647\u0645\u062C';
  22864. t['\uFD94'] = '\u0647\u0645\u0645';
  22865. t['\uFD95'] = '\u0646\u062D\u0645';
  22866. t['\uFD96'] = '\u0646\u062D\u0649';
  22867. t['\uFD97'] = '\u0646\u062C\u0645';
  22868. t['\uFD98'] = '\u0646\u062C\u0645';
  22869. t['\uFD99'] = '\u0646\u062C\u0649';
  22870. t['\uFD9A'] = '\u0646\u0645\u064A';
  22871. t['\uFD9B'] = '\u0646\u0645\u0649';
  22872. t['\uFD9C'] = '\u064A\u0645\u0645';
  22873. t['\uFD9D'] = '\u064A\u0645\u0645';
  22874. t['\uFD9E'] = '\u0628\u062E\u064A';
  22875. t['\uFD9F'] = '\u062A\u062C\u064A';
  22876. t['\uFDA0'] = '\u062A\u062C\u0649';
  22877. t['\uFDA1'] = '\u062A\u062E\u064A';
  22878. t['\uFDA2'] = '\u062A\u062E\u0649';
  22879. t['\uFDA3'] = '\u062A\u0645\u064A';
  22880. t['\uFDA4'] = '\u062A\u0645\u0649';
  22881. t['\uFDA5'] = '\u062C\u0645\u064A';
  22882. t['\uFDA6'] = '\u062C\u062D\u0649';
  22883. t['\uFDA7'] = '\u062C\u0645\u0649';
  22884. t['\uFDA8'] = '\u0633\u062E\u0649';
  22885. t['\uFDA9'] = '\u0635\u062D\u064A';
  22886. t['\uFDAA'] = '\u0634\u062D\u064A';
  22887. t['\uFDAB'] = '\u0636\u062D\u064A';
  22888. t['\uFDAC'] = '\u0644\u062C\u064A';
  22889. t['\uFDAD'] = '\u0644\u0645\u064A';
  22890. t['\uFDAE'] = '\u064A\u062D\u064A';
  22891. t['\uFDAF'] = '\u064A\u062C\u064A';
  22892. t['\uFDB0'] = '\u064A\u0645\u064A';
  22893. t['\uFDB1'] = '\u0645\u0645\u064A';
  22894. t['\uFDB2'] = '\u0642\u0645\u064A';
  22895. t['\uFDB3'] = '\u0646\u062D\u064A';
  22896. t['\uFDB4'] = '\u0642\u0645\u062D';
  22897. t['\uFDB5'] = '\u0644\u062D\u0645';
  22898. t['\uFDB6'] = '\u0639\u0645\u064A';
  22899. t['\uFDB7'] = '\u0643\u0645\u064A';
  22900. t['\uFDB8'] = '\u0646\u062C\u062D';
  22901. t['\uFDB9'] = '\u0645\u062E\u064A';
  22902. t['\uFDBA'] = '\u0644\u062C\u0645';
  22903. t['\uFDBB'] = '\u0643\u0645\u0645';
  22904. t['\uFDBC'] = '\u0644\u062C\u0645';
  22905. t['\uFDBD'] = '\u0646\u062C\u062D';
  22906. t['\uFDBE'] = '\u062C\u062D\u064A';
  22907. t['\uFDBF'] = '\u062D\u062C\u064A';
  22908. t['\uFDC0'] = '\u0645\u062C\u064A';
  22909. t['\uFDC1'] = '\u0641\u0645\u064A';
  22910. t['\uFDC2'] = '\u0628\u062D\u064A';
  22911. t['\uFDC3'] = '\u0643\u0645\u0645';
  22912. t['\uFDC4'] = '\u0639\u062C\u0645';
  22913. t['\uFDC5'] = '\u0635\u0645\u0645';
  22914. t['\uFDC6'] = '\u0633\u062E\u064A';
  22915. t['\uFDC7'] = '\u0646\u062C\u064A';
  22916. t['\uFE49'] = '\u203E';
  22917. t['\uFE4A'] = '\u203E';
  22918. t['\uFE4B'] = '\u203E';
  22919. t['\uFE4C'] = '\u203E';
  22920. t['\uFE4D'] = '\u005F';
  22921. t['\uFE4E'] = '\u005F';
  22922. t['\uFE4F'] = '\u005F';
  22923. t['\uFE80'] = '\u0621';
  22924. t['\uFE81'] = '\u0622';
  22925. t['\uFE82'] = '\u0622';
  22926. t['\uFE83'] = '\u0623';
  22927. t['\uFE84'] = '\u0623';
  22928. t['\uFE85'] = '\u0624';
  22929. t['\uFE86'] = '\u0624';
  22930. t['\uFE87'] = '\u0625';
  22931. t['\uFE88'] = '\u0625';
  22932. t['\uFE89'] = '\u0626';
  22933. t['\uFE8A'] = '\u0626';
  22934. t['\uFE8B'] = '\u0626';
  22935. t['\uFE8C'] = '\u0626';
  22936. t['\uFE8D'] = '\u0627';
  22937. t['\uFE8E'] = '\u0627';
  22938. t['\uFE8F'] = '\u0628';
  22939. t['\uFE90'] = '\u0628';
  22940. t['\uFE91'] = '\u0628';
  22941. t['\uFE92'] = '\u0628';
  22942. t['\uFE93'] = '\u0629';
  22943. t['\uFE94'] = '\u0629';
  22944. t['\uFE95'] = '\u062A';
  22945. t['\uFE96'] = '\u062A';
  22946. t['\uFE97'] = '\u062A';
  22947. t['\uFE98'] = '\u062A';
  22948. t['\uFE99'] = '\u062B';
  22949. t['\uFE9A'] = '\u062B';
  22950. t['\uFE9B'] = '\u062B';
  22951. t['\uFE9C'] = '\u062B';
  22952. t['\uFE9D'] = '\u062C';
  22953. t['\uFE9E'] = '\u062C';
  22954. t['\uFE9F'] = '\u062C';
  22955. t['\uFEA0'] = '\u062C';
  22956. t['\uFEA1'] = '\u062D';
  22957. t['\uFEA2'] = '\u062D';
  22958. t['\uFEA3'] = '\u062D';
  22959. t['\uFEA4'] = '\u062D';
  22960. t['\uFEA5'] = '\u062E';
  22961. t['\uFEA6'] = '\u062E';
  22962. t['\uFEA7'] = '\u062E';
  22963. t['\uFEA8'] = '\u062E';
  22964. t['\uFEA9'] = '\u062F';
  22965. t['\uFEAA'] = '\u062F';
  22966. t['\uFEAB'] = '\u0630';
  22967. t['\uFEAC'] = '\u0630';
  22968. t['\uFEAD'] = '\u0631';
  22969. t['\uFEAE'] = '\u0631';
  22970. t['\uFEAF'] = '\u0632';
  22971. t['\uFEB0'] = '\u0632';
  22972. t['\uFEB1'] = '\u0633';
  22973. t['\uFEB2'] = '\u0633';
  22974. t['\uFEB3'] = '\u0633';
  22975. t['\uFEB4'] = '\u0633';
  22976. t['\uFEB5'] = '\u0634';
  22977. t['\uFEB6'] = '\u0634';
  22978. t['\uFEB7'] = '\u0634';
  22979. t['\uFEB8'] = '\u0634';
  22980. t['\uFEB9'] = '\u0635';
  22981. t['\uFEBA'] = '\u0635';
  22982. t['\uFEBB'] = '\u0635';
  22983. t['\uFEBC'] = '\u0635';
  22984. t['\uFEBD'] = '\u0636';
  22985. t['\uFEBE'] = '\u0636';
  22986. t['\uFEBF'] = '\u0636';
  22987. t['\uFEC0'] = '\u0636';
  22988. t['\uFEC1'] = '\u0637';
  22989. t['\uFEC2'] = '\u0637';
  22990. t['\uFEC3'] = '\u0637';
  22991. t['\uFEC4'] = '\u0637';
  22992. t['\uFEC5'] = '\u0638';
  22993. t['\uFEC6'] = '\u0638';
  22994. t['\uFEC7'] = '\u0638';
  22995. t['\uFEC8'] = '\u0638';
  22996. t['\uFEC9'] = '\u0639';
  22997. t['\uFECA'] = '\u0639';
  22998. t['\uFECB'] = '\u0639';
  22999. t['\uFECC'] = '\u0639';
  23000. t['\uFECD'] = '\u063A';
  23001. t['\uFECE'] = '\u063A';
  23002. t['\uFECF'] = '\u063A';
  23003. t['\uFED0'] = '\u063A';
  23004. t['\uFED1'] = '\u0641';
  23005. t['\uFED2'] = '\u0641';
  23006. t['\uFED3'] = '\u0641';
  23007. t['\uFED4'] = '\u0641';
  23008. t['\uFED5'] = '\u0642';
  23009. t['\uFED6'] = '\u0642';
  23010. t['\uFED7'] = '\u0642';
  23011. t['\uFED8'] = '\u0642';
  23012. t['\uFED9'] = '\u0643';
  23013. t['\uFEDA'] = '\u0643';
  23014. t['\uFEDB'] = '\u0643';
  23015. t['\uFEDC'] = '\u0643';
  23016. t['\uFEDD'] = '\u0644';
  23017. t['\uFEDE'] = '\u0644';
  23018. t['\uFEDF'] = '\u0644';
  23019. t['\uFEE0'] = '\u0644';
  23020. t['\uFEE1'] = '\u0645';
  23021. t['\uFEE2'] = '\u0645';
  23022. t['\uFEE3'] = '\u0645';
  23023. t['\uFEE4'] = '\u0645';
  23024. t['\uFEE5'] = '\u0646';
  23025. t['\uFEE6'] = '\u0646';
  23026. t['\uFEE7'] = '\u0646';
  23027. t['\uFEE8'] = '\u0646';
  23028. t['\uFEE9'] = '\u0647';
  23029. t['\uFEEA'] = '\u0647';
  23030. t['\uFEEB'] = '\u0647';
  23031. t['\uFEEC'] = '\u0647';
  23032. t['\uFEED'] = '\u0648';
  23033. t['\uFEEE'] = '\u0648';
  23034. t['\uFEEF'] = '\u0649';
  23035. t['\uFEF0'] = '\u0649';
  23036. t['\uFEF1'] = '\u064A';
  23037. t['\uFEF2'] = '\u064A';
  23038. t['\uFEF3'] = '\u064A';
  23039. t['\uFEF4'] = '\u064A';
  23040. t['\uFEF5'] = '\u0644\u0622';
  23041. t['\uFEF6'] = '\u0644\u0622';
  23042. t['\uFEF7'] = '\u0644\u0623';
  23043. t['\uFEF8'] = '\u0644\u0623';
  23044. t['\uFEF9'] = '\u0644\u0625';
  23045. t['\uFEFA'] = '\u0644\u0625';
  23046. t['\uFEFB'] = '\u0644\u0627';
  23047. t['\uFEFC'] = '\u0644\u0627';
  23048. });
  23049. function reverseIfRtl(chars) {
  23050. var charsLength = chars.length;
  23051. if (charsLength <= 1 || !isRTLRangeFor(chars.charCodeAt(0))) {
  23052. return chars;
  23053. }
  23054. var s = '';
  23055. for (var ii = charsLength - 1; ii >= 0; ii--) {
  23056. s += chars[ii];
  23057. }
  23058. return s;
  23059. }
  23060. exports.mapSpecialUnicodeValues = mapSpecialUnicodeValues;
  23061. exports.reverseIfRtl = reverseIfRtl;
  23062. exports.getUnicodeRangeFor = getUnicodeRangeFor;
  23063. exports.getNormalizedUnicodes = getNormalizedUnicodes;
  23064. exports.getUnicodeForGlyph = getUnicodeForGlyph;
  23065. }));
  23066. (function (root, factory) {
  23067. factory(root.pdfjsDisplayDOMUtils = {}, root.pdfjsSharedUtil);
  23068. }(this, function (exports, sharedUtil) {
  23069. var removeNullCharacters = sharedUtil.removeNullCharacters;
  23070. var warn = sharedUtil.warn;
  23071. var deprecated = sharedUtil.deprecated;
  23072. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  23073. var CustomStyle = function CustomStyleClosure() {
  23074. var prefixes = [
  23075. 'ms',
  23076. 'Moz',
  23077. 'Webkit',
  23078. 'O'
  23079. ];
  23080. var _cache = Object.create(null);
  23081. function CustomStyle() {
  23082. }
  23083. CustomStyle.getProp = function get(propName, element) {
  23084. if (arguments.length === 1 && typeof _cache[propName] === 'string') {
  23085. return _cache[propName];
  23086. }
  23087. element = element || document.documentElement;
  23088. var style = element.style, prefixed, uPropName;
  23089. if (typeof style[propName] === 'string') {
  23090. return _cache[propName] = propName;
  23091. }
  23092. uPropName = propName.charAt(0).toUpperCase() + propName.slice(1);
  23093. for (var i = 0, l = prefixes.length; i < l; i++) {
  23094. prefixed = prefixes[i] + uPropName;
  23095. if (typeof style[prefixed] === 'string') {
  23096. return _cache[propName] = prefixed;
  23097. }
  23098. }
  23099. return _cache[propName] = 'undefined';
  23100. };
  23101. CustomStyle.setProp = function set(propName, element, str) {
  23102. var prop = this.getProp(propName);
  23103. if (prop !== 'undefined') {
  23104. element.style[prop] = str;
  23105. }
  23106. };
  23107. return CustomStyle;
  23108. }();
  23109. var hasCanvasTypedArrays;
  23110. hasCanvasTypedArrays = function hasCanvasTypedArrays() {
  23111. var canvas = document.createElement('canvas');
  23112. canvas.width = canvas.height = 1;
  23113. var ctx = canvas.getContext('2d');
  23114. var imageData = ctx.createImageData(1, 1);
  23115. return typeof imageData.data.buffer !== 'undefined';
  23116. };
  23117. var LinkTarget = {
  23118. NONE: 0,
  23119. SELF: 1,
  23120. BLANK: 2,
  23121. PARENT: 3,
  23122. TOP: 4
  23123. };
  23124. var LinkTargetStringMap = [
  23125. '',
  23126. '_self',
  23127. '_blank',
  23128. '_parent',
  23129. '_top'
  23130. ];
  23131. function addLinkAttributes(link, params) {
  23132. var url = params && params.url;
  23133. link.href = link.title = url ? removeNullCharacters(url) : '';
  23134. if (url) {
  23135. var target = params.target;
  23136. if (typeof target === 'undefined') {
  23137. target = getDefaultSetting('externalLinkTarget');
  23138. }
  23139. link.target = LinkTargetStringMap[target];
  23140. var rel = params.rel;
  23141. if (typeof rel === 'undefined') {
  23142. rel = getDefaultSetting('externalLinkRel');
  23143. }
  23144. link.rel = rel;
  23145. }
  23146. }
  23147. function getFilenameFromUrl(url) {
  23148. var anchor = url.indexOf('#');
  23149. var query = url.indexOf('?');
  23150. var end = Math.min(anchor > 0 ? anchor : url.length, query > 0 ? query : url.length);
  23151. return url.substring(url.lastIndexOf('/', end) + 1, end);
  23152. }
  23153. function getDefaultSetting(id) {
  23154. var globalSettings = sharedUtil.globalScope.PDFJS;
  23155. switch (id) {
  23156. case 'pdfBug':
  23157. return globalSettings ? globalSettings.pdfBug : false;
  23158. case 'disableAutoFetch':
  23159. return globalSettings ? globalSettings.disableAutoFetch : false;
  23160. case 'disableStream':
  23161. return globalSettings ? globalSettings.disableStream : false;
  23162. case 'disableRange':
  23163. return globalSettings ? globalSettings.disableRange : false;
  23164. case 'disableFontFace':
  23165. return globalSettings ? globalSettings.disableFontFace : false;
  23166. case 'disableCreateObjectURL':
  23167. return globalSettings ? globalSettings.disableCreateObjectURL : false;
  23168. case 'disableWebGL':
  23169. return globalSettings ? globalSettings.disableWebGL : true;
  23170. case 'cMapUrl':
  23171. return globalSettings ? globalSettings.cMapUrl : null;
  23172. case 'cMapPacked':
  23173. return globalSettings ? globalSettings.cMapPacked : false;
  23174. case 'postMessageTransfers':
  23175. return globalSettings ? globalSettings.postMessageTransfers : true;
  23176. case 'workerSrc':
  23177. return globalSettings ? globalSettings.workerSrc : null;
  23178. case 'disableWorker':
  23179. return globalSettings ? globalSettings.disableWorker : false;
  23180. case 'maxImageSize':
  23181. return globalSettings ? globalSettings.maxImageSize : -1;
  23182. case 'imageResourcesPath':
  23183. return globalSettings ? globalSettings.imageResourcesPath : '';
  23184. case 'isEvalSupported':
  23185. return globalSettings ? globalSettings.isEvalSupported : true;
  23186. case 'externalLinkTarget':
  23187. if (!globalSettings) {
  23188. return LinkTarget.NONE;
  23189. }
  23190. switch (globalSettings.externalLinkTarget) {
  23191. case LinkTarget.NONE:
  23192. case LinkTarget.SELF:
  23193. case LinkTarget.BLANK:
  23194. case LinkTarget.PARENT:
  23195. case LinkTarget.TOP:
  23196. return globalSettings.externalLinkTarget;
  23197. }
  23198. warn('PDFJS.externalLinkTarget is invalid: ' + globalSettings.externalLinkTarget);
  23199. globalSettings.externalLinkTarget = LinkTarget.NONE;
  23200. return LinkTarget.NONE;
  23201. case 'externalLinkRel':
  23202. return globalSettings ? globalSettings.externalLinkRel : 'noreferrer';
  23203. case 'enableStats':
  23204. return !!(globalSettings && globalSettings.enableStats);
  23205. default:
  23206. throw new Error('Unknown default setting: ' + id);
  23207. }
  23208. }
  23209. function isExternalLinkTargetSet() {
  23210. var externalLinkTarget = getDefaultSetting('externalLinkTarget');
  23211. switch (externalLinkTarget) {
  23212. case LinkTarget.NONE:
  23213. return false;
  23214. case LinkTarget.SELF:
  23215. case LinkTarget.BLANK:
  23216. case LinkTarget.PARENT:
  23217. case LinkTarget.TOP:
  23218. return true;
  23219. }
  23220. }
  23221. function isValidUrl(url, allowRelative) {
  23222. deprecated('isValidUrl(), please use createValidAbsoluteUrl() instead.');
  23223. var baseUrl = allowRelative ? 'http://example.com' : null;
  23224. return createValidAbsoluteUrl(url, baseUrl) !== null;
  23225. }
  23226. exports.CustomStyle = CustomStyle;
  23227. exports.addLinkAttributes = addLinkAttributes;
  23228. exports.isExternalLinkTargetSet = isExternalLinkTargetSet;
  23229. exports.isValidUrl = isValidUrl;
  23230. exports.getFilenameFromUrl = getFilenameFromUrl;
  23231. exports.LinkTarget = LinkTarget;
  23232. exports.hasCanvasTypedArrays = hasCanvasTypedArrays;
  23233. exports.getDefaultSetting = getDefaultSetting;
  23234. }));
  23235. (function (root, factory) {
  23236. factory(root.pdfjsDisplayFontLoader = {}, root.pdfjsSharedUtil);
  23237. }(this, function (exports, sharedUtil) {
  23238. var assert = sharedUtil.assert;
  23239. var bytesToString = sharedUtil.bytesToString;
  23240. var string32 = sharedUtil.string32;
  23241. var shadow = sharedUtil.shadow;
  23242. var warn = sharedUtil.warn;
  23243. function FontLoader(docId) {
  23244. this.docId = docId;
  23245. this.styleElement = null;
  23246. this.nativeFontFaces = [];
  23247. this.loadTestFontId = 0;
  23248. this.loadingContext = {
  23249. requests: [],
  23250. nextRequestId: 0
  23251. };
  23252. }
  23253. FontLoader.prototype = {
  23254. insertRule: function fontLoaderInsertRule(rule) {
  23255. var styleElement = this.styleElement;
  23256. if (!styleElement) {
  23257. styleElement = this.styleElement = document.createElement('style');
  23258. styleElement.id = 'PDFJS_FONT_STYLE_TAG_' + this.docId;
  23259. document.documentElement.getElementsByTagName('head')[0].appendChild(styleElement);
  23260. }
  23261. var styleSheet = styleElement.sheet;
  23262. styleSheet.insertRule(rule, styleSheet.cssRules.length);
  23263. },
  23264. clear: function fontLoaderClear() {
  23265. var styleElement = this.styleElement;
  23266. if (styleElement) {
  23267. styleElement.parentNode.removeChild(styleElement);
  23268. styleElement = this.styleElement = null;
  23269. }
  23270. this.nativeFontFaces.forEach(function (nativeFontFace) {
  23271. document.fonts.delete(nativeFontFace);
  23272. });
  23273. this.nativeFontFaces.length = 0;
  23274. }
  23275. };
  23276. var getLoadTestFont = function () {
  23277. return atob('T1RUTwALAIAAAwAwQ0ZGIDHtZg4AAAOYAAAAgUZGVE1lkzZwAAAEHAAAABxHREVGABQAFQ' + 'AABDgAAAAeT1MvMlYNYwkAAAEgAAAAYGNtYXABDQLUAAACNAAAAUJoZWFk/xVFDQAAALwA' + 'AAA2aGhlYQdkA+oAAAD0AAAAJGhtdHgD6AAAAAAEWAAAAAZtYXhwAAJQAAAAARgAAAAGbm' + 'FtZVjmdH4AAAGAAAAAsXBvc3T/hgAzAAADeAAAACAAAQAAAAEAALZRFsRfDzz1AAsD6AAA' + 'AADOBOTLAAAAAM4KHDwAAAAAA+gDIQAAAAgAAgAAAAAAAAABAAADIQAAAFoD6AAAAAAD6A' + 'ABAAAAAAAAAAAAAAAAAAAAAQAAUAAAAgAAAAQD6AH0AAUAAAKKArwAAACMAooCvAAAAeAA' + 'MQECAAACAAYJAAAAAAAAAAAAAQAAAAAAAAAAAAAAAFBmRWQAwAAuAC4DIP84AFoDIQAAAA' + 'AAAQAAAAAAAAAAACAAIAABAAAADgCuAAEAAAAAAAAAAQAAAAEAAAAAAAEAAQAAAAEAAAAA' + 'AAIAAQAAAAEAAAAAAAMAAQAAAAEAAAAAAAQAAQAAAAEAAAAAAAUAAQAAAAEAAAAAAAYAAQ' + 'AAAAMAAQQJAAAAAgABAAMAAQQJAAEAAgABAAMAAQQJAAIAAgABAAMAAQQJAAMAAgABAAMA' + 'AQQJAAQAAgABAAMAAQQJAAUAAgABAAMAAQQJAAYAAgABWABYAAAAAAAAAwAAAAMAAAAcAA' + 'EAAAAAADwAAwABAAAAHAAEACAAAAAEAAQAAQAAAC7//wAAAC7////TAAEAAAAAAAABBgAA' + 'AQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAEAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' + 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMAAA' + 'AAAAD/gwAyAAAAAQAAAAAAAAAAAAAAAAAAAAABAAQEAAEBAQJYAAEBASH4DwD4GwHEAvgc' + 'A/gXBIwMAYuL+nz5tQXkD5j3CBLnEQACAQEBIVhYWFhYWFhYWFhYWFhYWFhYWFhYWFhYWF' + 'hYWFhYWFhYAAABAQAADwACAQEEE/t3Dov6fAH6fAT+fPp8+nwHDosMCvm1Cvm1DAz6fBQA' + 'AAAAAAABAAAAAMmJbzEAAAAAzgTjFQAAAADOBOQpAAEAAAAAAAAADAAUAAQAAAABAAAAAg' + 'ABAAAAAAAAAAAD6AAAAAAAAA==');
  23278. };
  23279. Object.defineProperty(FontLoader.prototype, 'loadTestFont', {
  23280. get: function () {
  23281. return shadow(this, 'loadTestFont', getLoadTestFont());
  23282. },
  23283. configurable: true
  23284. });
  23285. FontLoader.prototype.addNativeFontFace = function fontLoader_addNativeFontFace(nativeFontFace) {
  23286. this.nativeFontFaces.push(nativeFontFace);
  23287. document.fonts.add(nativeFontFace);
  23288. };
  23289. FontLoader.prototype.bind = function fontLoaderBind(fonts, callback) {
  23290. var rules = [];
  23291. var fontsToLoad = [];
  23292. var fontLoadPromises = [];
  23293. var getNativeFontPromise = function (nativeFontFace) {
  23294. return nativeFontFace.loaded.catch(function (e) {
  23295. warn('Failed to load font "' + nativeFontFace.family + '": ' + e);
  23296. });
  23297. };
  23298. var isFontLoadingAPISupported = FontLoader.isFontLoadingAPISupported && !FontLoader.isSyncFontLoadingSupported;
  23299. for (var i = 0, ii = fonts.length; i < ii; i++) {
  23300. var font = fonts[i];
  23301. if (font.attached || font.loading === false) {
  23302. continue;
  23303. }
  23304. font.attached = true;
  23305. if (isFontLoadingAPISupported) {
  23306. var nativeFontFace = font.createNativeFontFace();
  23307. if (nativeFontFace) {
  23308. this.addNativeFontFace(nativeFontFace);
  23309. fontLoadPromises.push(getNativeFontPromise(nativeFontFace));
  23310. }
  23311. } else {
  23312. var rule = font.createFontFaceRule();
  23313. if (rule) {
  23314. this.insertRule(rule);
  23315. rules.push(rule);
  23316. fontsToLoad.push(font);
  23317. }
  23318. }
  23319. }
  23320. var request = this.queueLoadingCallback(callback);
  23321. if (isFontLoadingAPISupported) {
  23322. Promise.all(fontLoadPromises).then(function () {
  23323. request.complete();
  23324. });
  23325. } else if (rules.length > 0 && !FontLoader.isSyncFontLoadingSupported) {
  23326. this.prepareFontLoadEvent(rules, fontsToLoad, request);
  23327. } else {
  23328. request.complete();
  23329. }
  23330. };
  23331. FontLoader.prototype.queueLoadingCallback = function FontLoader_queueLoadingCallback(callback) {
  23332. function LoadLoader_completeRequest() {
  23333. assert(!request.end, 'completeRequest() cannot be called twice');
  23334. request.end = Date.now();
  23335. while (context.requests.length > 0 && context.requests[0].end) {
  23336. var otherRequest = context.requests.shift();
  23337. setTimeout(otherRequest.callback, 0);
  23338. }
  23339. }
  23340. var context = this.loadingContext;
  23341. var requestId = 'pdfjs-font-loading-' + context.nextRequestId++;
  23342. var request = {
  23343. id: requestId,
  23344. complete: LoadLoader_completeRequest,
  23345. callback: callback,
  23346. started: Date.now()
  23347. };
  23348. context.requests.push(request);
  23349. return request;
  23350. };
  23351. FontLoader.prototype.prepareFontLoadEvent = function fontLoaderPrepareFontLoadEvent(rules, fonts, request) {
  23352. function int32(data, offset) {
  23353. return data.charCodeAt(offset) << 24 | data.charCodeAt(offset + 1) << 16 | data.charCodeAt(offset + 2) << 8 | data.charCodeAt(offset + 3) & 0xff;
  23354. }
  23355. function spliceString(s, offset, remove, insert) {
  23356. var chunk1 = s.substr(0, offset);
  23357. var chunk2 = s.substr(offset + remove);
  23358. return chunk1 + insert + chunk2;
  23359. }
  23360. var i, ii;
  23361. var canvas = document.createElement('canvas');
  23362. canvas.width = 1;
  23363. canvas.height = 1;
  23364. var ctx = canvas.getContext('2d');
  23365. var called = 0;
  23366. function isFontReady(name, callback) {
  23367. called++;
  23368. if (called > 30) {
  23369. warn('Load test font never loaded.');
  23370. callback();
  23371. return;
  23372. }
  23373. ctx.font = '30px ' + name;
  23374. ctx.fillText('.', 0, 20);
  23375. var imageData = ctx.getImageData(0, 0, 1, 1);
  23376. if (imageData.data[3] > 0) {
  23377. callback();
  23378. return;
  23379. }
  23380. setTimeout(isFontReady.bind(null, name, callback));
  23381. }
  23382. var loadTestFontId = 'lt' + Date.now() + this.loadTestFontId++;
  23383. var data = this.loadTestFont;
  23384. var COMMENT_OFFSET = 976;
  23385. data = spliceString(data, COMMENT_OFFSET, loadTestFontId.length, loadTestFontId);
  23386. var CFF_CHECKSUM_OFFSET = 16;
  23387. var XXXX_VALUE = 0x58585858;
  23388. var checksum = int32(data, CFF_CHECKSUM_OFFSET);
  23389. for (i = 0, ii = loadTestFontId.length - 3; i < ii; i += 4) {
  23390. checksum = checksum - XXXX_VALUE + int32(loadTestFontId, i) | 0;
  23391. }
  23392. if (i < loadTestFontId.length) {
  23393. checksum = checksum - XXXX_VALUE + int32(loadTestFontId + 'XXX', i) | 0;
  23394. }
  23395. data = spliceString(data, CFF_CHECKSUM_OFFSET, 4, string32(checksum));
  23396. var url = 'url(data:font/opentype;base64,' + btoa(data) + ');';
  23397. var rule = '@font-face { font-family:"' + loadTestFontId + '";src:' + url + '}';
  23398. this.insertRule(rule);
  23399. var names = [];
  23400. for (i = 0, ii = fonts.length; i < ii; i++) {
  23401. names.push(fonts[i].loadedName);
  23402. }
  23403. names.push(loadTestFontId);
  23404. var div = document.createElement('div');
  23405. div.setAttribute('style', 'visibility: hidden;' + 'width: 10px; height: 10px;' + 'position: absolute; top: 0px; left: 0px;');
  23406. for (i = 0, ii = names.length; i < ii; ++i) {
  23407. var span = document.createElement('span');
  23408. span.textContent = 'Hi';
  23409. span.style.fontFamily = names[i];
  23410. div.appendChild(span);
  23411. }
  23412. document.body.appendChild(div);
  23413. isFontReady(loadTestFontId, function () {
  23414. document.body.removeChild(div);
  23415. request.complete();
  23416. });
  23417. };
  23418. FontLoader.isFontLoadingAPISupported = typeof document !== 'undefined' && !!document.fonts;
  23419. var isSyncFontLoadingSupported = function isSyncFontLoadingSupported() {
  23420. if (typeof navigator === 'undefined') {
  23421. return true;
  23422. }
  23423. var supported = false;
  23424. var m = /Mozilla\/5.0.*?rv:(\d+).*? Gecko/.exec(navigator.userAgent);
  23425. if (m && m[1] >= 14) {
  23426. supported = true;
  23427. }
  23428. return supported;
  23429. };
  23430. Object.defineProperty(FontLoader, 'isSyncFontLoadingSupported', {
  23431. get: function () {
  23432. return shadow(FontLoader, 'isSyncFontLoadingSupported', isSyncFontLoadingSupported());
  23433. },
  23434. enumerable: true,
  23435. configurable: true
  23436. });
  23437. var IsEvalSupportedCached = {
  23438. get value() {
  23439. return shadow(this, 'value', sharedUtil.isEvalSupported());
  23440. }
  23441. };
  23442. var FontFaceObject = function FontFaceObjectClosure() {
  23443. function FontFaceObject(translatedData, options) {
  23444. this.compiledGlyphs = Object.create(null);
  23445. for (var i in translatedData) {
  23446. this[i] = translatedData[i];
  23447. }
  23448. this.options = options;
  23449. }
  23450. FontFaceObject.prototype = {
  23451. createNativeFontFace: function FontFaceObject_createNativeFontFace() {
  23452. if (!this.data) {
  23453. return null;
  23454. }
  23455. if (this.options.disableFontFace) {
  23456. this.disableFontFace = true;
  23457. return null;
  23458. }
  23459. var nativeFontFace = new FontFace(this.loadedName, this.data, {});
  23460. if (this.options.fontRegistry) {
  23461. this.options.fontRegistry.registerFont(this);
  23462. }
  23463. return nativeFontFace;
  23464. },
  23465. createFontFaceRule: function FontFaceObject_createFontFaceRule() {
  23466. if (!this.data) {
  23467. return null;
  23468. }
  23469. if (this.options.disableFontFace) {
  23470. this.disableFontFace = true;
  23471. return null;
  23472. }
  23473. var data = bytesToString(new Uint8Array(this.data));
  23474. var fontName = this.loadedName;
  23475. var url = 'url(data:' + this.mimetype + ';base64,' + btoa(data) + ');';
  23476. var rule = '@font-face { font-family:"' + fontName + '";src:' + url + '}';
  23477. if (this.options.fontRegistry) {
  23478. this.options.fontRegistry.registerFont(this, url);
  23479. }
  23480. return rule;
  23481. },
  23482. getPathGenerator: function FontFaceObject_getPathGenerator(objs, character) {
  23483. if (!(character in this.compiledGlyphs)) {
  23484. var cmds = objs.get(this.loadedName + '_path_' + character);
  23485. var current, i, len;
  23486. if (this.options.isEvalSupported && IsEvalSupportedCached.value) {
  23487. var args, js = '';
  23488. for (i = 0, len = cmds.length; i < len; i++) {
  23489. current = cmds[i];
  23490. if (current.args !== undefined) {
  23491. args = current.args.join(',');
  23492. } else {
  23493. args = '';
  23494. }
  23495. js += 'c.' + current.cmd + '(' + args + ');\n';
  23496. }
  23497. this.compiledGlyphs[character] = new Function('c', 'size', js);
  23498. } else {
  23499. this.compiledGlyphs[character] = function (c, size) {
  23500. for (i = 0, len = cmds.length; i < len; i++) {
  23501. current = cmds[i];
  23502. if (current.cmd === 'scale') {
  23503. current.args = [
  23504. size,
  23505. -size
  23506. ];
  23507. }
  23508. c[current.cmd].apply(c, current.args);
  23509. }
  23510. };
  23511. }
  23512. }
  23513. return this.compiledGlyphs[character];
  23514. }
  23515. };
  23516. return FontFaceObject;
  23517. }();
  23518. exports.FontFaceObject = FontFaceObject;
  23519. exports.FontLoader = FontLoader;
  23520. }));
  23521. (function (root, factory) {
  23522. factory(root.pdfjsDisplayMetadata = {}, root.pdfjsSharedUtil);
  23523. }(this, function (exports, sharedUtil) {
  23524. var error = sharedUtil.error;
  23525. function fixMetadata(meta) {
  23526. return meta.replace(/>\\376\\377([^<]+)/g, function (all, codes) {
  23527. var bytes = codes.replace(/\\([0-3])([0-7])([0-7])/g, function (code, d1, d2, d3) {
  23528. return String.fromCharCode(d1 * 64 + d2 * 8 + d3 * 1);
  23529. });
  23530. var chars = '';
  23531. for (var i = 0; i < bytes.length; i += 2) {
  23532. var code = bytes.charCodeAt(i) * 256 + bytes.charCodeAt(i + 1);
  23533. chars += code >= 32 && code < 127 && code !== 60 && code !== 62 && code !== 38 ? String.fromCharCode(code) : '&#x' + (0x10000 + code).toString(16).substring(1) + ';';
  23534. }
  23535. return '>' + chars;
  23536. });
  23537. }
  23538. function Metadata(meta) {
  23539. if (typeof meta === 'string') {
  23540. meta = fixMetadata(meta);
  23541. var parser = new DOMParser();
  23542. meta = parser.parseFromString(meta, 'application/xml');
  23543. } else if (!(meta instanceof Document)) {
  23544. error('Metadata: Invalid metadata object');
  23545. }
  23546. this.metaDocument = meta;
  23547. this.metadata = Object.create(null);
  23548. this.parse();
  23549. }
  23550. Metadata.prototype = {
  23551. parse: function Metadata_parse() {
  23552. var doc = this.metaDocument;
  23553. var rdf = doc.documentElement;
  23554. if (rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23555. rdf = rdf.firstChild;
  23556. while (rdf && rdf.nodeName.toLowerCase() !== 'rdf:rdf') {
  23557. rdf = rdf.nextSibling;
  23558. }
  23559. }
  23560. var nodeName = rdf ? rdf.nodeName.toLowerCase() : null;
  23561. if (!rdf || nodeName !== 'rdf:rdf' || !rdf.hasChildNodes()) {
  23562. return;
  23563. }
  23564. var children = rdf.childNodes, desc, entry, name, i, ii, length, iLength;
  23565. for (i = 0, length = children.length; i < length; i++) {
  23566. desc = children[i];
  23567. if (desc.nodeName.toLowerCase() !== 'rdf:description') {
  23568. continue;
  23569. }
  23570. for (ii = 0, iLength = desc.childNodes.length; ii < iLength; ii++) {
  23571. if (desc.childNodes[ii].nodeName.toLowerCase() !== '#text') {
  23572. entry = desc.childNodes[ii];
  23573. name = entry.nodeName.toLowerCase();
  23574. this.metadata[name] = entry.textContent.trim();
  23575. }
  23576. }
  23577. }
  23578. },
  23579. get: function Metadata_get(name) {
  23580. return this.metadata[name] || null;
  23581. },
  23582. has: function Metadata_has(name) {
  23583. return typeof this.metadata[name] !== 'undefined';
  23584. }
  23585. };
  23586. exports.Metadata = Metadata;
  23587. }));
  23588. (function (root, factory) {
  23589. factory(root.pdfjsDisplaySVG = {}, root.pdfjsSharedUtil);
  23590. }(this, function (exports, sharedUtil) {
  23591. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  23592. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  23593. var ImageKind = sharedUtil.ImageKind;
  23594. var OPS = sharedUtil.OPS;
  23595. var Util = sharedUtil.Util;
  23596. var isNum = sharedUtil.isNum;
  23597. var isArray = sharedUtil.isArray;
  23598. var warn = sharedUtil.warn;
  23599. var createObjectURL = sharedUtil.createObjectURL;
  23600. var SVG_DEFAULTS = {
  23601. fontStyle: 'normal',
  23602. fontWeight: 'normal',
  23603. fillColor: '#000000'
  23604. };
  23605. var convertImgDataToPng = function convertImgDataToPngClosure() {
  23606. var PNG_HEADER = new Uint8Array([
  23607. 0x89,
  23608. 0x50,
  23609. 0x4e,
  23610. 0x47,
  23611. 0x0d,
  23612. 0x0a,
  23613. 0x1a,
  23614. 0x0a
  23615. ]);
  23616. var CHUNK_WRAPPER_SIZE = 12;
  23617. var crcTable = new Int32Array(256);
  23618. for (var i = 0; i < 256; i++) {
  23619. var c = i;
  23620. for (var h = 0; h < 8; h++) {
  23621. if (c & 1) {
  23622. c = 0xedB88320 ^ c >> 1 & 0x7fffffff;
  23623. } else {
  23624. c = c >> 1 & 0x7fffffff;
  23625. }
  23626. }
  23627. crcTable[i] = c;
  23628. }
  23629. function crc32(data, start, end) {
  23630. var crc = -1;
  23631. for (var i = start; i < end; i++) {
  23632. var a = (crc ^ data[i]) & 0xff;
  23633. var b = crcTable[a];
  23634. crc = crc >>> 8 ^ b;
  23635. }
  23636. return crc ^ -1;
  23637. }
  23638. function writePngChunk(type, body, data, offset) {
  23639. var p = offset;
  23640. var len = body.length;
  23641. data[p] = len >> 24 & 0xff;
  23642. data[p + 1] = len >> 16 & 0xff;
  23643. data[p + 2] = len >> 8 & 0xff;
  23644. data[p + 3] = len & 0xff;
  23645. p += 4;
  23646. data[p] = type.charCodeAt(0) & 0xff;
  23647. data[p + 1] = type.charCodeAt(1) & 0xff;
  23648. data[p + 2] = type.charCodeAt(2) & 0xff;
  23649. data[p + 3] = type.charCodeAt(3) & 0xff;
  23650. p += 4;
  23651. data.set(body, p);
  23652. p += body.length;
  23653. var crc = crc32(data, offset + 4, p);
  23654. data[p] = crc >> 24 & 0xff;
  23655. data[p + 1] = crc >> 16 & 0xff;
  23656. data[p + 2] = crc >> 8 & 0xff;
  23657. data[p + 3] = crc & 0xff;
  23658. }
  23659. function adler32(data, start, end) {
  23660. var a = 1;
  23661. var b = 0;
  23662. for (var i = start; i < end; ++i) {
  23663. a = (a + (data[i] & 0xff)) % 65521;
  23664. b = (b + a) % 65521;
  23665. }
  23666. return b << 16 | a;
  23667. }
  23668. function encode(imgData, kind, forceDataSchema) {
  23669. var width = imgData.width;
  23670. var height = imgData.height;
  23671. var bitDepth, colorType, lineSize;
  23672. var bytes = imgData.data;
  23673. switch (kind) {
  23674. case ImageKind.GRAYSCALE_1BPP:
  23675. colorType = 0;
  23676. bitDepth = 1;
  23677. lineSize = width + 7 >> 3;
  23678. break;
  23679. case ImageKind.RGB_24BPP:
  23680. colorType = 2;
  23681. bitDepth = 8;
  23682. lineSize = width * 3;
  23683. break;
  23684. case ImageKind.RGBA_32BPP:
  23685. colorType = 6;
  23686. bitDepth = 8;
  23687. lineSize = width * 4;
  23688. break;
  23689. default:
  23690. throw new Error('invalid format');
  23691. }
  23692. var literals = new Uint8Array((1 + lineSize) * height);
  23693. var offsetLiterals = 0, offsetBytes = 0;
  23694. var y, i;
  23695. for (y = 0; y < height; ++y) {
  23696. literals[offsetLiterals++] = 0;
  23697. literals.set(bytes.subarray(offsetBytes, offsetBytes + lineSize), offsetLiterals);
  23698. offsetBytes += lineSize;
  23699. offsetLiterals += lineSize;
  23700. }
  23701. if (kind === ImageKind.GRAYSCALE_1BPP) {
  23702. offsetLiterals = 0;
  23703. for (y = 0; y < height; y++) {
  23704. offsetLiterals++;
  23705. for (i = 0; i < lineSize; i++) {
  23706. literals[offsetLiterals++] ^= 0xFF;
  23707. }
  23708. }
  23709. }
  23710. var ihdr = new Uint8Array([
  23711. width >> 24 & 0xff,
  23712. width >> 16 & 0xff,
  23713. width >> 8 & 0xff,
  23714. width & 0xff,
  23715. height >> 24 & 0xff,
  23716. height >> 16 & 0xff,
  23717. height >> 8 & 0xff,
  23718. height & 0xff,
  23719. bitDepth,
  23720. colorType,
  23721. 0x00,
  23722. 0x00,
  23723. 0x00
  23724. ]);
  23725. var len = literals.length;
  23726. var maxBlockLength = 0xFFFF;
  23727. var deflateBlocks = Math.ceil(len / maxBlockLength);
  23728. var idat = new Uint8Array(2 + len + deflateBlocks * 5 + 4);
  23729. var pi = 0;
  23730. idat[pi++] = 0x78;
  23731. idat[pi++] = 0x9c;
  23732. var pos = 0;
  23733. while (len > maxBlockLength) {
  23734. idat[pi++] = 0x00;
  23735. idat[pi++] = 0xff;
  23736. idat[pi++] = 0xff;
  23737. idat[pi++] = 0x00;
  23738. idat[pi++] = 0x00;
  23739. idat.set(literals.subarray(pos, pos + maxBlockLength), pi);
  23740. pi += maxBlockLength;
  23741. pos += maxBlockLength;
  23742. len -= maxBlockLength;
  23743. }
  23744. idat[pi++] = 0x01;
  23745. idat[pi++] = len & 0xff;
  23746. idat[pi++] = len >> 8 & 0xff;
  23747. idat[pi++] = ~len & 0xffff & 0xff;
  23748. idat[pi++] = (~len & 0xffff) >> 8 & 0xff;
  23749. idat.set(literals.subarray(pos), pi);
  23750. pi += literals.length - pos;
  23751. var adler = adler32(literals, 0, literals.length);
  23752. idat[pi++] = adler >> 24 & 0xff;
  23753. idat[pi++] = adler >> 16 & 0xff;
  23754. idat[pi++] = adler >> 8 & 0xff;
  23755. idat[pi++] = adler & 0xff;
  23756. var pngLength = PNG_HEADER.length + CHUNK_WRAPPER_SIZE * 3 + ihdr.length + idat.length;
  23757. var data = new Uint8Array(pngLength);
  23758. var offset = 0;
  23759. data.set(PNG_HEADER, offset);
  23760. offset += PNG_HEADER.length;
  23761. writePngChunk('IHDR', ihdr, data, offset);
  23762. offset += CHUNK_WRAPPER_SIZE + ihdr.length;
  23763. writePngChunk('IDATA', idat, data, offset);
  23764. offset += CHUNK_WRAPPER_SIZE + idat.length;
  23765. writePngChunk('IEND', new Uint8Array(0), data, offset);
  23766. return createObjectURL(data, 'image/png', forceDataSchema);
  23767. }
  23768. return function convertImgDataToPng(imgData, forceDataSchema) {
  23769. var kind = imgData.kind === undefined ? ImageKind.GRAYSCALE_1BPP : imgData.kind;
  23770. return encode(imgData, kind, forceDataSchema);
  23771. };
  23772. }();
  23773. var SVGExtraState = function SVGExtraStateClosure() {
  23774. function SVGExtraState() {
  23775. this.fontSizeScale = 1;
  23776. this.fontWeight = SVG_DEFAULTS.fontWeight;
  23777. this.fontSize = 0;
  23778. this.textMatrix = IDENTITY_MATRIX;
  23779. this.fontMatrix = FONT_IDENTITY_MATRIX;
  23780. this.leading = 0;
  23781. this.x = 0;
  23782. this.y = 0;
  23783. this.lineX = 0;
  23784. this.lineY = 0;
  23785. this.charSpacing = 0;
  23786. this.wordSpacing = 0;
  23787. this.textHScale = 1;
  23788. this.textRise = 0;
  23789. this.fillColor = SVG_DEFAULTS.fillColor;
  23790. this.strokeColor = '#000000';
  23791. this.fillAlpha = 1;
  23792. this.strokeAlpha = 1;
  23793. this.lineWidth = 1;
  23794. this.lineJoin = '';
  23795. this.lineCap = '';
  23796. this.miterLimit = 0;
  23797. this.dashArray = [];
  23798. this.dashPhase = 0;
  23799. this.dependencies = [];
  23800. this.activeClipUrl = null;
  23801. this.clipGroup = null;
  23802. this.maskId = '';
  23803. }
  23804. SVGExtraState.prototype = {
  23805. clone: function SVGExtraState_clone() {
  23806. return Object.create(this);
  23807. },
  23808. setCurrentPoint: function SVGExtraState_setCurrentPoint(x, y) {
  23809. this.x = x;
  23810. this.y = y;
  23811. }
  23812. };
  23813. return SVGExtraState;
  23814. }();
  23815. var SVGGraphics = function SVGGraphicsClosure() {
  23816. function opListToTree(opList) {
  23817. var opTree = [];
  23818. var tmp = [];
  23819. var opListLen = opList.length;
  23820. for (var x = 0; x < opListLen; x++) {
  23821. if (opList[x].fn === 'save') {
  23822. opTree.push({
  23823. 'fnId': 92,
  23824. 'fn': 'group',
  23825. 'items': []
  23826. });
  23827. tmp.push(opTree);
  23828. opTree = opTree[opTree.length - 1].items;
  23829. continue;
  23830. }
  23831. if (opList[x].fn === 'restore') {
  23832. opTree = tmp.pop();
  23833. } else {
  23834. opTree.push(opList[x]);
  23835. }
  23836. }
  23837. return opTree;
  23838. }
  23839. function pf(value) {
  23840. if (value === (value | 0)) {
  23841. return value.toString();
  23842. }
  23843. var s = value.toFixed(10);
  23844. var i = s.length - 1;
  23845. if (s[i] !== '0') {
  23846. return s;
  23847. }
  23848. do {
  23849. i--;
  23850. } while (s[i] === '0');
  23851. return s.substr(0, s[i] === '.' ? i : i + 1);
  23852. }
  23853. function pm(m) {
  23854. if (m[4] === 0 && m[5] === 0) {
  23855. if (m[1] === 0 && m[2] === 0) {
  23856. if (m[0] === 1 && m[3] === 1) {
  23857. return '';
  23858. }
  23859. return 'scale(' + pf(m[0]) + ' ' + pf(m[3]) + ')';
  23860. }
  23861. if (m[0] === m[3] && m[1] === -m[2]) {
  23862. var a = Math.acos(m[0]) * 180 / Math.PI;
  23863. return 'rotate(' + pf(a) + ')';
  23864. }
  23865. } else {
  23866. if (m[0] === 1 && m[1] === 0 && m[2] === 0 && m[3] === 1) {
  23867. return 'translate(' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23868. }
  23869. }
  23870. return 'matrix(' + pf(m[0]) + ' ' + pf(m[1]) + ' ' + pf(m[2]) + ' ' + pf(m[3]) + ' ' + pf(m[4]) + ' ' + pf(m[5]) + ')';
  23871. }
  23872. function SVGGraphics(commonObjs, objs, forceDataSchema) {
  23873. this.current = new SVGExtraState();
  23874. this.transformMatrix = IDENTITY_MATRIX;
  23875. this.transformStack = [];
  23876. this.extraStack = [];
  23877. this.commonObjs = commonObjs;
  23878. this.objs = objs;
  23879. this.pendingEOFill = false;
  23880. this.embedFonts = false;
  23881. this.embeddedFonts = Object.create(null);
  23882. this.cssStyle = null;
  23883. this.forceDataSchema = !!forceDataSchema;
  23884. }
  23885. var NS = 'http://www.w3.org/2000/svg';
  23886. var XML_NS = 'http://www.w3.org/XML/1998/namespace';
  23887. var XLINK_NS = 'http://www.w3.org/1999/xlink';
  23888. var LINE_CAP_STYLES = [
  23889. 'butt',
  23890. 'round',
  23891. 'square'
  23892. ];
  23893. var LINE_JOIN_STYLES = [
  23894. 'miter',
  23895. 'round',
  23896. 'bevel'
  23897. ];
  23898. var clipCount = 0;
  23899. var maskCount = 0;
  23900. SVGGraphics.prototype = {
  23901. save: function SVGGraphics_save() {
  23902. this.transformStack.push(this.transformMatrix);
  23903. var old = this.current;
  23904. this.extraStack.push(old);
  23905. this.current = old.clone();
  23906. },
  23907. restore: function SVGGraphics_restore() {
  23908. this.transformMatrix = this.transformStack.pop();
  23909. this.current = this.extraStack.pop();
  23910. this.tgrp = null;
  23911. },
  23912. group: function SVGGraphics_group(items) {
  23913. this.save();
  23914. this.executeOpTree(items);
  23915. this.restore();
  23916. },
  23917. loadDependencies: function SVGGraphics_loadDependencies(operatorList) {
  23918. var fnArray = operatorList.fnArray;
  23919. var fnArrayLen = fnArray.length;
  23920. var argsArray = operatorList.argsArray;
  23921. var self = this;
  23922. for (var i = 0; i < fnArrayLen; i++) {
  23923. if (OPS.dependency === fnArray[i]) {
  23924. var deps = argsArray[i];
  23925. for (var n = 0, nn = deps.length; n < nn; n++) {
  23926. var obj = deps[n];
  23927. var common = obj.substring(0, 2) === 'g_';
  23928. var promise;
  23929. if (common) {
  23930. promise = new Promise(function (resolve) {
  23931. self.commonObjs.get(obj, resolve);
  23932. });
  23933. } else {
  23934. promise = new Promise(function (resolve) {
  23935. self.objs.get(obj, resolve);
  23936. });
  23937. }
  23938. this.current.dependencies.push(promise);
  23939. }
  23940. }
  23941. }
  23942. return Promise.all(this.current.dependencies);
  23943. },
  23944. transform: function SVGGraphics_transform(a, b, c, d, e, f) {
  23945. var transformMatrix = [
  23946. a,
  23947. b,
  23948. c,
  23949. d,
  23950. e,
  23951. f
  23952. ];
  23953. this.transformMatrix = Util.transform(this.transformMatrix, transformMatrix);
  23954. this.tgrp = null;
  23955. },
  23956. getSVG: function SVGGraphics_getSVG(operatorList, viewport) {
  23957. this.viewport = viewport;
  23958. var svgElement = this._initialize(viewport);
  23959. return this.loadDependencies(operatorList).then(function () {
  23960. this.transformMatrix = IDENTITY_MATRIX;
  23961. var opTree = this.convertOpList(operatorList);
  23962. this.executeOpTree(opTree);
  23963. return svgElement;
  23964. }.bind(this));
  23965. },
  23966. convertOpList: function SVGGraphics_convertOpList(operatorList) {
  23967. var argsArray = operatorList.argsArray;
  23968. var fnArray = operatorList.fnArray;
  23969. var fnArrayLen = fnArray.length;
  23970. var REVOPS = [];
  23971. var opList = [];
  23972. for (var op in OPS) {
  23973. REVOPS[OPS[op]] = op;
  23974. }
  23975. for (var x = 0; x < fnArrayLen; x++) {
  23976. var fnId = fnArray[x];
  23977. opList.push({
  23978. 'fnId': fnId,
  23979. 'fn': REVOPS[fnId],
  23980. 'args': argsArray[x]
  23981. });
  23982. }
  23983. return opListToTree(opList);
  23984. },
  23985. executeOpTree: function SVGGraphics_executeOpTree(opTree) {
  23986. var opTreeLen = opTree.length;
  23987. for (var x = 0; x < opTreeLen; x++) {
  23988. var fn = opTree[x].fn;
  23989. var fnId = opTree[x].fnId;
  23990. var args = opTree[x].args;
  23991. switch (fnId | 0) {
  23992. case OPS.beginText:
  23993. this.beginText();
  23994. break;
  23995. case OPS.setLeading:
  23996. this.setLeading(args);
  23997. break;
  23998. case OPS.setLeadingMoveText:
  23999. this.setLeadingMoveText(args[0], args[1]);
  24000. break;
  24001. case OPS.setFont:
  24002. this.setFont(args);
  24003. break;
  24004. case OPS.showText:
  24005. this.showText(args[0]);
  24006. break;
  24007. case OPS.showSpacedText:
  24008. this.showText(args[0]);
  24009. break;
  24010. case OPS.endText:
  24011. this.endText();
  24012. break;
  24013. case OPS.moveText:
  24014. this.moveText(args[0], args[1]);
  24015. break;
  24016. case OPS.setCharSpacing:
  24017. this.setCharSpacing(args[0]);
  24018. break;
  24019. case OPS.setWordSpacing:
  24020. this.setWordSpacing(args[0]);
  24021. break;
  24022. case OPS.setHScale:
  24023. this.setHScale(args[0]);
  24024. break;
  24025. case OPS.setTextMatrix:
  24026. this.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  24027. break;
  24028. case OPS.setLineWidth:
  24029. this.setLineWidth(args[0]);
  24030. break;
  24031. case OPS.setLineJoin:
  24032. this.setLineJoin(args[0]);
  24033. break;
  24034. case OPS.setLineCap:
  24035. this.setLineCap(args[0]);
  24036. break;
  24037. case OPS.setMiterLimit:
  24038. this.setMiterLimit(args[0]);
  24039. break;
  24040. case OPS.setFillRGBColor:
  24041. this.setFillRGBColor(args[0], args[1], args[2]);
  24042. break;
  24043. case OPS.setStrokeRGBColor:
  24044. this.setStrokeRGBColor(args[0], args[1], args[2]);
  24045. break;
  24046. case OPS.setDash:
  24047. this.setDash(args[0], args[1]);
  24048. break;
  24049. case OPS.setGState:
  24050. this.setGState(args[0]);
  24051. break;
  24052. case OPS.fill:
  24053. this.fill();
  24054. break;
  24055. case OPS.eoFill:
  24056. this.eoFill();
  24057. break;
  24058. case OPS.stroke:
  24059. this.stroke();
  24060. break;
  24061. case OPS.fillStroke:
  24062. this.fillStroke();
  24063. break;
  24064. case OPS.eoFillStroke:
  24065. this.eoFillStroke();
  24066. break;
  24067. case OPS.clip:
  24068. this.clip('nonzero');
  24069. break;
  24070. case OPS.eoClip:
  24071. this.clip('evenodd');
  24072. break;
  24073. case OPS.paintSolidColorImageMask:
  24074. this.paintSolidColorImageMask();
  24075. break;
  24076. case OPS.paintJpegXObject:
  24077. this.paintJpegXObject(args[0], args[1], args[2]);
  24078. break;
  24079. case OPS.paintImageXObject:
  24080. this.paintImageXObject(args[0]);
  24081. break;
  24082. case OPS.paintInlineImageXObject:
  24083. this.paintInlineImageXObject(args[0]);
  24084. break;
  24085. case OPS.paintImageMaskXObject:
  24086. this.paintImageMaskXObject(args[0]);
  24087. break;
  24088. case OPS.paintFormXObjectBegin:
  24089. this.paintFormXObjectBegin(args[0], args[1]);
  24090. break;
  24091. case OPS.paintFormXObjectEnd:
  24092. this.paintFormXObjectEnd();
  24093. break;
  24094. case OPS.closePath:
  24095. this.closePath();
  24096. break;
  24097. case OPS.closeStroke:
  24098. this.closeStroke();
  24099. break;
  24100. case OPS.closeFillStroke:
  24101. this.closeFillStroke();
  24102. break;
  24103. case OPS.nextLine:
  24104. this.nextLine();
  24105. break;
  24106. case OPS.transform:
  24107. this.transform(args[0], args[1], args[2], args[3], args[4], args[5]);
  24108. break;
  24109. case OPS.constructPath:
  24110. this.constructPath(args[0], args[1]);
  24111. break;
  24112. case OPS.endPath:
  24113. this.endPath();
  24114. break;
  24115. case 92:
  24116. this.group(opTree[x].items);
  24117. break;
  24118. default:
  24119. warn('Unimplemented operator ' + fn);
  24120. break;
  24121. }
  24122. }
  24123. },
  24124. setWordSpacing: function SVGGraphics_setWordSpacing(wordSpacing) {
  24125. this.current.wordSpacing = wordSpacing;
  24126. },
  24127. setCharSpacing: function SVGGraphics_setCharSpacing(charSpacing) {
  24128. this.current.charSpacing = charSpacing;
  24129. },
  24130. nextLine: function SVGGraphics_nextLine() {
  24131. this.moveText(0, this.current.leading);
  24132. },
  24133. setTextMatrix: function SVGGraphics_setTextMatrix(a, b, c, d, e, f) {
  24134. var current = this.current;
  24135. this.current.textMatrix = this.current.lineMatrix = [
  24136. a,
  24137. b,
  24138. c,
  24139. d,
  24140. e,
  24141. f
  24142. ];
  24143. this.current.x = this.current.lineX = 0;
  24144. this.current.y = this.current.lineY = 0;
  24145. current.xcoords = [];
  24146. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24147. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24148. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24149. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24150. current.txtElement = document.createElementNS(NS, 'svg:text');
  24151. current.txtElement.appendChild(current.tspan);
  24152. },
  24153. beginText: function SVGGraphics_beginText() {
  24154. this.current.x = this.current.lineX = 0;
  24155. this.current.y = this.current.lineY = 0;
  24156. this.current.textMatrix = IDENTITY_MATRIX;
  24157. this.current.lineMatrix = IDENTITY_MATRIX;
  24158. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24159. this.current.txtElement = document.createElementNS(NS, 'svg:text');
  24160. this.current.txtgrp = document.createElementNS(NS, 'svg:g');
  24161. this.current.xcoords = [];
  24162. },
  24163. moveText: function SVGGraphics_moveText(x, y) {
  24164. var current = this.current;
  24165. this.current.x = this.current.lineX += x;
  24166. this.current.y = this.current.lineY += y;
  24167. current.xcoords = [];
  24168. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24169. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24170. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24171. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24172. },
  24173. showText: function SVGGraphics_showText(glyphs) {
  24174. var current = this.current;
  24175. var font = current.font;
  24176. var fontSize = current.fontSize;
  24177. if (fontSize === 0) {
  24178. return;
  24179. }
  24180. var charSpacing = current.charSpacing;
  24181. var wordSpacing = current.wordSpacing;
  24182. var fontDirection = current.fontDirection;
  24183. var textHScale = current.textHScale * fontDirection;
  24184. var glyphsLength = glyphs.length;
  24185. var vertical = font.vertical;
  24186. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  24187. var x = 0, i;
  24188. for (i = 0; i < glyphsLength; ++i) {
  24189. var glyph = glyphs[i];
  24190. if (glyph === null) {
  24191. x += fontDirection * wordSpacing;
  24192. continue;
  24193. } else if (isNum(glyph)) {
  24194. x += -glyph * fontSize * 0.001;
  24195. continue;
  24196. }
  24197. current.xcoords.push(current.x + x * textHScale);
  24198. var width = glyph.width;
  24199. var character = glyph.fontChar;
  24200. var charWidth = width * widthAdvanceScale + charSpacing * fontDirection;
  24201. x += charWidth;
  24202. current.tspan.textContent += character;
  24203. }
  24204. if (vertical) {
  24205. current.y -= x * textHScale;
  24206. } else {
  24207. current.x += x * textHScale;
  24208. }
  24209. current.tspan.setAttributeNS(null, 'x', current.xcoords.map(pf).join(' '));
  24210. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24211. current.tspan.setAttributeNS(null, 'font-family', current.fontFamily);
  24212. current.tspan.setAttributeNS(null, 'font-size', pf(current.fontSize) + 'px');
  24213. if (current.fontStyle !== SVG_DEFAULTS.fontStyle) {
  24214. current.tspan.setAttributeNS(null, 'font-style', current.fontStyle);
  24215. }
  24216. if (current.fontWeight !== SVG_DEFAULTS.fontWeight) {
  24217. current.tspan.setAttributeNS(null, 'font-weight', current.fontWeight);
  24218. }
  24219. if (current.fillColor !== SVG_DEFAULTS.fillColor) {
  24220. current.tspan.setAttributeNS(null, 'fill', current.fillColor);
  24221. }
  24222. current.txtElement.setAttributeNS(null, 'transform', pm(current.textMatrix) + ' scale(1, -1)');
  24223. current.txtElement.setAttributeNS(XML_NS, 'xml:space', 'preserve');
  24224. current.txtElement.appendChild(current.tspan);
  24225. current.txtgrp.appendChild(current.txtElement);
  24226. this._ensureTransformGroup().appendChild(current.txtElement);
  24227. },
  24228. setLeadingMoveText: function SVGGraphics_setLeadingMoveText(x, y) {
  24229. this.setLeading(-y);
  24230. this.moveText(x, y);
  24231. },
  24232. addFontStyle: function SVGGraphics_addFontStyle(fontObj) {
  24233. if (!this.cssStyle) {
  24234. this.cssStyle = document.createElementNS(NS, 'svg:style');
  24235. this.cssStyle.setAttributeNS(null, 'type', 'text/css');
  24236. this.defs.appendChild(this.cssStyle);
  24237. }
  24238. var url = createObjectURL(fontObj.data, fontObj.mimetype, this.forceDataSchema);
  24239. this.cssStyle.textContent += '@font-face { font-family: "' + fontObj.loadedName + '";' + ' src: url(' + url + '); }\n';
  24240. },
  24241. setFont: function SVGGraphics_setFont(details) {
  24242. var current = this.current;
  24243. var fontObj = this.commonObjs.get(details[0]);
  24244. var size = details[1];
  24245. this.current.font = fontObj;
  24246. if (this.embedFonts && fontObj.data && !this.embeddedFonts[fontObj.loadedName]) {
  24247. this.addFontStyle(fontObj);
  24248. this.embeddedFonts[fontObj.loadedName] = fontObj;
  24249. }
  24250. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  24251. var bold = fontObj.black ? fontObj.bold ? 'bolder' : 'bold' : fontObj.bold ? 'bold' : 'normal';
  24252. var italic = fontObj.italic ? 'italic' : 'normal';
  24253. if (size < 0) {
  24254. size = -size;
  24255. current.fontDirection = -1;
  24256. } else {
  24257. current.fontDirection = 1;
  24258. }
  24259. current.fontSize = size;
  24260. current.fontFamily = fontObj.loadedName;
  24261. current.fontWeight = bold;
  24262. current.fontStyle = italic;
  24263. current.tspan = document.createElementNS(NS, 'svg:tspan');
  24264. current.tspan.setAttributeNS(null, 'y', pf(-current.y));
  24265. current.xcoords = [];
  24266. },
  24267. endText: function SVGGraphics_endText() {
  24268. },
  24269. setLineWidth: function SVGGraphics_setLineWidth(width) {
  24270. this.current.lineWidth = width;
  24271. },
  24272. setLineCap: function SVGGraphics_setLineCap(style) {
  24273. this.current.lineCap = LINE_CAP_STYLES[style];
  24274. },
  24275. setLineJoin: function SVGGraphics_setLineJoin(style) {
  24276. this.current.lineJoin = LINE_JOIN_STYLES[style];
  24277. },
  24278. setMiterLimit: function SVGGraphics_setMiterLimit(limit) {
  24279. this.current.miterLimit = limit;
  24280. },
  24281. setStrokeRGBColor: function SVGGraphics_setStrokeRGBColor(r, g, b) {
  24282. var color = Util.makeCssRgb(r, g, b);
  24283. this.current.strokeColor = color;
  24284. },
  24285. setFillRGBColor: function SVGGraphics_setFillRGBColor(r, g, b) {
  24286. var color = Util.makeCssRgb(r, g, b);
  24287. this.current.fillColor = color;
  24288. this.current.tspan = document.createElementNS(NS, 'svg:tspan');
  24289. this.current.xcoords = [];
  24290. },
  24291. setDash: function SVGGraphics_setDash(dashArray, dashPhase) {
  24292. this.current.dashArray = dashArray;
  24293. this.current.dashPhase = dashPhase;
  24294. },
  24295. constructPath: function SVGGraphics_constructPath(ops, args) {
  24296. var current = this.current;
  24297. var x = current.x, y = current.y;
  24298. current.path = document.createElementNS(NS, 'svg:path');
  24299. var d = [];
  24300. var opLength = ops.length;
  24301. for (var i = 0, j = 0; i < opLength; i++) {
  24302. switch (ops[i] | 0) {
  24303. case OPS.rectangle:
  24304. x = args[j++];
  24305. y = args[j++];
  24306. var width = args[j++];
  24307. var height = args[j++];
  24308. var xw = x + width;
  24309. var yh = y + height;
  24310. d.push('M', pf(x), pf(y), 'L', pf(xw), pf(y), 'L', pf(xw), pf(yh), 'L', pf(x), pf(yh), 'Z');
  24311. break;
  24312. case OPS.moveTo:
  24313. x = args[j++];
  24314. y = args[j++];
  24315. d.push('M', pf(x), pf(y));
  24316. break;
  24317. case OPS.lineTo:
  24318. x = args[j++];
  24319. y = args[j++];
  24320. d.push('L', pf(x), pf(y));
  24321. break;
  24322. case OPS.curveTo:
  24323. x = args[j + 4];
  24324. y = args[j + 5];
  24325. d.push('C', pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]), pf(x), pf(y));
  24326. j += 6;
  24327. break;
  24328. case OPS.curveTo2:
  24329. x = args[j + 2];
  24330. y = args[j + 3];
  24331. d.push('C', pf(x), pf(y), pf(args[j]), pf(args[j + 1]), pf(args[j + 2]), pf(args[j + 3]));
  24332. j += 4;
  24333. break;
  24334. case OPS.curveTo3:
  24335. x = args[j + 2];
  24336. y = args[j + 3];
  24337. d.push('C', pf(args[j]), pf(args[j + 1]), pf(x), pf(y), pf(x), pf(y));
  24338. j += 4;
  24339. break;
  24340. case OPS.closePath:
  24341. d.push('Z');
  24342. break;
  24343. }
  24344. }
  24345. current.path.setAttributeNS(null, 'd', d.join(' '));
  24346. current.path.setAttributeNS(null, 'stroke-miterlimit', pf(current.miterLimit));
  24347. current.path.setAttributeNS(null, 'stroke-linecap', current.lineCap);
  24348. current.path.setAttributeNS(null, 'stroke-linejoin', current.lineJoin);
  24349. current.path.setAttributeNS(null, 'stroke-width', pf(current.lineWidth) + 'px');
  24350. current.path.setAttributeNS(null, 'stroke-dasharray', current.dashArray.map(pf).join(' '));
  24351. current.path.setAttributeNS(null, 'stroke-dashoffset', pf(current.dashPhase) + 'px');
  24352. current.path.setAttributeNS(null, 'fill', 'none');
  24353. this._ensureTransformGroup().appendChild(current.path);
  24354. current.element = current.path;
  24355. current.setCurrentPoint(x, y);
  24356. },
  24357. endPath: function SVGGraphics_endPath() {
  24358. },
  24359. clip: function SVGGraphics_clip(type) {
  24360. var current = this.current;
  24361. var clipId = 'clippath' + clipCount;
  24362. clipCount++;
  24363. var clipPath = document.createElementNS(NS, 'svg:clipPath');
  24364. clipPath.setAttributeNS(null, 'id', clipId);
  24365. clipPath.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24366. var clipElement = current.element.cloneNode();
  24367. if (type === 'evenodd') {
  24368. clipElement.setAttributeNS(null, 'clip-rule', 'evenodd');
  24369. } else {
  24370. clipElement.setAttributeNS(null, 'clip-rule', 'nonzero');
  24371. }
  24372. clipPath.appendChild(clipElement);
  24373. this.defs.appendChild(clipPath);
  24374. if (current.activeClipUrl) {
  24375. current.clipGroup = null;
  24376. this.extraStack.forEach(function (prev) {
  24377. prev.clipGroup = null;
  24378. });
  24379. }
  24380. current.activeClipUrl = 'url(#' + clipId + ')';
  24381. this.tgrp = null;
  24382. },
  24383. closePath: function SVGGraphics_closePath() {
  24384. var current = this.current;
  24385. var d = current.path.getAttributeNS(null, 'd');
  24386. d += 'Z';
  24387. current.path.setAttributeNS(null, 'd', d);
  24388. },
  24389. setLeading: function SVGGraphics_setLeading(leading) {
  24390. this.current.leading = -leading;
  24391. },
  24392. setTextRise: function SVGGraphics_setTextRise(textRise) {
  24393. this.current.textRise = textRise;
  24394. },
  24395. setHScale: function SVGGraphics_setHScale(scale) {
  24396. this.current.textHScale = scale / 100;
  24397. },
  24398. setGState: function SVGGraphics_setGState(states) {
  24399. for (var i = 0, ii = states.length; i < ii; i++) {
  24400. var state = states[i];
  24401. var key = state[0];
  24402. var value = state[1];
  24403. switch (key) {
  24404. case 'LW':
  24405. this.setLineWidth(value);
  24406. break;
  24407. case 'LC':
  24408. this.setLineCap(value);
  24409. break;
  24410. case 'LJ':
  24411. this.setLineJoin(value);
  24412. break;
  24413. case 'ML':
  24414. this.setMiterLimit(value);
  24415. break;
  24416. case 'D':
  24417. this.setDash(value[0], value[1]);
  24418. break;
  24419. case 'Font':
  24420. this.setFont(value);
  24421. break;
  24422. default:
  24423. warn('Unimplemented graphic state ' + key);
  24424. break;
  24425. }
  24426. }
  24427. },
  24428. fill: function SVGGraphics_fill() {
  24429. var current = this.current;
  24430. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24431. },
  24432. stroke: function SVGGraphics_stroke() {
  24433. var current = this.current;
  24434. current.element.setAttributeNS(null, 'stroke', current.strokeColor);
  24435. current.element.setAttributeNS(null, 'fill', 'none');
  24436. },
  24437. eoFill: function SVGGraphics_eoFill() {
  24438. var current = this.current;
  24439. current.element.setAttributeNS(null, 'fill', current.fillColor);
  24440. current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24441. },
  24442. fillStroke: function SVGGraphics_fillStroke() {
  24443. this.stroke();
  24444. this.fill();
  24445. },
  24446. eoFillStroke: function SVGGraphics_eoFillStroke() {
  24447. this.current.element.setAttributeNS(null, 'fill-rule', 'evenodd');
  24448. this.fillStroke();
  24449. },
  24450. closeStroke: function SVGGraphics_closeStroke() {
  24451. this.closePath();
  24452. this.stroke();
  24453. },
  24454. closeFillStroke: function SVGGraphics_closeFillStroke() {
  24455. this.closePath();
  24456. this.fillStroke();
  24457. },
  24458. paintSolidColorImageMask: function SVGGraphics_paintSolidColorImageMask() {
  24459. var current = this.current;
  24460. var rect = document.createElementNS(NS, 'svg:rect');
  24461. rect.setAttributeNS(null, 'x', '0');
  24462. rect.setAttributeNS(null, 'y', '0');
  24463. rect.setAttributeNS(null, 'width', '1px');
  24464. rect.setAttributeNS(null, 'height', '1px');
  24465. rect.setAttributeNS(null, 'fill', current.fillColor);
  24466. this._ensureTransformGroup().appendChild(rect);
  24467. },
  24468. paintJpegXObject: function SVGGraphics_paintJpegXObject(objId, w, h) {
  24469. var imgObj = this.objs.get(objId);
  24470. var imgEl = document.createElementNS(NS, 'svg:image');
  24471. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgObj.src);
  24472. imgEl.setAttributeNS(null, 'width', imgObj.width + 'px');
  24473. imgEl.setAttributeNS(null, 'height', imgObj.height + 'px');
  24474. imgEl.setAttributeNS(null, 'x', '0');
  24475. imgEl.setAttributeNS(null, 'y', pf(-h));
  24476. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / w) + ' ' + pf(-1 / h) + ')');
  24477. this._ensureTransformGroup().appendChild(imgEl);
  24478. },
  24479. paintImageXObject: function SVGGraphics_paintImageXObject(objId) {
  24480. var imgData = this.objs.get(objId);
  24481. if (!imgData) {
  24482. warn('Dependent image isn\'t ready yet');
  24483. return;
  24484. }
  24485. this.paintInlineImageXObject(imgData);
  24486. },
  24487. paintInlineImageXObject: function SVGGraphics_paintInlineImageXObject(imgData, mask) {
  24488. var width = imgData.width;
  24489. var height = imgData.height;
  24490. var imgSrc = convertImgDataToPng(imgData, this.forceDataSchema);
  24491. var cliprect = document.createElementNS(NS, 'svg:rect');
  24492. cliprect.setAttributeNS(null, 'x', '0');
  24493. cliprect.setAttributeNS(null, 'y', '0');
  24494. cliprect.setAttributeNS(null, 'width', pf(width));
  24495. cliprect.setAttributeNS(null, 'height', pf(height));
  24496. this.current.element = cliprect;
  24497. this.clip('nonzero');
  24498. var imgEl = document.createElementNS(NS, 'svg:image');
  24499. imgEl.setAttributeNS(XLINK_NS, 'xlink:href', imgSrc);
  24500. imgEl.setAttributeNS(null, 'x', '0');
  24501. imgEl.setAttributeNS(null, 'y', pf(-height));
  24502. imgEl.setAttributeNS(null, 'width', pf(width) + 'px');
  24503. imgEl.setAttributeNS(null, 'height', pf(height) + 'px');
  24504. imgEl.setAttributeNS(null, 'transform', 'scale(' + pf(1 / width) + ' ' + pf(-1 / height) + ')');
  24505. if (mask) {
  24506. mask.appendChild(imgEl);
  24507. } else {
  24508. this._ensureTransformGroup().appendChild(imgEl);
  24509. }
  24510. },
  24511. paintImageMaskXObject: function SVGGraphics_paintImageMaskXObject(imgData) {
  24512. var current = this.current;
  24513. var width = imgData.width;
  24514. var height = imgData.height;
  24515. var fillColor = current.fillColor;
  24516. current.maskId = 'mask' + maskCount++;
  24517. var mask = document.createElementNS(NS, 'svg:mask');
  24518. mask.setAttributeNS(null, 'id', current.maskId);
  24519. var rect = document.createElementNS(NS, 'svg:rect');
  24520. rect.setAttributeNS(null, 'x', '0');
  24521. rect.setAttributeNS(null, 'y', '0');
  24522. rect.setAttributeNS(null, 'width', pf(width));
  24523. rect.setAttributeNS(null, 'height', pf(height));
  24524. rect.setAttributeNS(null, 'fill', fillColor);
  24525. rect.setAttributeNS(null, 'mask', 'url(#' + current.maskId + ')');
  24526. this.defs.appendChild(mask);
  24527. this._ensureTransformGroup().appendChild(rect);
  24528. this.paintInlineImageXObject(imgData, mask);
  24529. },
  24530. paintFormXObjectBegin: function SVGGraphics_paintFormXObjectBegin(matrix, bbox) {
  24531. if (isArray(matrix) && matrix.length === 6) {
  24532. this.transform(matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]);
  24533. }
  24534. if (isArray(bbox) && bbox.length === 4) {
  24535. var width = bbox[2] - bbox[0];
  24536. var height = bbox[3] - bbox[1];
  24537. var cliprect = document.createElementNS(NS, 'svg:rect');
  24538. cliprect.setAttributeNS(null, 'x', bbox[0]);
  24539. cliprect.setAttributeNS(null, 'y', bbox[1]);
  24540. cliprect.setAttributeNS(null, 'width', pf(width));
  24541. cliprect.setAttributeNS(null, 'height', pf(height));
  24542. this.current.element = cliprect;
  24543. this.clip('nonzero');
  24544. this.endPath();
  24545. }
  24546. },
  24547. paintFormXObjectEnd: function SVGGraphics_paintFormXObjectEnd() {
  24548. },
  24549. _initialize: function SVGGraphics_initialize(viewport) {
  24550. var svg = document.createElementNS(NS, 'svg:svg');
  24551. svg.setAttributeNS(null, 'version', '1.1');
  24552. svg.setAttributeNS(null, 'width', viewport.width + 'px');
  24553. svg.setAttributeNS(null, 'height', viewport.height + 'px');
  24554. svg.setAttributeNS(null, 'preserveAspectRatio', 'none');
  24555. svg.setAttributeNS(null, 'viewBox', '0 0 ' + viewport.width + ' ' + viewport.height);
  24556. var definitions = document.createElementNS(NS, 'svg:defs');
  24557. svg.appendChild(definitions);
  24558. this.defs = definitions;
  24559. var rootGroup = document.createElementNS(NS, 'svg:g');
  24560. rootGroup.setAttributeNS(null, 'transform', pm(viewport.transform));
  24561. svg.appendChild(rootGroup);
  24562. this.svg = rootGroup;
  24563. return svg;
  24564. },
  24565. _ensureClipGroup: function SVGGraphics_ensureClipGroup() {
  24566. if (!this.current.clipGroup) {
  24567. var clipGroup = document.createElementNS(NS, 'svg:g');
  24568. clipGroup.setAttributeNS(null, 'clip-path', this.current.activeClipUrl);
  24569. this.svg.appendChild(clipGroup);
  24570. this.current.clipGroup = clipGroup;
  24571. }
  24572. return this.current.clipGroup;
  24573. },
  24574. _ensureTransformGroup: function SVGGraphics_ensureTransformGroup() {
  24575. if (!this.tgrp) {
  24576. this.tgrp = document.createElementNS(NS, 'svg:g');
  24577. this.tgrp.setAttributeNS(null, 'transform', pm(this.transformMatrix));
  24578. if (this.current.activeClipUrl) {
  24579. this._ensureClipGroup().appendChild(this.tgrp);
  24580. } else {
  24581. this.svg.appendChild(this.tgrp);
  24582. }
  24583. }
  24584. return this.tgrp;
  24585. }
  24586. };
  24587. return SVGGraphics;
  24588. }();
  24589. exports.SVGGraphics = SVGGraphics;
  24590. }));
  24591. (function (root, factory) {
  24592. factory(root.pdfjsCoreStream = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreJbig2, root.pdfjsCoreJpg, root.pdfjsCoreJpx);
  24593. }(this, function (exports, sharedUtil, corePrimitives, coreJbig2, coreJpg, coreJpx) {
  24594. var Util = sharedUtil.Util;
  24595. var error = sharedUtil.error;
  24596. var info = sharedUtil.info;
  24597. var isInt = sharedUtil.isInt;
  24598. var isArray = sharedUtil.isArray;
  24599. var createObjectURL = sharedUtil.createObjectURL;
  24600. var shadow = sharedUtil.shadow;
  24601. var warn = sharedUtil.warn;
  24602. var isSpace = sharedUtil.isSpace;
  24603. var Dict = corePrimitives.Dict;
  24604. var isDict = corePrimitives.isDict;
  24605. var isStream = corePrimitives.isStream;
  24606. var Jbig2Image = coreJbig2.Jbig2Image;
  24607. var JpegImage = coreJpg.JpegImage;
  24608. var JpxImage = coreJpx.JpxImage;
  24609. var Stream = function StreamClosure() {
  24610. function Stream(arrayBuffer, start, length, dict) {
  24611. this.bytes = arrayBuffer instanceof Uint8Array ? arrayBuffer : new Uint8Array(arrayBuffer);
  24612. this.start = start || 0;
  24613. this.pos = this.start;
  24614. this.end = start + length || this.bytes.length;
  24615. this.dict = dict;
  24616. }
  24617. Stream.prototype = {
  24618. get length() {
  24619. return this.end - this.start;
  24620. },
  24621. get isEmpty() {
  24622. return this.length === 0;
  24623. },
  24624. getByte: function Stream_getByte() {
  24625. if (this.pos >= this.end) {
  24626. return -1;
  24627. }
  24628. return this.bytes[this.pos++];
  24629. },
  24630. getUint16: function Stream_getUint16() {
  24631. var b0 = this.getByte();
  24632. var b1 = this.getByte();
  24633. if (b0 === -1 || b1 === -1) {
  24634. return -1;
  24635. }
  24636. return (b0 << 8) + b1;
  24637. },
  24638. getInt32: function Stream_getInt32() {
  24639. var b0 = this.getByte();
  24640. var b1 = this.getByte();
  24641. var b2 = this.getByte();
  24642. var b3 = this.getByte();
  24643. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24644. },
  24645. getBytes: function Stream_getBytes(length) {
  24646. var bytes = this.bytes;
  24647. var pos = this.pos;
  24648. var strEnd = this.end;
  24649. if (!length) {
  24650. return bytes.subarray(pos, strEnd);
  24651. }
  24652. var end = pos + length;
  24653. if (end > strEnd) {
  24654. end = strEnd;
  24655. }
  24656. this.pos = end;
  24657. return bytes.subarray(pos, end);
  24658. },
  24659. peekByte: function Stream_peekByte() {
  24660. var peekedByte = this.getByte();
  24661. this.pos--;
  24662. return peekedByte;
  24663. },
  24664. peekBytes: function Stream_peekBytes(length) {
  24665. var bytes = this.getBytes(length);
  24666. this.pos -= bytes.length;
  24667. return bytes;
  24668. },
  24669. skip: function Stream_skip(n) {
  24670. if (!n) {
  24671. n = 1;
  24672. }
  24673. this.pos += n;
  24674. },
  24675. reset: function Stream_reset() {
  24676. this.pos = this.start;
  24677. },
  24678. moveStart: function Stream_moveStart() {
  24679. this.start = this.pos;
  24680. },
  24681. makeSubStream: function Stream_makeSubStream(start, length, dict) {
  24682. return new Stream(this.bytes.buffer, start, length, dict);
  24683. },
  24684. isStream: true
  24685. };
  24686. return Stream;
  24687. }();
  24688. var StringStream = function StringStreamClosure() {
  24689. function StringStream(str) {
  24690. var length = str.length;
  24691. var bytes = new Uint8Array(length);
  24692. for (var n = 0; n < length; ++n) {
  24693. bytes[n] = str.charCodeAt(n);
  24694. }
  24695. Stream.call(this, bytes);
  24696. }
  24697. StringStream.prototype = Stream.prototype;
  24698. return StringStream;
  24699. }();
  24700. var DecodeStream = function DecodeStreamClosure() {
  24701. var emptyBuffer = new Uint8Array(0);
  24702. function DecodeStream(maybeMinBufferLength) {
  24703. this.pos = 0;
  24704. this.bufferLength = 0;
  24705. this.eof = false;
  24706. this.buffer = emptyBuffer;
  24707. this.minBufferLength = 512;
  24708. if (maybeMinBufferLength) {
  24709. while (this.minBufferLength < maybeMinBufferLength) {
  24710. this.minBufferLength *= 2;
  24711. }
  24712. }
  24713. }
  24714. DecodeStream.prototype = {
  24715. get isEmpty() {
  24716. while (!this.eof && this.bufferLength === 0) {
  24717. this.readBlock();
  24718. }
  24719. return this.bufferLength === 0;
  24720. },
  24721. ensureBuffer: function DecodeStream_ensureBuffer(requested) {
  24722. var buffer = this.buffer;
  24723. if (requested <= buffer.byteLength) {
  24724. return buffer;
  24725. }
  24726. var size = this.minBufferLength;
  24727. while (size < requested) {
  24728. size *= 2;
  24729. }
  24730. var buffer2 = new Uint8Array(size);
  24731. buffer2.set(buffer);
  24732. return this.buffer = buffer2;
  24733. },
  24734. getByte: function DecodeStream_getByte() {
  24735. var pos = this.pos;
  24736. while (this.bufferLength <= pos) {
  24737. if (this.eof) {
  24738. return -1;
  24739. }
  24740. this.readBlock();
  24741. }
  24742. return this.buffer[this.pos++];
  24743. },
  24744. getUint16: function DecodeStream_getUint16() {
  24745. var b0 = this.getByte();
  24746. var b1 = this.getByte();
  24747. if (b0 === -1 || b1 === -1) {
  24748. return -1;
  24749. }
  24750. return (b0 << 8) + b1;
  24751. },
  24752. getInt32: function DecodeStream_getInt32() {
  24753. var b0 = this.getByte();
  24754. var b1 = this.getByte();
  24755. var b2 = this.getByte();
  24756. var b3 = this.getByte();
  24757. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  24758. },
  24759. getBytes: function DecodeStream_getBytes(length) {
  24760. var end, pos = this.pos;
  24761. if (length) {
  24762. this.ensureBuffer(pos + length);
  24763. end = pos + length;
  24764. while (!this.eof && this.bufferLength < end) {
  24765. this.readBlock();
  24766. }
  24767. var bufEnd = this.bufferLength;
  24768. if (end > bufEnd) {
  24769. end = bufEnd;
  24770. }
  24771. } else {
  24772. while (!this.eof) {
  24773. this.readBlock();
  24774. }
  24775. end = this.bufferLength;
  24776. }
  24777. this.pos = end;
  24778. return this.buffer.subarray(pos, end);
  24779. },
  24780. peekByte: function DecodeStream_peekByte() {
  24781. var peekedByte = this.getByte();
  24782. this.pos--;
  24783. return peekedByte;
  24784. },
  24785. peekBytes: function DecodeStream_peekBytes(length) {
  24786. var bytes = this.getBytes(length);
  24787. this.pos -= bytes.length;
  24788. return bytes;
  24789. },
  24790. makeSubStream: function DecodeStream_makeSubStream(start, length, dict) {
  24791. var end = start + length;
  24792. while (this.bufferLength <= end && !this.eof) {
  24793. this.readBlock();
  24794. }
  24795. return new Stream(this.buffer, start, length, dict);
  24796. },
  24797. skip: function DecodeStream_skip(n) {
  24798. if (!n) {
  24799. n = 1;
  24800. }
  24801. this.pos += n;
  24802. },
  24803. reset: function DecodeStream_reset() {
  24804. this.pos = 0;
  24805. },
  24806. getBaseStreams: function DecodeStream_getBaseStreams() {
  24807. if (this.str && this.str.getBaseStreams) {
  24808. return this.str.getBaseStreams();
  24809. }
  24810. return [];
  24811. }
  24812. };
  24813. return DecodeStream;
  24814. }();
  24815. var StreamsSequenceStream = function StreamsSequenceStreamClosure() {
  24816. function StreamsSequenceStream(streams) {
  24817. this.streams = streams;
  24818. DecodeStream.call(this, null);
  24819. }
  24820. StreamsSequenceStream.prototype = Object.create(DecodeStream.prototype);
  24821. StreamsSequenceStream.prototype.readBlock = function streamSequenceStreamReadBlock() {
  24822. var streams = this.streams;
  24823. if (streams.length === 0) {
  24824. this.eof = true;
  24825. return;
  24826. }
  24827. var stream = streams.shift();
  24828. var chunk = stream.getBytes();
  24829. var bufferLength = this.bufferLength;
  24830. var newLength = bufferLength + chunk.length;
  24831. var buffer = this.ensureBuffer(newLength);
  24832. buffer.set(chunk, bufferLength);
  24833. this.bufferLength = newLength;
  24834. };
  24835. StreamsSequenceStream.prototype.getBaseStreams = function StreamsSequenceStream_getBaseStreams() {
  24836. var baseStreams = [];
  24837. for (var i = 0, ii = this.streams.length; i < ii; i++) {
  24838. var stream = this.streams[i];
  24839. if (stream.getBaseStreams) {
  24840. Util.appendToArray(baseStreams, stream.getBaseStreams());
  24841. }
  24842. }
  24843. return baseStreams;
  24844. };
  24845. return StreamsSequenceStream;
  24846. }();
  24847. var FlateStream = function FlateStreamClosure() {
  24848. var codeLenCodeMap = new Int32Array([
  24849. 16,
  24850. 17,
  24851. 18,
  24852. 0,
  24853. 8,
  24854. 7,
  24855. 9,
  24856. 6,
  24857. 10,
  24858. 5,
  24859. 11,
  24860. 4,
  24861. 12,
  24862. 3,
  24863. 13,
  24864. 2,
  24865. 14,
  24866. 1,
  24867. 15
  24868. ]);
  24869. var lengthDecode = new Int32Array([
  24870. 0x00003,
  24871. 0x00004,
  24872. 0x00005,
  24873. 0x00006,
  24874. 0x00007,
  24875. 0x00008,
  24876. 0x00009,
  24877. 0x0000a,
  24878. 0x1000b,
  24879. 0x1000d,
  24880. 0x1000f,
  24881. 0x10011,
  24882. 0x20013,
  24883. 0x20017,
  24884. 0x2001b,
  24885. 0x2001f,
  24886. 0x30023,
  24887. 0x3002b,
  24888. 0x30033,
  24889. 0x3003b,
  24890. 0x40043,
  24891. 0x40053,
  24892. 0x40063,
  24893. 0x40073,
  24894. 0x50083,
  24895. 0x500a3,
  24896. 0x500c3,
  24897. 0x500e3,
  24898. 0x00102,
  24899. 0x00102,
  24900. 0x00102
  24901. ]);
  24902. var distDecode = new Int32Array([
  24903. 0x00001,
  24904. 0x00002,
  24905. 0x00003,
  24906. 0x00004,
  24907. 0x10005,
  24908. 0x10007,
  24909. 0x20009,
  24910. 0x2000d,
  24911. 0x30011,
  24912. 0x30019,
  24913. 0x40021,
  24914. 0x40031,
  24915. 0x50041,
  24916. 0x50061,
  24917. 0x60081,
  24918. 0x600c1,
  24919. 0x70101,
  24920. 0x70181,
  24921. 0x80201,
  24922. 0x80301,
  24923. 0x90401,
  24924. 0x90601,
  24925. 0xa0801,
  24926. 0xa0c01,
  24927. 0xb1001,
  24928. 0xb1801,
  24929. 0xc2001,
  24930. 0xc3001,
  24931. 0xd4001,
  24932. 0xd6001
  24933. ]);
  24934. var fixedLitCodeTab = [
  24935. new Int32Array([
  24936. 0x70100,
  24937. 0x80050,
  24938. 0x80010,
  24939. 0x80118,
  24940. 0x70110,
  24941. 0x80070,
  24942. 0x80030,
  24943. 0x900c0,
  24944. 0x70108,
  24945. 0x80060,
  24946. 0x80020,
  24947. 0x900a0,
  24948. 0x80000,
  24949. 0x80080,
  24950. 0x80040,
  24951. 0x900e0,
  24952. 0x70104,
  24953. 0x80058,
  24954. 0x80018,
  24955. 0x90090,
  24956. 0x70114,
  24957. 0x80078,
  24958. 0x80038,
  24959. 0x900d0,
  24960. 0x7010c,
  24961. 0x80068,
  24962. 0x80028,
  24963. 0x900b0,
  24964. 0x80008,
  24965. 0x80088,
  24966. 0x80048,
  24967. 0x900f0,
  24968. 0x70102,
  24969. 0x80054,
  24970. 0x80014,
  24971. 0x8011c,
  24972. 0x70112,
  24973. 0x80074,
  24974. 0x80034,
  24975. 0x900c8,
  24976. 0x7010a,
  24977. 0x80064,
  24978. 0x80024,
  24979. 0x900a8,
  24980. 0x80004,
  24981. 0x80084,
  24982. 0x80044,
  24983. 0x900e8,
  24984. 0x70106,
  24985. 0x8005c,
  24986. 0x8001c,
  24987. 0x90098,
  24988. 0x70116,
  24989. 0x8007c,
  24990. 0x8003c,
  24991. 0x900d8,
  24992. 0x7010e,
  24993. 0x8006c,
  24994. 0x8002c,
  24995. 0x900b8,
  24996. 0x8000c,
  24997. 0x8008c,
  24998. 0x8004c,
  24999. 0x900f8,
  25000. 0x70101,
  25001. 0x80052,
  25002. 0x80012,
  25003. 0x8011a,
  25004. 0x70111,
  25005. 0x80072,
  25006. 0x80032,
  25007. 0x900c4,
  25008. 0x70109,
  25009. 0x80062,
  25010. 0x80022,
  25011. 0x900a4,
  25012. 0x80002,
  25013. 0x80082,
  25014. 0x80042,
  25015. 0x900e4,
  25016. 0x70105,
  25017. 0x8005a,
  25018. 0x8001a,
  25019. 0x90094,
  25020. 0x70115,
  25021. 0x8007a,
  25022. 0x8003a,
  25023. 0x900d4,
  25024. 0x7010d,
  25025. 0x8006a,
  25026. 0x8002a,
  25027. 0x900b4,
  25028. 0x8000a,
  25029. 0x8008a,
  25030. 0x8004a,
  25031. 0x900f4,
  25032. 0x70103,
  25033. 0x80056,
  25034. 0x80016,
  25035. 0x8011e,
  25036. 0x70113,
  25037. 0x80076,
  25038. 0x80036,
  25039. 0x900cc,
  25040. 0x7010b,
  25041. 0x80066,
  25042. 0x80026,
  25043. 0x900ac,
  25044. 0x80006,
  25045. 0x80086,
  25046. 0x80046,
  25047. 0x900ec,
  25048. 0x70107,
  25049. 0x8005e,
  25050. 0x8001e,
  25051. 0x9009c,
  25052. 0x70117,
  25053. 0x8007e,
  25054. 0x8003e,
  25055. 0x900dc,
  25056. 0x7010f,
  25057. 0x8006e,
  25058. 0x8002e,
  25059. 0x900bc,
  25060. 0x8000e,
  25061. 0x8008e,
  25062. 0x8004e,
  25063. 0x900fc,
  25064. 0x70100,
  25065. 0x80051,
  25066. 0x80011,
  25067. 0x80119,
  25068. 0x70110,
  25069. 0x80071,
  25070. 0x80031,
  25071. 0x900c2,
  25072. 0x70108,
  25073. 0x80061,
  25074. 0x80021,
  25075. 0x900a2,
  25076. 0x80001,
  25077. 0x80081,
  25078. 0x80041,
  25079. 0x900e2,
  25080. 0x70104,
  25081. 0x80059,
  25082. 0x80019,
  25083. 0x90092,
  25084. 0x70114,
  25085. 0x80079,
  25086. 0x80039,
  25087. 0x900d2,
  25088. 0x7010c,
  25089. 0x80069,
  25090. 0x80029,
  25091. 0x900b2,
  25092. 0x80009,
  25093. 0x80089,
  25094. 0x80049,
  25095. 0x900f2,
  25096. 0x70102,
  25097. 0x80055,
  25098. 0x80015,
  25099. 0x8011d,
  25100. 0x70112,
  25101. 0x80075,
  25102. 0x80035,
  25103. 0x900ca,
  25104. 0x7010a,
  25105. 0x80065,
  25106. 0x80025,
  25107. 0x900aa,
  25108. 0x80005,
  25109. 0x80085,
  25110. 0x80045,
  25111. 0x900ea,
  25112. 0x70106,
  25113. 0x8005d,
  25114. 0x8001d,
  25115. 0x9009a,
  25116. 0x70116,
  25117. 0x8007d,
  25118. 0x8003d,
  25119. 0x900da,
  25120. 0x7010e,
  25121. 0x8006d,
  25122. 0x8002d,
  25123. 0x900ba,
  25124. 0x8000d,
  25125. 0x8008d,
  25126. 0x8004d,
  25127. 0x900fa,
  25128. 0x70101,
  25129. 0x80053,
  25130. 0x80013,
  25131. 0x8011b,
  25132. 0x70111,
  25133. 0x80073,
  25134. 0x80033,
  25135. 0x900c6,
  25136. 0x70109,
  25137. 0x80063,
  25138. 0x80023,
  25139. 0x900a6,
  25140. 0x80003,
  25141. 0x80083,
  25142. 0x80043,
  25143. 0x900e6,
  25144. 0x70105,
  25145. 0x8005b,
  25146. 0x8001b,
  25147. 0x90096,
  25148. 0x70115,
  25149. 0x8007b,
  25150. 0x8003b,
  25151. 0x900d6,
  25152. 0x7010d,
  25153. 0x8006b,
  25154. 0x8002b,
  25155. 0x900b6,
  25156. 0x8000b,
  25157. 0x8008b,
  25158. 0x8004b,
  25159. 0x900f6,
  25160. 0x70103,
  25161. 0x80057,
  25162. 0x80017,
  25163. 0x8011f,
  25164. 0x70113,
  25165. 0x80077,
  25166. 0x80037,
  25167. 0x900ce,
  25168. 0x7010b,
  25169. 0x80067,
  25170. 0x80027,
  25171. 0x900ae,
  25172. 0x80007,
  25173. 0x80087,
  25174. 0x80047,
  25175. 0x900ee,
  25176. 0x70107,
  25177. 0x8005f,
  25178. 0x8001f,
  25179. 0x9009e,
  25180. 0x70117,
  25181. 0x8007f,
  25182. 0x8003f,
  25183. 0x900de,
  25184. 0x7010f,
  25185. 0x8006f,
  25186. 0x8002f,
  25187. 0x900be,
  25188. 0x8000f,
  25189. 0x8008f,
  25190. 0x8004f,
  25191. 0x900fe,
  25192. 0x70100,
  25193. 0x80050,
  25194. 0x80010,
  25195. 0x80118,
  25196. 0x70110,
  25197. 0x80070,
  25198. 0x80030,
  25199. 0x900c1,
  25200. 0x70108,
  25201. 0x80060,
  25202. 0x80020,
  25203. 0x900a1,
  25204. 0x80000,
  25205. 0x80080,
  25206. 0x80040,
  25207. 0x900e1,
  25208. 0x70104,
  25209. 0x80058,
  25210. 0x80018,
  25211. 0x90091,
  25212. 0x70114,
  25213. 0x80078,
  25214. 0x80038,
  25215. 0x900d1,
  25216. 0x7010c,
  25217. 0x80068,
  25218. 0x80028,
  25219. 0x900b1,
  25220. 0x80008,
  25221. 0x80088,
  25222. 0x80048,
  25223. 0x900f1,
  25224. 0x70102,
  25225. 0x80054,
  25226. 0x80014,
  25227. 0x8011c,
  25228. 0x70112,
  25229. 0x80074,
  25230. 0x80034,
  25231. 0x900c9,
  25232. 0x7010a,
  25233. 0x80064,
  25234. 0x80024,
  25235. 0x900a9,
  25236. 0x80004,
  25237. 0x80084,
  25238. 0x80044,
  25239. 0x900e9,
  25240. 0x70106,
  25241. 0x8005c,
  25242. 0x8001c,
  25243. 0x90099,
  25244. 0x70116,
  25245. 0x8007c,
  25246. 0x8003c,
  25247. 0x900d9,
  25248. 0x7010e,
  25249. 0x8006c,
  25250. 0x8002c,
  25251. 0x900b9,
  25252. 0x8000c,
  25253. 0x8008c,
  25254. 0x8004c,
  25255. 0x900f9,
  25256. 0x70101,
  25257. 0x80052,
  25258. 0x80012,
  25259. 0x8011a,
  25260. 0x70111,
  25261. 0x80072,
  25262. 0x80032,
  25263. 0x900c5,
  25264. 0x70109,
  25265. 0x80062,
  25266. 0x80022,
  25267. 0x900a5,
  25268. 0x80002,
  25269. 0x80082,
  25270. 0x80042,
  25271. 0x900e5,
  25272. 0x70105,
  25273. 0x8005a,
  25274. 0x8001a,
  25275. 0x90095,
  25276. 0x70115,
  25277. 0x8007a,
  25278. 0x8003a,
  25279. 0x900d5,
  25280. 0x7010d,
  25281. 0x8006a,
  25282. 0x8002a,
  25283. 0x900b5,
  25284. 0x8000a,
  25285. 0x8008a,
  25286. 0x8004a,
  25287. 0x900f5,
  25288. 0x70103,
  25289. 0x80056,
  25290. 0x80016,
  25291. 0x8011e,
  25292. 0x70113,
  25293. 0x80076,
  25294. 0x80036,
  25295. 0x900cd,
  25296. 0x7010b,
  25297. 0x80066,
  25298. 0x80026,
  25299. 0x900ad,
  25300. 0x80006,
  25301. 0x80086,
  25302. 0x80046,
  25303. 0x900ed,
  25304. 0x70107,
  25305. 0x8005e,
  25306. 0x8001e,
  25307. 0x9009d,
  25308. 0x70117,
  25309. 0x8007e,
  25310. 0x8003e,
  25311. 0x900dd,
  25312. 0x7010f,
  25313. 0x8006e,
  25314. 0x8002e,
  25315. 0x900bd,
  25316. 0x8000e,
  25317. 0x8008e,
  25318. 0x8004e,
  25319. 0x900fd,
  25320. 0x70100,
  25321. 0x80051,
  25322. 0x80011,
  25323. 0x80119,
  25324. 0x70110,
  25325. 0x80071,
  25326. 0x80031,
  25327. 0x900c3,
  25328. 0x70108,
  25329. 0x80061,
  25330. 0x80021,
  25331. 0x900a3,
  25332. 0x80001,
  25333. 0x80081,
  25334. 0x80041,
  25335. 0x900e3,
  25336. 0x70104,
  25337. 0x80059,
  25338. 0x80019,
  25339. 0x90093,
  25340. 0x70114,
  25341. 0x80079,
  25342. 0x80039,
  25343. 0x900d3,
  25344. 0x7010c,
  25345. 0x80069,
  25346. 0x80029,
  25347. 0x900b3,
  25348. 0x80009,
  25349. 0x80089,
  25350. 0x80049,
  25351. 0x900f3,
  25352. 0x70102,
  25353. 0x80055,
  25354. 0x80015,
  25355. 0x8011d,
  25356. 0x70112,
  25357. 0x80075,
  25358. 0x80035,
  25359. 0x900cb,
  25360. 0x7010a,
  25361. 0x80065,
  25362. 0x80025,
  25363. 0x900ab,
  25364. 0x80005,
  25365. 0x80085,
  25366. 0x80045,
  25367. 0x900eb,
  25368. 0x70106,
  25369. 0x8005d,
  25370. 0x8001d,
  25371. 0x9009b,
  25372. 0x70116,
  25373. 0x8007d,
  25374. 0x8003d,
  25375. 0x900db,
  25376. 0x7010e,
  25377. 0x8006d,
  25378. 0x8002d,
  25379. 0x900bb,
  25380. 0x8000d,
  25381. 0x8008d,
  25382. 0x8004d,
  25383. 0x900fb,
  25384. 0x70101,
  25385. 0x80053,
  25386. 0x80013,
  25387. 0x8011b,
  25388. 0x70111,
  25389. 0x80073,
  25390. 0x80033,
  25391. 0x900c7,
  25392. 0x70109,
  25393. 0x80063,
  25394. 0x80023,
  25395. 0x900a7,
  25396. 0x80003,
  25397. 0x80083,
  25398. 0x80043,
  25399. 0x900e7,
  25400. 0x70105,
  25401. 0x8005b,
  25402. 0x8001b,
  25403. 0x90097,
  25404. 0x70115,
  25405. 0x8007b,
  25406. 0x8003b,
  25407. 0x900d7,
  25408. 0x7010d,
  25409. 0x8006b,
  25410. 0x8002b,
  25411. 0x900b7,
  25412. 0x8000b,
  25413. 0x8008b,
  25414. 0x8004b,
  25415. 0x900f7,
  25416. 0x70103,
  25417. 0x80057,
  25418. 0x80017,
  25419. 0x8011f,
  25420. 0x70113,
  25421. 0x80077,
  25422. 0x80037,
  25423. 0x900cf,
  25424. 0x7010b,
  25425. 0x80067,
  25426. 0x80027,
  25427. 0x900af,
  25428. 0x80007,
  25429. 0x80087,
  25430. 0x80047,
  25431. 0x900ef,
  25432. 0x70107,
  25433. 0x8005f,
  25434. 0x8001f,
  25435. 0x9009f,
  25436. 0x70117,
  25437. 0x8007f,
  25438. 0x8003f,
  25439. 0x900df,
  25440. 0x7010f,
  25441. 0x8006f,
  25442. 0x8002f,
  25443. 0x900bf,
  25444. 0x8000f,
  25445. 0x8008f,
  25446. 0x8004f,
  25447. 0x900ff
  25448. ]),
  25449. 9
  25450. ];
  25451. var fixedDistCodeTab = [
  25452. new Int32Array([
  25453. 0x50000,
  25454. 0x50010,
  25455. 0x50008,
  25456. 0x50018,
  25457. 0x50004,
  25458. 0x50014,
  25459. 0x5000c,
  25460. 0x5001c,
  25461. 0x50002,
  25462. 0x50012,
  25463. 0x5000a,
  25464. 0x5001a,
  25465. 0x50006,
  25466. 0x50016,
  25467. 0x5000e,
  25468. 0x00000,
  25469. 0x50001,
  25470. 0x50011,
  25471. 0x50009,
  25472. 0x50019,
  25473. 0x50005,
  25474. 0x50015,
  25475. 0x5000d,
  25476. 0x5001d,
  25477. 0x50003,
  25478. 0x50013,
  25479. 0x5000b,
  25480. 0x5001b,
  25481. 0x50007,
  25482. 0x50017,
  25483. 0x5000f,
  25484. 0x00000
  25485. ]),
  25486. 5
  25487. ];
  25488. function FlateStream(str, maybeLength) {
  25489. this.str = str;
  25490. this.dict = str.dict;
  25491. var cmf = str.getByte();
  25492. var flg = str.getByte();
  25493. if (cmf === -1 || flg === -1) {
  25494. error('Invalid header in flate stream: ' + cmf + ', ' + flg);
  25495. }
  25496. if ((cmf & 0x0f) !== 0x08) {
  25497. error('Unknown compression method in flate stream: ' + cmf + ', ' + flg);
  25498. }
  25499. if (((cmf << 8) + flg) % 31 !== 0) {
  25500. error('Bad FCHECK in flate stream: ' + cmf + ', ' + flg);
  25501. }
  25502. if (flg & 0x20) {
  25503. error('FDICT bit set in flate stream: ' + cmf + ', ' + flg);
  25504. }
  25505. this.codeSize = 0;
  25506. this.codeBuf = 0;
  25507. DecodeStream.call(this, maybeLength);
  25508. }
  25509. FlateStream.prototype = Object.create(DecodeStream.prototype);
  25510. FlateStream.prototype.getBits = function FlateStream_getBits(bits) {
  25511. var str = this.str;
  25512. var codeSize = this.codeSize;
  25513. var codeBuf = this.codeBuf;
  25514. var b;
  25515. while (codeSize < bits) {
  25516. if ((b = str.getByte()) === -1) {
  25517. error('Bad encoding in flate stream');
  25518. }
  25519. codeBuf |= b << codeSize;
  25520. codeSize += 8;
  25521. }
  25522. b = codeBuf & (1 << bits) - 1;
  25523. this.codeBuf = codeBuf >> bits;
  25524. this.codeSize = codeSize -= bits;
  25525. return b;
  25526. };
  25527. FlateStream.prototype.getCode = function FlateStream_getCode(table) {
  25528. var str = this.str;
  25529. var codes = table[0];
  25530. var maxLen = table[1];
  25531. var codeSize = this.codeSize;
  25532. var codeBuf = this.codeBuf;
  25533. var b;
  25534. while (codeSize < maxLen) {
  25535. if ((b = str.getByte()) === -1) {
  25536. break;
  25537. }
  25538. codeBuf |= b << codeSize;
  25539. codeSize += 8;
  25540. }
  25541. var code = codes[codeBuf & (1 << maxLen) - 1];
  25542. var codeLen = code >> 16;
  25543. var codeVal = code & 0xffff;
  25544. if (codeLen < 1 || codeSize < codeLen) {
  25545. error('Bad encoding in flate stream');
  25546. }
  25547. this.codeBuf = codeBuf >> codeLen;
  25548. this.codeSize = codeSize - codeLen;
  25549. return codeVal;
  25550. };
  25551. FlateStream.prototype.generateHuffmanTable = function flateStreamGenerateHuffmanTable(lengths) {
  25552. var n = lengths.length;
  25553. var maxLen = 0;
  25554. var i;
  25555. for (i = 0; i < n; ++i) {
  25556. if (lengths[i] > maxLen) {
  25557. maxLen = lengths[i];
  25558. }
  25559. }
  25560. var size = 1 << maxLen;
  25561. var codes = new Int32Array(size);
  25562. for (var len = 1, code = 0, skip = 2; len <= maxLen; ++len, code <<= 1, skip <<= 1) {
  25563. for (var val = 0; val < n; ++val) {
  25564. if (lengths[val] === len) {
  25565. var code2 = 0;
  25566. var t = code;
  25567. for (i = 0; i < len; ++i) {
  25568. code2 = code2 << 1 | t & 1;
  25569. t >>= 1;
  25570. }
  25571. for (i = code2; i < size; i += skip) {
  25572. codes[i] = len << 16 | val;
  25573. }
  25574. ++code;
  25575. }
  25576. }
  25577. }
  25578. return [
  25579. codes,
  25580. maxLen
  25581. ];
  25582. };
  25583. FlateStream.prototype.readBlock = function FlateStream_readBlock() {
  25584. var buffer, len;
  25585. var str = this.str;
  25586. var hdr = this.getBits(3);
  25587. if (hdr & 1) {
  25588. this.eof = true;
  25589. }
  25590. hdr >>= 1;
  25591. if (hdr === 0) {
  25592. var b;
  25593. if ((b = str.getByte()) === -1) {
  25594. error('Bad block header in flate stream');
  25595. }
  25596. var blockLen = b;
  25597. if ((b = str.getByte()) === -1) {
  25598. error('Bad block header in flate stream');
  25599. }
  25600. blockLen |= b << 8;
  25601. if ((b = str.getByte()) === -1) {
  25602. error('Bad block header in flate stream');
  25603. }
  25604. var check = b;
  25605. if ((b = str.getByte()) === -1) {
  25606. error('Bad block header in flate stream');
  25607. }
  25608. check |= b << 8;
  25609. if (check !== (~blockLen & 0xffff) && (blockLen !== 0 || check !== 0)) {
  25610. error('Bad uncompressed block length in flate stream');
  25611. }
  25612. this.codeBuf = 0;
  25613. this.codeSize = 0;
  25614. var bufferLength = this.bufferLength;
  25615. buffer = this.ensureBuffer(bufferLength + blockLen);
  25616. var end = bufferLength + blockLen;
  25617. this.bufferLength = end;
  25618. if (blockLen === 0) {
  25619. if (str.peekByte() === -1) {
  25620. this.eof = true;
  25621. }
  25622. } else {
  25623. for (var n = bufferLength; n < end; ++n) {
  25624. if ((b = str.getByte()) === -1) {
  25625. this.eof = true;
  25626. break;
  25627. }
  25628. buffer[n] = b;
  25629. }
  25630. }
  25631. return;
  25632. }
  25633. var litCodeTable;
  25634. var distCodeTable;
  25635. if (hdr === 1) {
  25636. litCodeTable = fixedLitCodeTab;
  25637. distCodeTable = fixedDistCodeTab;
  25638. } else if (hdr === 2) {
  25639. var numLitCodes = this.getBits(5) + 257;
  25640. var numDistCodes = this.getBits(5) + 1;
  25641. var numCodeLenCodes = this.getBits(4) + 4;
  25642. var codeLenCodeLengths = new Uint8Array(codeLenCodeMap.length);
  25643. var i;
  25644. for (i = 0; i < numCodeLenCodes; ++i) {
  25645. codeLenCodeLengths[codeLenCodeMap[i]] = this.getBits(3);
  25646. }
  25647. var codeLenCodeTab = this.generateHuffmanTable(codeLenCodeLengths);
  25648. len = 0;
  25649. i = 0;
  25650. var codes = numLitCodes + numDistCodes;
  25651. var codeLengths = new Uint8Array(codes);
  25652. var bitsLength, bitsOffset, what;
  25653. while (i < codes) {
  25654. var code = this.getCode(codeLenCodeTab);
  25655. if (code === 16) {
  25656. bitsLength = 2;
  25657. bitsOffset = 3;
  25658. what = len;
  25659. } else if (code === 17) {
  25660. bitsLength = 3;
  25661. bitsOffset = 3;
  25662. what = len = 0;
  25663. } else if (code === 18) {
  25664. bitsLength = 7;
  25665. bitsOffset = 11;
  25666. what = len = 0;
  25667. } else {
  25668. codeLengths[i++] = len = code;
  25669. continue;
  25670. }
  25671. var repeatLength = this.getBits(bitsLength) + bitsOffset;
  25672. while (repeatLength-- > 0) {
  25673. codeLengths[i++] = what;
  25674. }
  25675. }
  25676. litCodeTable = this.generateHuffmanTable(codeLengths.subarray(0, numLitCodes));
  25677. distCodeTable = this.generateHuffmanTable(codeLengths.subarray(numLitCodes, codes));
  25678. } else {
  25679. error('Unknown block type in flate stream');
  25680. }
  25681. buffer = this.buffer;
  25682. var limit = buffer ? buffer.length : 0;
  25683. var pos = this.bufferLength;
  25684. while (true) {
  25685. var code1 = this.getCode(litCodeTable);
  25686. if (code1 < 256) {
  25687. if (pos + 1 >= limit) {
  25688. buffer = this.ensureBuffer(pos + 1);
  25689. limit = buffer.length;
  25690. }
  25691. buffer[pos++] = code1;
  25692. continue;
  25693. }
  25694. if (code1 === 256) {
  25695. this.bufferLength = pos;
  25696. return;
  25697. }
  25698. code1 -= 257;
  25699. code1 = lengthDecode[code1];
  25700. var code2 = code1 >> 16;
  25701. if (code2 > 0) {
  25702. code2 = this.getBits(code2);
  25703. }
  25704. len = (code1 & 0xffff) + code2;
  25705. code1 = this.getCode(distCodeTable);
  25706. code1 = distDecode[code1];
  25707. code2 = code1 >> 16;
  25708. if (code2 > 0) {
  25709. code2 = this.getBits(code2);
  25710. }
  25711. var dist = (code1 & 0xffff) + code2;
  25712. if (pos + len >= limit) {
  25713. buffer = this.ensureBuffer(pos + len);
  25714. limit = buffer.length;
  25715. }
  25716. for (var k = 0; k < len; ++k, ++pos) {
  25717. buffer[pos] = buffer[pos - dist];
  25718. }
  25719. }
  25720. };
  25721. return FlateStream;
  25722. }();
  25723. var PredictorStream = function PredictorStreamClosure() {
  25724. function PredictorStream(str, maybeLength, params) {
  25725. if (!isDict(params)) {
  25726. return str;
  25727. }
  25728. var predictor = this.predictor = params.get('Predictor') || 1;
  25729. if (predictor <= 1) {
  25730. return str;
  25731. }
  25732. if (predictor !== 2 && (predictor < 10 || predictor > 15)) {
  25733. error('Unsupported predictor: ' + predictor);
  25734. }
  25735. if (predictor === 2) {
  25736. this.readBlock = this.readBlockTiff;
  25737. } else {
  25738. this.readBlock = this.readBlockPng;
  25739. }
  25740. this.str = str;
  25741. this.dict = str.dict;
  25742. var colors = this.colors = params.get('Colors') || 1;
  25743. var bits = this.bits = params.get('BitsPerComponent') || 8;
  25744. var columns = this.columns = params.get('Columns') || 1;
  25745. this.pixBytes = colors * bits + 7 >> 3;
  25746. this.rowBytes = columns * colors * bits + 7 >> 3;
  25747. DecodeStream.call(this, maybeLength);
  25748. return this;
  25749. }
  25750. PredictorStream.prototype = Object.create(DecodeStream.prototype);
  25751. PredictorStream.prototype.readBlockTiff = function predictorStreamReadBlockTiff() {
  25752. var rowBytes = this.rowBytes;
  25753. var bufferLength = this.bufferLength;
  25754. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25755. var bits = this.bits;
  25756. var colors = this.colors;
  25757. var rawBytes = this.str.getBytes(rowBytes);
  25758. this.eof = !rawBytes.length;
  25759. if (this.eof) {
  25760. return;
  25761. }
  25762. var inbuf = 0, outbuf = 0;
  25763. var inbits = 0, outbits = 0;
  25764. var pos = bufferLength;
  25765. var i;
  25766. if (bits === 1) {
  25767. for (i = 0; i < rowBytes; ++i) {
  25768. var c = rawBytes[i];
  25769. inbuf = inbuf << 8 | c;
  25770. buffer[pos++] = (c ^ inbuf >> colors) & 0xFF;
  25771. inbuf &= 0xFFFF;
  25772. }
  25773. } else if (bits === 8) {
  25774. for (i = 0; i < colors; ++i) {
  25775. buffer[pos++] = rawBytes[i];
  25776. }
  25777. for (; i < rowBytes; ++i) {
  25778. buffer[pos] = buffer[pos - colors] + rawBytes[i];
  25779. pos++;
  25780. }
  25781. } else {
  25782. var compArray = new Uint8Array(colors + 1);
  25783. var bitMask = (1 << bits) - 1;
  25784. var j = 0, k = bufferLength;
  25785. var columns = this.columns;
  25786. for (i = 0; i < columns; ++i) {
  25787. for (var kk = 0; kk < colors; ++kk) {
  25788. if (inbits < bits) {
  25789. inbuf = inbuf << 8 | rawBytes[j++] & 0xFF;
  25790. inbits += 8;
  25791. }
  25792. compArray[kk] = compArray[kk] + (inbuf >> inbits - bits) & bitMask;
  25793. inbits -= bits;
  25794. outbuf = outbuf << bits | compArray[kk];
  25795. outbits += bits;
  25796. if (outbits >= 8) {
  25797. buffer[k++] = outbuf >> outbits - 8 & 0xFF;
  25798. outbits -= 8;
  25799. }
  25800. }
  25801. }
  25802. if (outbits > 0) {
  25803. buffer[k++] = (outbuf << 8 - outbits) + (inbuf & (1 << 8 - outbits) - 1);
  25804. }
  25805. }
  25806. this.bufferLength += rowBytes;
  25807. };
  25808. PredictorStream.prototype.readBlockPng = function predictorStreamReadBlockPng() {
  25809. var rowBytes = this.rowBytes;
  25810. var pixBytes = this.pixBytes;
  25811. var predictor = this.str.getByte();
  25812. var rawBytes = this.str.getBytes(rowBytes);
  25813. this.eof = !rawBytes.length;
  25814. if (this.eof) {
  25815. return;
  25816. }
  25817. var bufferLength = this.bufferLength;
  25818. var buffer = this.ensureBuffer(bufferLength + rowBytes);
  25819. var prevRow = buffer.subarray(bufferLength - rowBytes, bufferLength);
  25820. if (prevRow.length === 0) {
  25821. prevRow = new Uint8Array(rowBytes);
  25822. }
  25823. var i, j = bufferLength, up, c;
  25824. switch (predictor) {
  25825. case 0:
  25826. for (i = 0; i < rowBytes; ++i) {
  25827. buffer[j++] = rawBytes[i];
  25828. }
  25829. break;
  25830. case 1:
  25831. for (i = 0; i < pixBytes; ++i) {
  25832. buffer[j++] = rawBytes[i];
  25833. }
  25834. for (; i < rowBytes; ++i) {
  25835. buffer[j] = buffer[j - pixBytes] + rawBytes[i] & 0xFF;
  25836. j++;
  25837. }
  25838. break;
  25839. case 2:
  25840. for (i = 0; i < rowBytes; ++i) {
  25841. buffer[j++] = prevRow[i] + rawBytes[i] & 0xFF;
  25842. }
  25843. break;
  25844. case 3:
  25845. for (i = 0; i < pixBytes; ++i) {
  25846. buffer[j++] = (prevRow[i] >> 1) + rawBytes[i];
  25847. }
  25848. for (; i < rowBytes; ++i) {
  25849. buffer[j] = (prevRow[i] + buffer[j - pixBytes] >> 1) + rawBytes[i] & 0xFF;
  25850. j++;
  25851. }
  25852. break;
  25853. case 4:
  25854. for (i = 0; i < pixBytes; ++i) {
  25855. up = prevRow[i];
  25856. c = rawBytes[i];
  25857. buffer[j++] = up + c;
  25858. }
  25859. for (; i < rowBytes; ++i) {
  25860. up = prevRow[i];
  25861. var upLeft = prevRow[i - pixBytes];
  25862. var left = buffer[j - pixBytes];
  25863. var p = left + up - upLeft;
  25864. var pa = p - left;
  25865. if (pa < 0) {
  25866. pa = -pa;
  25867. }
  25868. var pb = p - up;
  25869. if (pb < 0) {
  25870. pb = -pb;
  25871. }
  25872. var pc = p - upLeft;
  25873. if (pc < 0) {
  25874. pc = -pc;
  25875. }
  25876. c = rawBytes[i];
  25877. if (pa <= pb && pa <= pc) {
  25878. buffer[j++] = left + c;
  25879. } else if (pb <= pc) {
  25880. buffer[j++] = up + c;
  25881. } else {
  25882. buffer[j++] = upLeft + c;
  25883. }
  25884. }
  25885. break;
  25886. default:
  25887. error('Unsupported predictor: ' + predictor);
  25888. }
  25889. this.bufferLength += rowBytes;
  25890. };
  25891. return PredictorStream;
  25892. }();
  25893. var JpegStream = function JpegStreamClosure() {
  25894. function JpegStream(stream, maybeLength, dict, params) {
  25895. var ch;
  25896. while ((ch = stream.getByte()) !== -1) {
  25897. if (ch === 0xFF) {
  25898. stream.skip(-1);
  25899. break;
  25900. }
  25901. }
  25902. this.stream = stream;
  25903. this.maybeLength = maybeLength;
  25904. this.dict = dict;
  25905. this.params = params;
  25906. DecodeStream.call(this, maybeLength);
  25907. }
  25908. JpegStream.prototype = Object.create(DecodeStream.prototype);
  25909. Object.defineProperty(JpegStream.prototype, 'bytes', {
  25910. get: function JpegStream_bytes() {
  25911. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  25912. },
  25913. configurable: true
  25914. });
  25915. JpegStream.prototype.ensureBuffer = function JpegStream_ensureBuffer(req) {
  25916. if (this.bufferLength) {
  25917. return;
  25918. }
  25919. var jpegImage = new JpegImage();
  25920. var decodeArr = this.dict.getArray('Decode', 'D');
  25921. if (this.forceRGB && isArray(decodeArr)) {
  25922. var bitsPerComponent = this.dict.get('BitsPerComponent') || 8;
  25923. var decodeArrLength = decodeArr.length;
  25924. var transform = new Int32Array(decodeArrLength);
  25925. var transformNeeded = false;
  25926. var maxValue = (1 << bitsPerComponent) - 1;
  25927. for (var i = 0; i < decodeArrLength; i += 2) {
  25928. transform[i] = (decodeArr[i + 1] - decodeArr[i]) * 256 | 0;
  25929. transform[i + 1] = decodeArr[i] * maxValue | 0;
  25930. if (transform[i] !== 256 || transform[i + 1] !== 0) {
  25931. transformNeeded = true;
  25932. }
  25933. }
  25934. if (transformNeeded) {
  25935. jpegImage.decodeTransform = transform;
  25936. }
  25937. }
  25938. if (isDict(this.params)) {
  25939. var colorTransform = this.params.get('ColorTransform');
  25940. if (isInt(colorTransform)) {
  25941. jpegImage.colorTransform = colorTransform;
  25942. }
  25943. }
  25944. jpegImage.parse(this.bytes);
  25945. var data = jpegImage.getData(this.drawWidth, this.drawHeight, this.forceRGB);
  25946. this.buffer = data;
  25947. this.bufferLength = data.length;
  25948. this.eof = true;
  25949. };
  25950. JpegStream.prototype.getBytes = function JpegStream_getBytes(length) {
  25951. this.ensureBuffer();
  25952. return this.buffer;
  25953. };
  25954. JpegStream.prototype.getIR = function JpegStream_getIR(forceDataSchema) {
  25955. return createObjectURL(this.bytes, 'image/jpeg', forceDataSchema);
  25956. };
  25957. return JpegStream;
  25958. }();
  25959. var JpxStream = function JpxStreamClosure() {
  25960. function JpxStream(stream, maybeLength, dict, params) {
  25961. this.stream = stream;
  25962. this.maybeLength = maybeLength;
  25963. this.dict = dict;
  25964. this.params = params;
  25965. DecodeStream.call(this, maybeLength);
  25966. }
  25967. JpxStream.prototype = Object.create(DecodeStream.prototype);
  25968. Object.defineProperty(JpxStream.prototype, 'bytes', {
  25969. get: function JpxStream_bytes() {
  25970. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  25971. },
  25972. configurable: true
  25973. });
  25974. JpxStream.prototype.ensureBuffer = function JpxStream_ensureBuffer(req) {
  25975. if (this.bufferLength) {
  25976. return;
  25977. }
  25978. var jpxImage = new JpxImage();
  25979. jpxImage.parse(this.bytes);
  25980. var width = jpxImage.width;
  25981. var height = jpxImage.height;
  25982. var componentsCount = jpxImage.componentsCount;
  25983. var tileCount = jpxImage.tiles.length;
  25984. if (tileCount === 1) {
  25985. this.buffer = jpxImage.tiles[0].items;
  25986. } else {
  25987. var data = new Uint8Array(width * height * componentsCount);
  25988. for (var k = 0; k < tileCount; k++) {
  25989. var tileComponents = jpxImage.tiles[k];
  25990. var tileWidth = tileComponents.width;
  25991. var tileHeight = tileComponents.height;
  25992. var tileLeft = tileComponents.left;
  25993. var tileTop = tileComponents.top;
  25994. var src = tileComponents.items;
  25995. var srcPosition = 0;
  25996. var dataPosition = (width * tileTop + tileLeft) * componentsCount;
  25997. var imgRowSize = width * componentsCount;
  25998. var tileRowSize = tileWidth * componentsCount;
  25999. for (var j = 0; j < tileHeight; j++) {
  26000. var rowBytes = src.subarray(srcPosition, srcPosition + tileRowSize);
  26001. data.set(rowBytes, dataPosition);
  26002. srcPosition += tileRowSize;
  26003. dataPosition += imgRowSize;
  26004. }
  26005. }
  26006. this.buffer = data;
  26007. }
  26008. this.bufferLength = this.buffer.length;
  26009. this.eof = true;
  26010. };
  26011. return JpxStream;
  26012. }();
  26013. var Jbig2Stream = function Jbig2StreamClosure() {
  26014. function Jbig2Stream(stream, maybeLength, dict, params) {
  26015. this.stream = stream;
  26016. this.maybeLength = maybeLength;
  26017. this.dict = dict;
  26018. this.params = params;
  26019. DecodeStream.call(this, maybeLength);
  26020. }
  26021. Jbig2Stream.prototype = Object.create(DecodeStream.prototype);
  26022. Object.defineProperty(Jbig2Stream.prototype, 'bytes', {
  26023. get: function Jbig2Stream_bytes() {
  26024. return shadow(this, 'bytes', this.stream.getBytes(this.maybeLength));
  26025. },
  26026. configurable: true
  26027. });
  26028. Jbig2Stream.prototype.ensureBuffer = function Jbig2Stream_ensureBuffer(req) {
  26029. if (this.bufferLength) {
  26030. return;
  26031. }
  26032. var jbig2Image = new Jbig2Image();
  26033. var chunks = [];
  26034. if (isDict(this.params)) {
  26035. var globalsStream = this.params.get('JBIG2Globals');
  26036. if (isStream(globalsStream)) {
  26037. var globals = globalsStream.getBytes();
  26038. chunks.push({
  26039. data: globals,
  26040. start: 0,
  26041. end: globals.length
  26042. });
  26043. }
  26044. }
  26045. chunks.push({
  26046. data: this.bytes,
  26047. start: 0,
  26048. end: this.bytes.length
  26049. });
  26050. var data = jbig2Image.parseChunks(chunks);
  26051. var dataLength = data.length;
  26052. for (var i = 0; i < dataLength; i++) {
  26053. data[i] ^= 0xFF;
  26054. }
  26055. this.buffer = data;
  26056. this.bufferLength = dataLength;
  26057. this.eof = true;
  26058. };
  26059. return Jbig2Stream;
  26060. }();
  26061. var DecryptStream = function DecryptStreamClosure() {
  26062. function DecryptStream(str, maybeLength, decrypt) {
  26063. this.str = str;
  26064. this.dict = str.dict;
  26065. this.decrypt = decrypt;
  26066. this.nextChunk = null;
  26067. this.initialized = false;
  26068. DecodeStream.call(this, maybeLength);
  26069. }
  26070. var chunkSize = 512;
  26071. DecryptStream.prototype = Object.create(DecodeStream.prototype);
  26072. DecryptStream.prototype.readBlock = function DecryptStream_readBlock() {
  26073. var chunk;
  26074. if (this.initialized) {
  26075. chunk = this.nextChunk;
  26076. } else {
  26077. chunk = this.str.getBytes(chunkSize);
  26078. this.initialized = true;
  26079. }
  26080. if (!chunk || chunk.length === 0) {
  26081. this.eof = true;
  26082. return;
  26083. }
  26084. this.nextChunk = this.str.getBytes(chunkSize);
  26085. var hasMoreData = this.nextChunk && this.nextChunk.length > 0;
  26086. var decrypt = this.decrypt;
  26087. chunk = decrypt(chunk, !hasMoreData);
  26088. var bufferLength = this.bufferLength;
  26089. var i, n = chunk.length;
  26090. var buffer = this.ensureBuffer(bufferLength + n);
  26091. for (i = 0; i < n; i++) {
  26092. buffer[bufferLength++] = chunk[i];
  26093. }
  26094. this.bufferLength = bufferLength;
  26095. };
  26096. return DecryptStream;
  26097. }();
  26098. var Ascii85Stream = function Ascii85StreamClosure() {
  26099. function Ascii85Stream(str, maybeLength) {
  26100. this.str = str;
  26101. this.dict = str.dict;
  26102. this.input = new Uint8Array(5);
  26103. if (maybeLength) {
  26104. maybeLength = 0.8 * maybeLength;
  26105. }
  26106. DecodeStream.call(this, maybeLength);
  26107. }
  26108. Ascii85Stream.prototype = Object.create(DecodeStream.prototype);
  26109. Ascii85Stream.prototype.readBlock = function Ascii85Stream_readBlock() {
  26110. var TILDA_CHAR = 0x7E;
  26111. var Z_LOWER_CHAR = 0x7A;
  26112. var EOF = -1;
  26113. var str = this.str;
  26114. var c = str.getByte();
  26115. while (isSpace(c)) {
  26116. c = str.getByte();
  26117. }
  26118. if (c === EOF || c === TILDA_CHAR) {
  26119. this.eof = true;
  26120. return;
  26121. }
  26122. var bufferLength = this.bufferLength, buffer;
  26123. var i;
  26124. if (c === Z_LOWER_CHAR) {
  26125. buffer = this.ensureBuffer(bufferLength + 4);
  26126. for (i = 0; i < 4; ++i) {
  26127. buffer[bufferLength + i] = 0;
  26128. }
  26129. this.bufferLength += 4;
  26130. } else {
  26131. var input = this.input;
  26132. input[0] = c;
  26133. for (i = 1; i < 5; ++i) {
  26134. c = str.getByte();
  26135. while (isSpace(c)) {
  26136. c = str.getByte();
  26137. }
  26138. input[i] = c;
  26139. if (c === EOF || c === TILDA_CHAR) {
  26140. break;
  26141. }
  26142. }
  26143. buffer = this.ensureBuffer(bufferLength + i - 1);
  26144. this.bufferLength += i - 1;
  26145. if (i < 5) {
  26146. for (; i < 5; ++i) {
  26147. input[i] = 0x21 + 84;
  26148. }
  26149. this.eof = true;
  26150. }
  26151. var t = 0;
  26152. for (i = 0; i < 5; ++i) {
  26153. t = t * 85 + (input[i] - 0x21);
  26154. }
  26155. for (i = 3; i >= 0; --i) {
  26156. buffer[bufferLength + i] = t & 0xFF;
  26157. t >>= 8;
  26158. }
  26159. }
  26160. };
  26161. return Ascii85Stream;
  26162. }();
  26163. var AsciiHexStream = function AsciiHexStreamClosure() {
  26164. function AsciiHexStream(str, maybeLength) {
  26165. this.str = str;
  26166. this.dict = str.dict;
  26167. this.firstDigit = -1;
  26168. if (maybeLength) {
  26169. maybeLength = 0.5 * maybeLength;
  26170. }
  26171. DecodeStream.call(this, maybeLength);
  26172. }
  26173. AsciiHexStream.prototype = Object.create(DecodeStream.prototype);
  26174. AsciiHexStream.prototype.readBlock = function AsciiHexStream_readBlock() {
  26175. var UPSTREAM_BLOCK_SIZE = 8000;
  26176. var bytes = this.str.getBytes(UPSTREAM_BLOCK_SIZE);
  26177. if (!bytes.length) {
  26178. this.eof = true;
  26179. return;
  26180. }
  26181. var maxDecodeLength = bytes.length + 1 >> 1;
  26182. var buffer = this.ensureBuffer(this.bufferLength + maxDecodeLength);
  26183. var bufferLength = this.bufferLength;
  26184. var firstDigit = this.firstDigit;
  26185. for (var i = 0, ii = bytes.length; i < ii; i++) {
  26186. var ch = bytes[i], digit;
  26187. if (ch >= 0x30 && ch <= 0x39) {
  26188. digit = ch & 0x0F;
  26189. } else if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  26190. digit = (ch & 0x0F) + 9;
  26191. } else if (ch === 0x3E) {
  26192. this.eof = true;
  26193. break;
  26194. } else {
  26195. continue;
  26196. }
  26197. if (firstDigit < 0) {
  26198. firstDigit = digit;
  26199. } else {
  26200. buffer[bufferLength++] = firstDigit << 4 | digit;
  26201. firstDigit = -1;
  26202. }
  26203. }
  26204. if (firstDigit >= 0 && this.eof) {
  26205. buffer[bufferLength++] = firstDigit << 4;
  26206. firstDigit = -1;
  26207. }
  26208. this.firstDigit = firstDigit;
  26209. this.bufferLength = bufferLength;
  26210. };
  26211. return AsciiHexStream;
  26212. }();
  26213. var RunLengthStream = function RunLengthStreamClosure() {
  26214. function RunLengthStream(str, maybeLength) {
  26215. this.str = str;
  26216. this.dict = str.dict;
  26217. DecodeStream.call(this, maybeLength);
  26218. }
  26219. RunLengthStream.prototype = Object.create(DecodeStream.prototype);
  26220. RunLengthStream.prototype.readBlock = function RunLengthStream_readBlock() {
  26221. var repeatHeader = this.str.getBytes(2);
  26222. if (!repeatHeader || repeatHeader.length < 2 || repeatHeader[0] === 128) {
  26223. this.eof = true;
  26224. return;
  26225. }
  26226. var buffer;
  26227. var bufferLength = this.bufferLength;
  26228. var n = repeatHeader[0];
  26229. if (n < 128) {
  26230. buffer = this.ensureBuffer(bufferLength + n + 1);
  26231. buffer[bufferLength++] = repeatHeader[1];
  26232. if (n > 0) {
  26233. var source = this.str.getBytes(n);
  26234. buffer.set(source, bufferLength);
  26235. bufferLength += n;
  26236. }
  26237. } else {
  26238. n = 257 - n;
  26239. var b = repeatHeader[1];
  26240. buffer = this.ensureBuffer(bufferLength + n + 1);
  26241. for (var i = 0; i < n; i++) {
  26242. buffer[bufferLength++] = b;
  26243. }
  26244. }
  26245. this.bufferLength = bufferLength;
  26246. };
  26247. return RunLengthStream;
  26248. }();
  26249. var CCITTFaxStream = function CCITTFaxStreamClosure() {
  26250. var ccittEOL = -2;
  26251. var ccittEOF = -1;
  26252. var twoDimPass = 0;
  26253. var twoDimHoriz = 1;
  26254. var twoDimVert0 = 2;
  26255. var twoDimVertR1 = 3;
  26256. var twoDimVertL1 = 4;
  26257. var twoDimVertR2 = 5;
  26258. var twoDimVertL2 = 6;
  26259. var twoDimVertR3 = 7;
  26260. var twoDimVertL3 = 8;
  26261. var twoDimTable = [
  26262. [
  26263. -1,
  26264. -1
  26265. ],
  26266. [
  26267. -1,
  26268. -1
  26269. ],
  26270. [
  26271. 7,
  26272. twoDimVertL3
  26273. ],
  26274. [
  26275. 7,
  26276. twoDimVertR3
  26277. ],
  26278. [
  26279. 6,
  26280. twoDimVertL2
  26281. ],
  26282. [
  26283. 6,
  26284. twoDimVertL2
  26285. ],
  26286. [
  26287. 6,
  26288. twoDimVertR2
  26289. ],
  26290. [
  26291. 6,
  26292. twoDimVertR2
  26293. ],
  26294. [
  26295. 4,
  26296. twoDimPass
  26297. ],
  26298. [
  26299. 4,
  26300. twoDimPass
  26301. ],
  26302. [
  26303. 4,
  26304. twoDimPass
  26305. ],
  26306. [
  26307. 4,
  26308. twoDimPass
  26309. ],
  26310. [
  26311. 4,
  26312. twoDimPass
  26313. ],
  26314. [
  26315. 4,
  26316. twoDimPass
  26317. ],
  26318. [
  26319. 4,
  26320. twoDimPass
  26321. ],
  26322. [
  26323. 4,
  26324. twoDimPass
  26325. ],
  26326. [
  26327. 3,
  26328. twoDimHoriz
  26329. ],
  26330. [
  26331. 3,
  26332. twoDimHoriz
  26333. ],
  26334. [
  26335. 3,
  26336. twoDimHoriz
  26337. ],
  26338. [
  26339. 3,
  26340. twoDimHoriz
  26341. ],
  26342. [
  26343. 3,
  26344. twoDimHoriz
  26345. ],
  26346. [
  26347. 3,
  26348. twoDimHoriz
  26349. ],
  26350. [
  26351. 3,
  26352. twoDimHoriz
  26353. ],
  26354. [
  26355. 3,
  26356. twoDimHoriz
  26357. ],
  26358. [
  26359. 3,
  26360. twoDimHoriz
  26361. ],
  26362. [
  26363. 3,
  26364. twoDimHoriz
  26365. ],
  26366. [
  26367. 3,
  26368. twoDimHoriz
  26369. ],
  26370. [
  26371. 3,
  26372. twoDimHoriz
  26373. ],
  26374. [
  26375. 3,
  26376. twoDimHoriz
  26377. ],
  26378. [
  26379. 3,
  26380. twoDimHoriz
  26381. ],
  26382. [
  26383. 3,
  26384. twoDimHoriz
  26385. ],
  26386. [
  26387. 3,
  26388. twoDimHoriz
  26389. ],
  26390. [
  26391. 3,
  26392. twoDimVertL1
  26393. ],
  26394. [
  26395. 3,
  26396. twoDimVertL1
  26397. ],
  26398. [
  26399. 3,
  26400. twoDimVertL1
  26401. ],
  26402. [
  26403. 3,
  26404. twoDimVertL1
  26405. ],
  26406. [
  26407. 3,
  26408. twoDimVertL1
  26409. ],
  26410. [
  26411. 3,
  26412. twoDimVertL1
  26413. ],
  26414. [
  26415. 3,
  26416. twoDimVertL1
  26417. ],
  26418. [
  26419. 3,
  26420. twoDimVertL1
  26421. ],
  26422. [
  26423. 3,
  26424. twoDimVertL1
  26425. ],
  26426. [
  26427. 3,
  26428. twoDimVertL1
  26429. ],
  26430. [
  26431. 3,
  26432. twoDimVertL1
  26433. ],
  26434. [
  26435. 3,
  26436. twoDimVertL1
  26437. ],
  26438. [
  26439. 3,
  26440. twoDimVertL1
  26441. ],
  26442. [
  26443. 3,
  26444. twoDimVertL1
  26445. ],
  26446. [
  26447. 3,
  26448. twoDimVertL1
  26449. ],
  26450. [
  26451. 3,
  26452. twoDimVertL1
  26453. ],
  26454. [
  26455. 3,
  26456. twoDimVertR1
  26457. ],
  26458. [
  26459. 3,
  26460. twoDimVertR1
  26461. ],
  26462. [
  26463. 3,
  26464. twoDimVertR1
  26465. ],
  26466. [
  26467. 3,
  26468. twoDimVertR1
  26469. ],
  26470. [
  26471. 3,
  26472. twoDimVertR1
  26473. ],
  26474. [
  26475. 3,
  26476. twoDimVertR1
  26477. ],
  26478. [
  26479. 3,
  26480. twoDimVertR1
  26481. ],
  26482. [
  26483. 3,
  26484. twoDimVertR1
  26485. ],
  26486. [
  26487. 3,
  26488. twoDimVertR1
  26489. ],
  26490. [
  26491. 3,
  26492. twoDimVertR1
  26493. ],
  26494. [
  26495. 3,
  26496. twoDimVertR1
  26497. ],
  26498. [
  26499. 3,
  26500. twoDimVertR1
  26501. ],
  26502. [
  26503. 3,
  26504. twoDimVertR1
  26505. ],
  26506. [
  26507. 3,
  26508. twoDimVertR1
  26509. ],
  26510. [
  26511. 3,
  26512. twoDimVertR1
  26513. ],
  26514. [
  26515. 3,
  26516. twoDimVertR1
  26517. ],
  26518. [
  26519. 1,
  26520. twoDimVert0
  26521. ],
  26522. [
  26523. 1,
  26524. twoDimVert0
  26525. ],
  26526. [
  26527. 1,
  26528. twoDimVert0
  26529. ],
  26530. [
  26531. 1,
  26532. twoDimVert0
  26533. ],
  26534. [
  26535. 1,
  26536. twoDimVert0
  26537. ],
  26538. [
  26539. 1,
  26540. twoDimVert0
  26541. ],
  26542. [
  26543. 1,
  26544. twoDimVert0
  26545. ],
  26546. [
  26547. 1,
  26548. twoDimVert0
  26549. ],
  26550. [
  26551. 1,
  26552. twoDimVert0
  26553. ],
  26554. [
  26555. 1,
  26556. twoDimVert0
  26557. ],
  26558. [
  26559. 1,
  26560. twoDimVert0
  26561. ],
  26562. [
  26563. 1,
  26564. twoDimVert0
  26565. ],
  26566. [
  26567. 1,
  26568. twoDimVert0
  26569. ],
  26570. [
  26571. 1,
  26572. twoDimVert0
  26573. ],
  26574. [
  26575. 1,
  26576. twoDimVert0
  26577. ],
  26578. [
  26579. 1,
  26580. twoDimVert0
  26581. ],
  26582. [
  26583. 1,
  26584. twoDimVert0
  26585. ],
  26586. [
  26587. 1,
  26588. twoDimVert0
  26589. ],
  26590. [
  26591. 1,
  26592. twoDimVert0
  26593. ],
  26594. [
  26595. 1,
  26596. twoDimVert0
  26597. ],
  26598. [
  26599. 1,
  26600. twoDimVert0
  26601. ],
  26602. [
  26603. 1,
  26604. twoDimVert0
  26605. ],
  26606. [
  26607. 1,
  26608. twoDimVert0
  26609. ],
  26610. [
  26611. 1,
  26612. twoDimVert0
  26613. ],
  26614. [
  26615. 1,
  26616. twoDimVert0
  26617. ],
  26618. [
  26619. 1,
  26620. twoDimVert0
  26621. ],
  26622. [
  26623. 1,
  26624. twoDimVert0
  26625. ],
  26626. [
  26627. 1,
  26628. twoDimVert0
  26629. ],
  26630. [
  26631. 1,
  26632. twoDimVert0
  26633. ],
  26634. [
  26635. 1,
  26636. twoDimVert0
  26637. ],
  26638. [
  26639. 1,
  26640. twoDimVert0
  26641. ],
  26642. [
  26643. 1,
  26644. twoDimVert0
  26645. ],
  26646. [
  26647. 1,
  26648. twoDimVert0
  26649. ],
  26650. [
  26651. 1,
  26652. twoDimVert0
  26653. ],
  26654. [
  26655. 1,
  26656. twoDimVert0
  26657. ],
  26658. [
  26659. 1,
  26660. twoDimVert0
  26661. ],
  26662. [
  26663. 1,
  26664. twoDimVert0
  26665. ],
  26666. [
  26667. 1,
  26668. twoDimVert0
  26669. ],
  26670. [
  26671. 1,
  26672. twoDimVert0
  26673. ],
  26674. [
  26675. 1,
  26676. twoDimVert0
  26677. ],
  26678. [
  26679. 1,
  26680. twoDimVert0
  26681. ],
  26682. [
  26683. 1,
  26684. twoDimVert0
  26685. ],
  26686. [
  26687. 1,
  26688. twoDimVert0
  26689. ],
  26690. [
  26691. 1,
  26692. twoDimVert0
  26693. ],
  26694. [
  26695. 1,
  26696. twoDimVert0
  26697. ],
  26698. [
  26699. 1,
  26700. twoDimVert0
  26701. ],
  26702. [
  26703. 1,
  26704. twoDimVert0
  26705. ],
  26706. [
  26707. 1,
  26708. twoDimVert0
  26709. ],
  26710. [
  26711. 1,
  26712. twoDimVert0
  26713. ],
  26714. [
  26715. 1,
  26716. twoDimVert0
  26717. ],
  26718. [
  26719. 1,
  26720. twoDimVert0
  26721. ],
  26722. [
  26723. 1,
  26724. twoDimVert0
  26725. ],
  26726. [
  26727. 1,
  26728. twoDimVert0
  26729. ],
  26730. [
  26731. 1,
  26732. twoDimVert0
  26733. ],
  26734. [
  26735. 1,
  26736. twoDimVert0
  26737. ],
  26738. [
  26739. 1,
  26740. twoDimVert0
  26741. ],
  26742. [
  26743. 1,
  26744. twoDimVert0
  26745. ],
  26746. [
  26747. 1,
  26748. twoDimVert0
  26749. ],
  26750. [
  26751. 1,
  26752. twoDimVert0
  26753. ],
  26754. [
  26755. 1,
  26756. twoDimVert0
  26757. ],
  26758. [
  26759. 1,
  26760. twoDimVert0
  26761. ],
  26762. [
  26763. 1,
  26764. twoDimVert0
  26765. ],
  26766. [
  26767. 1,
  26768. twoDimVert0
  26769. ],
  26770. [
  26771. 1,
  26772. twoDimVert0
  26773. ]
  26774. ];
  26775. var whiteTable1 = [
  26776. [
  26777. -1,
  26778. -1
  26779. ],
  26780. [
  26781. 12,
  26782. ccittEOL
  26783. ],
  26784. [
  26785. -1,
  26786. -1
  26787. ],
  26788. [
  26789. -1,
  26790. -1
  26791. ],
  26792. [
  26793. -1,
  26794. -1
  26795. ],
  26796. [
  26797. -1,
  26798. -1
  26799. ],
  26800. [
  26801. -1,
  26802. -1
  26803. ],
  26804. [
  26805. -1,
  26806. -1
  26807. ],
  26808. [
  26809. -1,
  26810. -1
  26811. ],
  26812. [
  26813. -1,
  26814. -1
  26815. ],
  26816. [
  26817. -1,
  26818. -1
  26819. ],
  26820. [
  26821. -1,
  26822. -1
  26823. ],
  26824. [
  26825. -1,
  26826. -1
  26827. ],
  26828. [
  26829. -1,
  26830. -1
  26831. ],
  26832. [
  26833. -1,
  26834. -1
  26835. ],
  26836. [
  26837. -1,
  26838. -1
  26839. ],
  26840. [
  26841. 11,
  26842. 1792
  26843. ],
  26844. [
  26845. 11,
  26846. 1792
  26847. ],
  26848. [
  26849. 12,
  26850. 1984
  26851. ],
  26852. [
  26853. 12,
  26854. 2048
  26855. ],
  26856. [
  26857. 12,
  26858. 2112
  26859. ],
  26860. [
  26861. 12,
  26862. 2176
  26863. ],
  26864. [
  26865. 12,
  26866. 2240
  26867. ],
  26868. [
  26869. 12,
  26870. 2304
  26871. ],
  26872. [
  26873. 11,
  26874. 1856
  26875. ],
  26876. [
  26877. 11,
  26878. 1856
  26879. ],
  26880. [
  26881. 11,
  26882. 1920
  26883. ],
  26884. [
  26885. 11,
  26886. 1920
  26887. ],
  26888. [
  26889. 12,
  26890. 2368
  26891. ],
  26892. [
  26893. 12,
  26894. 2432
  26895. ],
  26896. [
  26897. 12,
  26898. 2496
  26899. ],
  26900. [
  26901. 12,
  26902. 2560
  26903. ]
  26904. ];
  26905. var whiteTable2 = [
  26906. [
  26907. -1,
  26908. -1
  26909. ],
  26910. [
  26911. -1,
  26912. -1
  26913. ],
  26914. [
  26915. -1,
  26916. -1
  26917. ],
  26918. [
  26919. -1,
  26920. -1
  26921. ],
  26922. [
  26923. 8,
  26924. 29
  26925. ],
  26926. [
  26927. 8,
  26928. 29
  26929. ],
  26930. [
  26931. 8,
  26932. 30
  26933. ],
  26934. [
  26935. 8,
  26936. 30
  26937. ],
  26938. [
  26939. 8,
  26940. 45
  26941. ],
  26942. [
  26943. 8,
  26944. 45
  26945. ],
  26946. [
  26947. 8,
  26948. 46
  26949. ],
  26950. [
  26951. 8,
  26952. 46
  26953. ],
  26954. [
  26955. 7,
  26956. 22
  26957. ],
  26958. [
  26959. 7,
  26960. 22
  26961. ],
  26962. [
  26963. 7,
  26964. 22
  26965. ],
  26966. [
  26967. 7,
  26968. 22
  26969. ],
  26970. [
  26971. 7,
  26972. 23
  26973. ],
  26974. [
  26975. 7,
  26976. 23
  26977. ],
  26978. [
  26979. 7,
  26980. 23
  26981. ],
  26982. [
  26983. 7,
  26984. 23
  26985. ],
  26986. [
  26987. 8,
  26988. 47
  26989. ],
  26990. [
  26991. 8,
  26992. 47
  26993. ],
  26994. [
  26995. 8,
  26996. 48
  26997. ],
  26998. [
  26999. 8,
  27000. 48
  27001. ],
  27002. [
  27003. 6,
  27004. 13
  27005. ],
  27006. [
  27007. 6,
  27008. 13
  27009. ],
  27010. [
  27011. 6,
  27012. 13
  27013. ],
  27014. [
  27015. 6,
  27016. 13
  27017. ],
  27018. [
  27019. 6,
  27020. 13
  27021. ],
  27022. [
  27023. 6,
  27024. 13
  27025. ],
  27026. [
  27027. 6,
  27028. 13
  27029. ],
  27030. [
  27031. 6,
  27032. 13
  27033. ],
  27034. [
  27035. 7,
  27036. 20
  27037. ],
  27038. [
  27039. 7,
  27040. 20
  27041. ],
  27042. [
  27043. 7,
  27044. 20
  27045. ],
  27046. [
  27047. 7,
  27048. 20
  27049. ],
  27050. [
  27051. 8,
  27052. 33
  27053. ],
  27054. [
  27055. 8,
  27056. 33
  27057. ],
  27058. [
  27059. 8,
  27060. 34
  27061. ],
  27062. [
  27063. 8,
  27064. 34
  27065. ],
  27066. [
  27067. 8,
  27068. 35
  27069. ],
  27070. [
  27071. 8,
  27072. 35
  27073. ],
  27074. [
  27075. 8,
  27076. 36
  27077. ],
  27078. [
  27079. 8,
  27080. 36
  27081. ],
  27082. [
  27083. 8,
  27084. 37
  27085. ],
  27086. [
  27087. 8,
  27088. 37
  27089. ],
  27090. [
  27091. 8,
  27092. 38
  27093. ],
  27094. [
  27095. 8,
  27096. 38
  27097. ],
  27098. [
  27099. 7,
  27100. 19
  27101. ],
  27102. [
  27103. 7,
  27104. 19
  27105. ],
  27106. [
  27107. 7,
  27108. 19
  27109. ],
  27110. [
  27111. 7,
  27112. 19
  27113. ],
  27114. [
  27115. 8,
  27116. 31
  27117. ],
  27118. [
  27119. 8,
  27120. 31
  27121. ],
  27122. [
  27123. 8,
  27124. 32
  27125. ],
  27126. [
  27127. 8,
  27128. 32
  27129. ],
  27130. [
  27131. 6,
  27132. 1
  27133. ],
  27134. [
  27135. 6,
  27136. 1
  27137. ],
  27138. [
  27139. 6,
  27140. 1
  27141. ],
  27142. [
  27143. 6,
  27144. 1
  27145. ],
  27146. [
  27147. 6,
  27148. 1
  27149. ],
  27150. [
  27151. 6,
  27152. 1
  27153. ],
  27154. [
  27155. 6,
  27156. 1
  27157. ],
  27158. [
  27159. 6,
  27160. 1
  27161. ],
  27162. [
  27163. 6,
  27164. 12
  27165. ],
  27166. [
  27167. 6,
  27168. 12
  27169. ],
  27170. [
  27171. 6,
  27172. 12
  27173. ],
  27174. [
  27175. 6,
  27176. 12
  27177. ],
  27178. [
  27179. 6,
  27180. 12
  27181. ],
  27182. [
  27183. 6,
  27184. 12
  27185. ],
  27186. [
  27187. 6,
  27188. 12
  27189. ],
  27190. [
  27191. 6,
  27192. 12
  27193. ],
  27194. [
  27195. 8,
  27196. 53
  27197. ],
  27198. [
  27199. 8,
  27200. 53
  27201. ],
  27202. [
  27203. 8,
  27204. 54
  27205. ],
  27206. [
  27207. 8,
  27208. 54
  27209. ],
  27210. [
  27211. 7,
  27212. 26
  27213. ],
  27214. [
  27215. 7,
  27216. 26
  27217. ],
  27218. [
  27219. 7,
  27220. 26
  27221. ],
  27222. [
  27223. 7,
  27224. 26
  27225. ],
  27226. [
  27227. 8,
  27228. 39
  27229. ],
  27230. [
  27231. 8,
  27232. 39
  27233. ],
  27234. [
  27235. 8,
  27236. 40
  27237. ],
  27238. [
  27239. 8,
  27240. 40
  27241. ],
  27242. [
  27243. 8,
  27244. 41
  27245. ],
  27246. [
  27247. 8,
  27248. 41
  27249. ],
  27250. [
  27251. 8,
  27252. 42
  27253. ],
  27254. [
  27255. 8,
  27256. 42
  27257. ],
  27258. [
  27259. 8,
  27260. 43
  27261. ],
  27262. [
  27263. 8,
  27264. 43
  27265. ],
  27266. [
  27267. 8,
  27268. 44
  27269. ],
  27270. [
  27271. 8,
  27272. 44
  27273. ],
  27274. [
  27275. 7,
  27276. 21
  27277. ],
  27278. [
  27279. 7,
  27280. 21
  27281. ],
  27282. [
  27283. 7,
  27284. 21
  27285. ],
  27286. [
  27287. 7,
  27288. 21
  27289. ],
  27290. [
  27291. 7,
  27292. 28
  27293. ],
  27294. [
  27295. 7,
  27296. 28
  27297. ],
  27298. [
  27299. 7,
  27300. 28
  27301. ],
  27302. [
  27303. 7,
  27304. 28
  27305. ],
  27306. [
  27307. 8,
  27308. 61
  27309. ],
  27310. [
  27311. 8,
  27312. 61
  27313. ],
  27314. [
  27315. 8,
  27316. 62
  27317. ],
  27318. [
  27319. 8,
  27320. 62
  27321. ],
  27322. [
  27323. 8,
  27324. 63
  27325. ],
  27326. [
  27327. 8,
  27328. 63
  27329. ],
  27330. [
  27331. 8,
  27332. 0
  27333. ],
  27334. [
  27335. 8,
  27336. 0
  27337. ],
  27338. [
  27339. 8,
  27340. 320
  27341. ],
  27342. [
  27343. 8,
  27344. 320
  27345. ],
  27346. [
  27347. 8,
  27348. 384
  27349. ],
  27350. [
  27351. 8,
  27352. 384
  27353. ],
  27354. [
  27355. 5,
  27356. 10
  27357. ],
  27358. [
  27359. 5,
  27360. 10
  27361. ],
  27362. [
  27363. 5,
  27364. 10
  27365. ],
  27366. [
  27367. 5,
  27368. 10
  27369. ],
  27370. [
  27371. 5,
  27372. 10
  27373. ],
  27374. [
  27375. 5,
  27376. 10
  27377. ],
  27378. [
  27379. 5,
  27380. 10
  27381. ],
  27382. [
  27383. 5,
  27384. 10
  27385. ],
  27386. [
  27387. 5,
  27388. 10
  27389. ],
  27390. [
  27391. 5,
  27392. 10
  27393. ],
  27394. [
  27395. 5,
  27396. 10
  27397. ],
  27398. [
  27399. 5,
  27400. 10
  27401. ],
  27402. [
  27403. 5,
  27404. 10
  27405. ],
  27406. [
  27407. 5,
  27408. 10
  27409. ],
  27410. [
  27411. 5,
  27412. 10
  27413. ],
  27414. [
  27415. 5,
  27416. 10
  27417. ],
  27418. [
  27419. 5,
  27420. 11
  27421. ],
  27422. [
  27423. 5,
  27424. 11
  27425. ],
  27426. [
  27427. 5,
  27428. 11
  27429. ],
  27430. [
  27431. 5,
  27432. 11
  27433. ],
  27434. [
  27435. 5,
  27436. 11
  27437. ],
  27438. [
  27439. 5,
  27440. 11
  27441. ],
  27442. [
  27443. 5,
  27444. 11
  27445. ],
  27446. [
  27447. 5,
  27448. 11
  27449. ],
  27450. [
  27451. 5,
  27452. 11
  27453. ],
  27454. [
  27455. 5,
  27456. 11
  27457. ],
  27458. [
  27459. 5,
  27460. 11
  27461. ],
  27462. [
  27463. 5,
  27464. 11
  27465. ],
  27466. [
  27467. 5,
  27468. 11
  27469. ],
  27470. [
  27471. 5,
  27472. 11
  27473. ],
  27474. [
  27475. 5,
  27476. 11
  27477. ],
  27478. [
  27479. 5,
  27480. 11
  27481. ],
  27482. [
  27483. 7,
  27484. 27
  27485. ],
  27486. [
  27487. 7,
  27488. 27
  27489. ],
  27490. [
  27491. 7,
  27492. 27
  27493. ],
  27494. [
  27495. 7,
  27496. 27
  27497. ],
  27498. [
  27499. 8,
  27500. 59
  27501. ],
  27502. [
  27503. 8,
  27504. 59
  27505. ],
  27506. [
  27507. 8,
  27508. 60
  27509. ],
  27510. [
  27511. 8,
  27512. 60
  27513. ],
  27514. [
  27515. 9,
  27516. 1472
  27517. ],
  27518. [
  27519. 9,
  27520. 1536
  27521. ],
  27522. [
  27523. 9,
  27524. 1600
  27525. ],
  27526. [
  27527. 9,
  27528. 1728
  27529. ],
  27530. [
  27531. 7,
  27532. 18
  27533. ],
  27534. [
  27535. 7,
  27536. 18
  27537. ],
  27538. [
  27539. 7,
  27540. 18
  27541. ],
  27542. [
  27543. 7,
  27544. 18
  27545. ],
  27546. [
  27547. 7,
  27548. 24
  27549. ],
  27550. [
  27551. 7,
  27552. 24
  27553. ],
  27554. [
  27555. 7,
  27556. 24
  27557. ],
  27558. [
  27559. 7,
  27560. 24
  27561. ],
  27562. [
  27563. 8,
  27564. 49
  27565. ],
  27566. [
  27567. 8,
  27568. 49
  27569. ],
  27570. [
  27571. 8,
  27572. 50
  27573. ],
  27574. [
  27575. 8,
  27576. 50
  27577. ],
  27578. [
  27579. 8,
  27580. 51
  27581. ],
  27582. [
  27583. 8,
  27584. 51
  27585. ],
  27586. [
  27587. 8,
  27588. 52
  27589. ],
  27590. [
  27591. 8,
  27592. 52
  27593. ],
  27594. [
  27595. 7,
  27596. 25
  27597. ],
  27598. [
  27599. 7,
  27600. 25
  27601. ],
  27602. [
  27603. 7,
  27604. 25
  27605. ],
  27606. [
  27607. 7,
  27608. 25
  27609. ],
  27610. [
  27611. 8,
  27612. 55
  27613. ],
  27614. [
  27615. 8,
  27616. 55
  27617. ],
  27618. [
  27619. 8,
  27620. 56
  27621. ],
  27622. [
  27623. 8,
  27624. 56
  27625. ],
  27626. [
  27627. 8,
  27628. 57
  27629. ],
  27630. [
  27631. 8,
  27632. 57
  27633. ],
  27634. [
  27635. 8,
  27636. 58
  27637. ],
  27638. [
  27639. 8,
  27640. 58
  27641. ],
  27642. [
  27643. 6,
  27644. 192
  27645. ],
  27646. [
  27647. 6,
  27648. 192
  27649. ],
  27650. [
  27651. 6,
  27652. 192
  27653. ],
  27654. [
  27655. 6,
  27656. 192
  27657. ],
  27658. [
  27659. 6,
  27660. 192
  27661. ],
  27662. [
  27663. 6,
  27664. 192
  27665. ],
  27666. [
  27667. 6,
  27668. 192
  27669. ],
  27670. [
  27671. 6,
  27672. 192
  27673. ],
  27674. [
  27675. 6,
  27676. 1664
  27677. ],
  27678. [
  27679. 6,
  27680. 1664
  27681. ],
  27682. [
  27683. 6,
  27684. 1664
  27685. ],
  27686. [
  27687. 6,
  27688. 1664
  27689. ],
  27690. [
  27691. 6,
  27692. 1664
  27693. ],
  27694. [
  27695. 6,
  27696. 1664
  27697. ],
  27698. [
  27699. 6,
  27700. 1664
  27701. ],
  27702. [
  27703. 6,
  27704. 1664
  27705. ],
  27706. [
  27707. 8,
  27708. 448
  27709. ],
  27710. [
  27711. 8,
  27712. 448
  27713. ],
  27714. [
  27715. 8,
  27716. 512
  27717. ],
  27718. [
  27719. 8,
  27720. 512
  27721. ],
  27722. [
  27723. 9,
  27724. 704
  27725. ],
  27726. [
  27727. 9,
  27728. 768
  27729. ],
  27730. [
  27731. 8,
  27732. 640
  27733. ],
  27734. [
  27735. 8,
  27736. 640
  27737. ],
  27738. [
  27739. 8,
  27740. 576
  27741. ],
  27742. [
  27743. 8,
  27744. 576
  27745. ],
  27746. [
  27747. 9,
  27748. 832
  27749. ],
  27750. [
  27751. 9,
  27752. 896
  27753. ],
  27754. [
  27755. 9,
  27756. 960
  27757. ],
  27758. [
  27759. 9,
  27760. 1024
  27761. ],
  27762. [
  27763. 9,
  27764. 1088
  27765. ],
  27766. [
  27767. 9,
  27768. 1152
  27769. ],
  27770. [
  27771. 9,
  27772. 1216
  27773. ],
  27774. [
  27775. 9,
  27776. 1280
  27777. ],
  27778. [
  27779. 9,
  27780. 1344
  27781. ],
  27782. [
  27783. 9,
  27784. 1408
  27785. ],
  27786. [
  27787. 7,
  27788. 256
  27789. ],
  27790. [
  27791. 7,
  27792. 256
  27793. ],
  27794. [
  27795. 7,
  27796. 256
  27797. ],
  27798. [
  27799. 7,
  27800. 256
  27801. ],
  27802. [
  27803. 4,
  27804. 2
  27805. ],
  27806. [
  27807. 4,
  27808. 2
  27809. ],
  27810. [
  27811. 4,
  27812. 2
  27813. ],
  27814. [
  27815. 4,
  27816. 2
  27817. ],
  27818. [
  27819. 4,
  27820. 2
  27821. ],
  27822. [
  27823. 4,
  27824. 2
  27825. ],
  27826. [
  27827. 4,
  27828. 2
  27829. ],
  27830. [
  27831. 4,
  27832. 2
  27833. ],
  27834. [
  27835. 4,
  27836. 2
  27837. ],
  27838. [
  27839. 4,
  27840. 2
  27841. ],
  27842. [
  27843. 4,
  27844. 2
  27845. ],
  27846. [
  27847. 4,
  27848. 2
  27849. ],
  27850. [
  27851. 4,
  27852. 2
  27853. ],
  27854. [
  27855. 4,
  27856. 2
  27857. ],
  27858. [
  27859. 4,
  27860. 2
  27861. ],
  27862. [
  27863. 4,
  27864. 2
  27865. ],
  27866. [
  27867. 4,
  27868. 2
  27869. ],
  27870. [
  27871. 4,
  27872. 2
  27873. ],
  27874. [
  27875. 4,
  27876. 2
  27877. ],
  27878. [
  27879. 4,
  27880. 2
  27881. ],
  27882. [
  27883. 4,
  27884. 2
  27885. ],
  27886. [
  27887. 4,
  27888. 2
  27889. ],
  27890. [
  27891. 4,
  27892. 2
  27893. ],
  27894. [
  27895. 4,
  27896. 2
  27897. ],
  27898. [
  27899. 4,
  27900. 2
  27901. ],
  27902. [
  27903. 4,
  27904. 2
  27905. ],
  27906. [
  27907. 4,
  27908. 2
  27909. ],
  27910. [
  27911. 4,
  27912. 2
  27913. ],
  27914. [
  27915. 4,
  27916. 2
  27917. ],
  27918. [
  27919. 4,
  27920. 2
  27921. ],
  27922. [
  27923. 4,
  27924. 2
  27925. ],
  27926. [
  27927. 4,
  27928. 2
  27929. ],
  27930. [
  27931. 4,
  27932. 3
  27933. ],
  27934. [
  27935. 4,
  27936. 3
  27937. ],
  27938. [
  27939. 4,
  27940. 3
  27941. ],
  27942. [
  27943. 4,
  27944. 3
  27945. ],
  27946. [
  27947. 4,
  27948. 3
  27949. ],
  27950. [
  27951. 4,
  27952. 3
  27953. ],
  27954. [
  27955. 4,
  27956. 3
  27957. ],
  27958. [
  27959. 4,
  27960. 3
  27961. ],
  27962. [
  27963. 4,
  27964. 3
  27965. ],
  27966. [
  27967. 4,
  27968. 3
  27969. ],
  27970. [
  27971. 4,
  27972. 3
  27973. ],
  27974. [
  27975. 4,
  27976. 3
  27977. ],
  27978. [
  27979. 4,
  27980. 3
  27981. ],
  27982. [
  27983. 4,
  27984. 3
  27985. ],
  27986. [
  27987. 4,
  27988. 3
  27989. ],
  27990. [
  27991. 4,
  27992. 3
  27993. ],
  27994. [
  27995. 4,
  27996. 3
  27997. ],
  27998. [
  27999. 4,
  28000. 3
  28001. ],
  28002. [
  28003. 4,
  28004. 3
  28005. ],
  28006. [
  28007. 4,
  28008. 3
  28009. ],
  28010. [
  28011. 4,
  28012. 3
  28013. ],
  28014. [
  28015. 4,
  28016. 3
  28017. ],
  28018. [
  28019. 4,
  28020. 3
  28021. ],
  28022. [
  28023. 4,
  28024. 3
  28025. ],
  28026. [
  28027. 4,
  28028. 3
  28029. ],
  28030. [
  28031. 4,
  28032. 3
  28033. ],
  28034. [
  28035. 4,
  28036. 3
  28037. ],
  28038. [
  28039. 4,
  28040. 3
  28041. ],
  28042. [
  28043. 4,
  28044. 3
  28045. ],
  28046. [
  28047. 4,
  28048. 3
  28049. ],
  28050. [
  28051. 4,
  28052. 3
  28053. ],
  28054. [
  28055. 4,
  28056. 3
  28057. ],
  28058. [
  28059. 5,
  28060. 128
  28061. ],
  28062. [
  28063. 5,
  28064. 128
  28065. ],
  28066. [
  28067. 5,
  28068. 128
  28069. ],
  28070. [
  28071. 5,
  28072. 128
  28073. ],
  28074. [
  28075. 5,
  28076. 128
  28077. ],
  28078. [
  28079. 5,
  28080. 128
  28081. ],
  28082. [
  28083. 5,
  28084. 128
  28085. ],
  28086. [
  28087. 5,
  28088. 128
  28089. ],
  28090. [
  28091. 5,
  28092. 128
  28093. ],
  28094. [
  28095. 5,
  28096. 128
  28097. ],
  28098. [
  28099. 5,
  28100. 128
  28101. ],
  28102. [
  28103. 5,
  28104. 128
  28105. ],
  28106. [
  28107. 5,
  28108. 128
  28109. ],
  28110. [
  28111. 5,
  28112. 128
  28113. ],
  28114. [
  28115. 5,
  28116. 128
  28117. ],
  28118. [
  28119. 5,
  28120. 128
  28121. ],
  28122. [
  28123. 5,
  28124. 8
  28125. ],
  28126. [
  28127. 5,
  28128. 8
  28129. ],
  28130. [
  28131. 5,
  28132. 8
  28133. ],
  28134. [
  28135. 5,
  28136. 8
  28137. ],
  28138. [
  28139. 5,
  28140. 8
  28141. ],
  28142. [
  28143. 5,
  28144. 8
  28145. ],
  28146. [
  28147. 5,
  28148. 8
  28149. ],
  28150. [
  28151. 5,
  28152. 8
  28153. ],
  28154. [
  28155. 5,
  28156. 8
  28157. ],
  28158. [
  28159. 5,
  28160. 8
  28161. ],
  28162. [
  28163. 5,
  28164. 8
  28165. ],
  28166. [
  28167. 5,
  28168. 8
  28169. ],
  28170. [
  28171. 5,
  28172. 8
  28173. ],
  28174. [
  28175. 5,
  28176. 8
  28177. ],
  28178. [
  28179. 5,
  28180. 8
  28181. ],
  28182. [
  28183. 5,
  28184. 8
  28185. ],
  28186. [
  28187. 5,
  28188. 9
  28189. ],
  28190. [
  28191. 5,
  28192. 9
  28193. ],
  28194. [
  28195. 5,
  28196. 9
  28197. ],
  28198. [
  28199. 5,
  28200. 9
  28201. ],
  28202. [
  28203. 5,
  28204. 9
  28205. ],
  28206. [
  28207. 5,
  28208. 9
  28209. ],
  28210. [
  28211. 5,
  28212. 9
  28213. ],
  28214. [
  28215. 5,
  28216. 9
  28217. ],
  28218. [
  28219. 5,
  28220. 9
  28221. ],
  28222. [
  28223. 5,
  28224. 9
  28225. ],
  28226. [
  28227. 5,
  28228. 9
  28229. ],
  28230. [
  28231. 5,
  28232. 9
  28233. ],
  28234. [
  28235. 5,
  28236. 9
  28237. ],
  28238. [
  28239. 5,
  28240. 9
  28241. ],
  28242. [
  28243. 5,
  28244. 9
  28245. ],
  28246. [
  28247. 5,
  28248. 9
  28249. ],
  28250. [
  28251. 6,
  28252. 16
  28253. ],
  28254. [
  28255. 6,
  28256. 16
  28257. ],
  28258. [
  28259. 6,
  28260. 16
  28261. ],
  28262. [
  28263. 6,
  28264. 16
  28265. ],
  28266. [
  28267. 6,
  28268. 16
  28269. ],
  28270. [
  28271. 6,
  28272. 16
  28273. ],
  28274. [
  28275. 6,
  28276. 16
  28277. ],
  28278. [
  28279. 6,
  28280. 16
  28281. ],
  28282. [
  28283. 6,
  28284. 17
  28285. ],
  28286. [
  28287. 6,
  28288. 17
  28289. ],
  28290. [
  28291. 6,
  28292. 17
  28293. ],
  28294. [
  28295. 6,
  28296. 17
  28297. ],
  28298. [
  28299. 6,
  28300. 17
  28301. ],
  28302. [
  28303. 6,
  28304. 17
  28305. ],
  28306. [
  28307. 6,
  28308. 17
  28309. ],
  28310. [
  28311. 6,
  28312. 17
  28313. ],
  28314. [
  28315. 4,
  28316. 4
  28317. ],
  28318. [
  28319. 4,
  28320. 4
  28321. ],
  28322. [
  28323. 4,
  28324. 4
  28325. ],
  28326. [
  28327. 4,
  28328. 4
  28329. ],
  28330. [
  28331. 4,
  28332. 4
  28333. ],
  28334. [
  28335. 4,
  28336. 4
  28337. ],
  28338. [
  28339. 4,
  28340. 4
  28341. ],
  28342. [
  28343. 4,
  28344. 4
  28345. ],
  28346. [
  28347. 4,
  28348. 4
  28349. ],
  28350. [
  28351. 4,
  28352. 4
  28353. ],
  28354. [
  28355. 4,
  28356. 4
  28357. ],
  28358. [
  28359. 4,
  28360. 4
  28361. ],
  28362. [
  28363. 4,
  28364. 4
  28365. ],
  28366. [
  28367. 4,
  28368. 4
  28369. ],
  28370. [
  28371. 4,
  28372. 4
  28373. ],
  28374. [
  28375. 4,
  28376. 4
  28377. ],
  28378. [
  28379. 4,
  28380. 4
  28381. ],
  28382. [
  28383. 4,
  28384. 4
  28385. ],
  28386. [
  28387. 4,
  28388. 4
  28389. ],
  28390. [
  28391. 4,
  28392. 4
  28393. ],
  28394. [
  28395. 4,
  28396. 4
  28397. ],
  28398. [
  28399. 4,
  28400. 4
  28401. ],
  28402. [
  28403. 4,
  28404. 4
  28405. ],
  28406. [
  28407. 4,
  28408. 4
  28409. ],
  28410. [
  28411. 4,
  28412. 4
  28413. ],
  28414. [
  28415. 4,
  28416. 4
  28417. ],
  28418. [
  28419. 4,
  28420. 4
  28421. ],
  28422. [
  28423. 4,
  28424. 4
  28425. ],
  28426. [
  28427. 4,
  28428. 4
  28429. ],
  28430. [
  28431. 4,
  28432. 4
  28433. ],
  28434. [
  28435. 4,
  28436. 4
  28437. ],
  28438. [
  28439. 4,
  28440. 4
  28441. ],
  28442. [
  28443. 4,
  28444. 5
  28445. ],
  28446. [
  28447. 4,
  28448. 5
  28449. ],
  28450. [
  28451. 4,
  28452. 5
  28453. ],
  28454. [
  28455. 4,
  28456. 5
  28457. ],
  28458. [
  28459. 4,
  28460. 5
  28461. ],
  28462. [
  28463. 4,
  28464. 5
  28465. ],
  28466. [
  28467. 4,
  28468. 5
  28469. ],
  28470. [
  28471. 4,
  28472. 5
  28473. ],
  28474. [
  28475. 4,
  28476. 5
  28477. ],
  28478. [
  28479. 4,
  28480. 5
  28481. ],
  28482. [
  28483. 4,
  28484. 5
  28485. ],
  28486. [
  28487. 4,
  28488. 5
  28489. ],
  28490. [
  28491. 4,
  28492. 5
  28493. ],
  28494. [
  28495. 4,
  28496. 5
  28497. ],
  28498. [
  28499. 4,
  28500. 5
  28501. ],
  28502. [
  28503. 4,
  28504. 5
  28505. ],
  28506. [
  28507. 4,
  28508. 5
  28509. ],
  28510. [
  28511. 4,
  28512. 5
  28513. ],
  28514. [
  28515. 4,
  28516. 5
  28517. ],
  28518. [
  28519. 4,
  28520. 5
  28521. ],
  28522. [
  28523. 4,
  28524. 5
  28525. ],
  28526. [
  28527. 4,
  28528. 5
  28529. ],
  28530. [
  28531. 4,
  28532. 5
  28533. ],
  28534. [
  28535. 4,
  28536. 5
  28537. ],
  28538. [
  28539. 4,
  28540. 5
  28541. ],
  28542. [
  28543. 4,
  28544. 5
  28545. ],
  28546. [
  28547. 4,
  28548. 5
  28549. ],
  28550. [
  28551. 4,
  28552. 5
  28553. ],
  28554. [
  28555. 4,
  28556. 5
  28557. ],
  28558. [
  28559. 4,
  28560. 5
  28561. ],
  28562. [
  28563. 4,
  28564. 5
  28565. ],
  28566. [
  28567. 4,
  28568. 5
  28569. ],
  28570. [
  28571. 6,
  28572. 14
  28573. ],
  28574. [
  28575. 6,
  28576. 14
  28577. ],
  28578. [
  28579. 6,
  28580. 14
  28581. ],
  28582. [
  28583. 6,
  28584. 14
  28585. ],
  28586. [
  28587. 6,
  28588. 14
  28589. ],
  28590. [
  28591. 6,
  28592. 14
  28593. ],
  28594. [
  28595. 6,
  28596. 14
  28597. ],
  28598. [
  28599. 6,
  28600. 14
  28601. ],
  28602. [
  28603. 6,
  28604. 15
  28605. ],
  28606. [
  28607. 6,
  28608. 15
  28609. ],
  28610. [
  28611. 6,
  28612. 15
  28613. ],
  28614. [
  28615. 6,
  28616. 15
  28617. ],
  28618. [
  28619. 6,
  28620. 15
  28621. ],
  28622. [
  28623. 6,
  28624. 15
  28625. ],
  28626. [
  28627. 6,
  28628. 15
  28629. ],
  28630. [
  28631. 6,
  28632. 15
  28633. ],
  28634. [
  28635. 5,
  28636. 64
  28637. ],
  28638. [
  28639. 5,
  28640. 64
  28641. ],
  28642. [
  28643. 5,
  28644. 64
  28645. ],
  28646. [
  28647. 5,
  28648. 64
  28649. ],
  28650. [
  28651. 5,
  28652. 64
  28653. ],
  28654. [
  28655. 5,
  28656. 64
  28657. ],
  28658. [
  28659. 5,
  28660. 64
  28661. ],
  28662. [
  28663. 5,
  28664. 64
  28665. ],
  28666. [
  28667. 5,
  28668. 64
  28669. ],
  28670. [
  28671. 5,
  28672. 64
  28673. ],
  28674. [
  28675. 5,
  28676. 64
  28677. ],
  28678. [
  28679. 5,
  28680. 64
  28681. ],
  28682. [
  28683. 5,
  28684. 64
  28685. ],
  28686. [
  28687. 5,
  28688. 64
  28689. ],
  28690. [
  28691. 5,
  28692. 64
  28693. ],
  28694. [
  28695. 5,
  28696. 64
  28697. ],
  28698. [
  28699. 4,
  28700. 6
  28701. ],
  28702. [
  28703. 4,
  28704. 6
  28705. ],
  28706. [
  28707. 4,
  28708. 6
  28709. ],
  28710. [
  28711. 4,
  28712. 6
  28713. ],
  28714. [
  28715. 4,
  28716. 6
  28717. ],
  28718. [
  28719. 4,
  28720. 6
  28721. ],
  28722. [
  28723. 4,
  28724. 6
  28725. ],
  28726. [
  28727. 4,
  28728. 6
  28729. ],
  28730. [
  28731. 4,
  28732. 6
  28733. ],
  28734. [
  28735. 4,
  28736. 6
  28737. ],
  28738. [
  28739. 4,
  28740. 6
  28741. ],
  28742. [
  28743. 4,
  28744. 6
  28745. ],
  28746. [
  28747. 4,
  28748. 6
  28749. ],
  28750. [
  28751. 4,
  28752. 6
  28753. ],
  28754. [
  28755. 4,
  28756. 6
  28757. ],
  28758. [
  28759. 4,
  28760. 6
  28761. ],
  28762. [
  28763. 4,
  28764. 6
  28765. ],
  28766. [
  28767. 4,
  28768. 6
  28769. ],
  28770. [
  28771. 4,
  28772. 6
  28773. ],
  28774. [
  28775. 4,
  28776. 6
  28777. ],
  28778. [
  28779. 4,
  28780. 6
  28781. ],
  28782. [
  28783. 4,
  28784. 6
  28785. ],
  28786. [
  28787. 4,
  28788. 6
  28789. ],
  28790. [
  28791. 4,
  28792. 6
  28793. ],
  28794. [
  28795. 4,
  28796. 6
  28797. ],
  28798. [
  28799. 4,
  28800. 6
  28801. ],
  28802. [
  28803. 4,
  28804. 6
  28805. ],
  28806. [
  28807. 4,
  28808. 6
  28809. ],
  28810. [
  28811. 4,
  28812. 6
  28813. ],
  28814. [
  28815. 4,
  28816. 6
  28817. ],
  28818. [
  28819. 4,
  28820. 6
  28821. ],
  28822. [
  28823. 4,
  28824. 6
  28825. ],
  28826. [
  28827. 4,
  28828. 7
  28829. ],
  28830. [
  28831. 4,
  28832. 7
  28833. ],
  28834. [
  28835. 4,
  28836. 7
  28837. ],
  28838. [
  28839. 4,
  28840. 7
  28841. ],
  28842. [
  28843. 4,
  28844. 7
  28845. ],
  28846. [
  28847. 4,
  28848. 7
  28849. ],
  28850. [
  28851. 4,
  28852. 7
  28853. ],
  28854. [
  28855. 4,
  28856. 7
  28857. ],
  28858. [
  28859. 4,
  28860. 7
  28861. ],
  28862. [
  28863. 4,
  28864. 7
  28865. ],
  28866. [
  28867. 4,
  28868. 7
  28869. ],
  28870. [
  28871. 4,
  28872. 7
  28873. ],
  28874. [
  28875. 4,
  28876. 7
  28877. ],
  28878. [
  28879. 4,
  28880. 7
  28881. ],
  28882. [
  28883. 4,
  28884. 7
  28885. ],
  28886. [
  28887. 4,
  28888. 7
  28889. ],
  28890. [
  28891. 4,
  28892. 7
  28893. ],
  28894. [
  28895. 4,
  28896. 7
  28897. ],
  28898. [
  28899. 4,
  28900. 7
  28901. ],
  28902. [
  28903. 4,
  28904. 7
  28905. ],
  28906. [
  28907. 4,
  28908. 7
  28909. ],
  28910. [
  28911. 4,
  28912. 7
  28913. ],
  28914. [
  28915. 4,
  28916. 7
  28917. ],
  28918. [
  28919. 4,
  28920. 7
  28921. ],
  28922. [
  28923. 4,
  28924. 7
  28925. ],
  28926. [
  28927. 4,
  28928. 7
  28929. ],
  28930. [
  28931. 4,
  28932. 7
  28933. ],
  28934. [
  28935. 4,
  28936. 7
  28937. ],
  28938. [
  28939. 4,
  28940. 7
  28941. ],
  28942. [
  28943. 4,
  28944. 7
  28945. ],
  28946. [
  28947. 4,
  28948. 7
  28949. ],
  28950. [
  28951. 4,
  28952. 7
  28953. ]
  28954. ];
  28955. var blackTable1 = [
  28956. [
  28957. -1,
  28958. -1
  28959. ],
  28960. [
  28961. -1,
  28962. -1
  28963. ],
  28964. [
  28965. 12,
  28966. ccittEOL
  28967. ],
  28968. [
  28969. 12,
  28970. ccittEOL
  28971. ],
  28972. [
  28973. -1,
  28974. -1
  28975. ],
  28976. [
  28977. -1,
  28978. -1
  28979. ],
  28980. [
  28981. -1,
  28982. -1
  28983. ],
  28984. [
  28985. -1,
  28986. -1
  28987. ],
  28988. [
  28989. -1,
  28990. -1
  28991. ],
  28992. [
  28993. -1,
  28994. -1
  28995. ],
  28996. [
  28997. -1,
  28998. -1
  28999. ],
  29000. [
  29001. -1,
  29002. -1
  29003. ],
  29004. [
  29005. -1,
  29006. -1
  29007. ],
  29008. [
  29009. -1,
  29010. -1
  29011. ],
  29012. [
  29013. -1,
  29014. -1
  29015. ],
  29016. [
  29017. -1,
  29018. -1
  29019. ],
  29020. [
  29021. -1,
  29022. -1
  29023. ],
  29024. [
  29025. -1,
  29026. -1
  29027. ],
  29028. [
  29029. -1,
  29030. -1
  29031. ],
  29032. [
  29033. -1,
  29034. -1
  29035. ],
  29036. [
  29037. -1,
  29038. -1
  29039. ],
  29040. [
  29041. -1,
  29042. -1
  29043. ],
  29044. [
  29045. -1,
  29046. -1
  29047. ],
  29048. [
  29049. -1,
  29050. -1
  29051. ],
  29052. [
  29053. -1,
  29054. -1
  29055. ],
  29056. [
  29057. -1,
  29058. -1
  29059. ],
  29060. [
  29061. -1,
  29062. -1
  29063. ],
  29064. [
  29065. -1,
  29066. -1
  29067. ],
  29068. [
  29069. -1,
  29070. -1
  29071. ],
  29072. [
  29073. -1,
  29074. -1
  29075. ],
  29076. [
  29077. -1,
  29078. -1
  29079. ],
  29080. [
  29081. -1,
  29082. -1
  29083. ],
  29084. [
  29085. 11,
  29086. 1792
  29087. ],
  29088. [
  29089. 11,
  29090. 1792
  29091. ],
  29092. [
  29093. 11,
  29094. 1792
  29095. ],
  29096. [
  29097. 11,
  29098. 1792
  29099. ],
  29100. [
  29101. 12,
  29102. 1984
  29103. ],
  29104. [
  29105. 12,
  29106. 1984
  29107. ],
  29108. [
  29109. 12,
  29110. 2048
  29111. ],
  29112. [
  29113. 12,
  29114. 2048
  29115. ],
  29116. [
  29117. 12,
  29118. 2112
  29119. ],
  29120. [
  29121. 12,
  29122. 2112
  29123. ],
  29124. [
  29125. 12,
  29126. 2176
  29127. ],
  29128. [
  29129. 12,
  29130. 2176
  29131. ],
  29132. [
  29133. 12,
  29134. 2240
  29135. ],
  29136. [
  29137. 12,
  29138. 2240
  29139. ],
  29140. [
  29141. 12,
  29142. 2304
  29143. ],
  29144. [
  29145. 12,
  29146. 2304
  29147. ],
  29148. [
  29149. 11,
  29150. 1856
  29151. ],
  29152. [
  29153. 11,
  29154. 1856
  29155. ],
  29156. [
  29157. 11,
  29158. 1856
  29159. ],
  29160. [
  29161. 11,
  29162. 1856
  29163. ],
  29164. [
  29165. 11,
  29166. 1920
  29167. ],
  29168. [
  29169. 11,
  29170. 1920
  29171. ],
  29172. [
  29173. 11,
  29174. 1920
  29175. ],
  29176. [
  29177. 11,
  29178. 1920
  29179. ],
  29180. [
  29181. 12,
  29182. 2368
  29183. ],
  29184. [
  29185. 12,
  29186. 2368
  29187. ],
  29188. [
  29189. 12,
  29190. 2432
  29191. ],
  29192. [
  29193. 12,
  29194. 2432
  29195. ],
  29196. [
  29197. 12,
  29198. 2496
  29199. ],
  29200. [
  29201. 12,
  29202. 2496
  29203. ],
  29204. [
  29205. 12,
  29206. 2560
  29207. ],
  29208. [
  29209. 12,
  29210. 2560
  29211. ],
  29212. [
  29213. 10,
  29214. 18
  29215. ],
  29216. [
  29217. 10,
  29218. 18
  29219. ],
  29220. [
  29221. 10,
  29222. 18
  29223. ],
  29224. [
  29225. 10,
  29226. 18
  29227. ],
  29228. [
  29229. 10,
  29230. 18
  29231. ],
  29232. [
  29233. 10,
  29234. 18
  29235. ],
  29236. [
  29237. 10,
  29238. 18
  29239. ],
  29240. [
  29241. 10,
  29242. 18
  29243. ],
  29244. [
  29245. 12,
  29246. 52
  29247. ],
  29248. [
  29249. 12,
  29250. 52
  29251. ],
  29252. [
  29253. 13,
  29254. 640
  29255. ],
  29256. [
  29257. 13,
  29258. 704
  29259. ],
  29260. [
  29261. 13,
  29262. 768
  29263. ],
  29264. [
  29265. 13,
  29266. 832
  29267. ],
  29268. [
  29269. 12,
  29270. 55
  29271. ],
  29272. [
  29273. 12,
  29274. 55
  29275. ],
  29276. [
  29277. 12,
  29278. 56
  29279. ],
  29280. [
  29281. 12,
  29282. 56
  29283. ],
  29284. [
  29285. 13,
  29286. 1280
  29287. ],
  29288. [
  29289. 13,
  29290. 1344
  29291. ],
  29292. [
  29293. 13,
  29294. 1408
  29295. ],
  29296. [
  29297. 13,
  29298. 1472
  29299. ],
  29300. [
  29301. 12,
  29302. 59
  29303. ],
  29304. [
  29305. 12,
  29306. 59
  29307. ],
  29308. [
  29309. 12,
  29310. 60
  29311. ],
  29312. [
  29313. 12,
  29314. 60
  29315. ],
  29316. [
  29317. 13,
  29318. 1536
  29319. ],
  29320. [
  29321. 13,
  29322. 1600
  29323. ],
  29324. [
  29325. 11,
  29326. 24
  29327. ],
  29328. [
  29329. 11,
  29330. 24
  29331. ],
  29332. [
  29333. 11,
  29334. 24
  29335. ],
  29336. [
  29337. 11,
  29338. 24
  29339. ],
  29340. [
  29341. 11,
  29342. 25
  29343. ],
  29344. [
  29345. 11,
  29346. 25
  29347. ],
  29348. [
  29349. 11,
  29350. 25
  29351. ],
  29352. [
  29353. 11,
  29354. 25
  29355. ],
  29356. [
  29357. 13,
  29358. 1664
  29359. ],
  29360. [
  29361. 13,
  29362. 1728
  29363. ],
  29364. [
  29365. 12,
  29366. 320
  29367. ],
  29368. [
  29369. 12,
  29370. 320
  29371. ],
  29372. [
  29373. 12,
  29374. 384
  29375. ],
  29376. [
  29377. 12,
  29378. 384
  29379. ],
  29380. [
  29381. 12,
  29382. 448
  29383. ],
  29384. [
  29385. 12,
  29386. 448
  29387. ],
  29388. [
  29389. 13,
  29390. 512
  29391. ],
  29392. [
  29393. 13,
  29394. 576
  29395. ],
  29396. [
  29397. 12,
  29398. 53
  29399. ],
  29400. [
  29401. 12,
  29402. 53
  29403. ],
  29404. [
  29405. 12,
  29406. 54
  29407. ],
  29408. [
  29409. 12,
  29410. 54
  29411. ],
  29412. [
  29413. 13,
  29414. 896
  29415. ],
  29416. [
  29417. 13,
  29418. 960
  29419. ],
  29420. [
  29421. 13,
  29422. 1024
  29423. ],
  29424. [
  29425. 13,
  29426. 1088
  29427. ],
  29428. [
  29429. 13,
  29430. 1152
  29431. ],
  29432. [
  29433. 13,
  29434. 1216
  29435. ],
  29436. [
  29437. 10,
  29438. 64
  29439. ],
  29440. [
  29441. 10,
  29442. 64
  29443. ],
  29444. [
  29445. 10,
  29446. 64
  29447. ],
  29448. [
  29449. 10,
  29450. 64
  29451. ],
  29452. [
  29453. 10,
  29454. 64
  29455. ],
  29456. [
  29457. 10,
  29458. 64
  29459. ],
  29460. [
  29461. 10,
  29462. 64
  29463. ],
  29464. [
  29465. 10,
  29466. 64
  29467. ]
  29468. ];
  29469. var blackTable2 = [
  29470. [
  29471. 8,
  29472. 13
  29473. ],
  29474. [
  29475. 8,
  29476. 13
  29477. ],
  29478. [
  29479. 8,
  29480. 13
  29481. ],
  29482. [
  29483. 8,
  29484. 13
  29485. ],
  29486. [
  29487. 8,
  29488. 13
  29489. ],
  29490. [
  29491. 8,
  29492. 13
  29493. ],
  29494. [
  29495. 8,
  29496. 13
  29497. ],
  29498. [
  29499. 8,
  29500. 13
  29501. ],
  29502. [
  29503. 8,
  29504. 13
  29505. ],
  29506. [
  29507. 8,
  29508. 13
  29509. ],
  29510. [
  29511. 8,
  29512. 13
  29513. ],
  29514. [
  29515. 8,
  29516. 13
  29517. ],
  29518. [
  29519. 8,
  29520. 13
  29521. ],
  29522. [
  29523. 8,
  29524. 13
  29525. ],
  29526. [
  29527. 8,
  29528. 13
  29529. ],
  29530. [
  29531. 8,
  29532. 13
  29533. ],
  29534. [
  29535. 11,
  29536. 23
  29537. ],
  29538. [
  29539. 11,
  29540. 23
  29541. ],
  29542. [
  29543. 12,
  29544. 50
  29545. ],
  29546. [
  29547. 12,
  29548. 51
  29549. ],
  29550. [
  29551. 12,
  29552. 44
  29553. ],
  29554. [
  29555. 12,
  29556. 45
  29557. ],
  29558. [
  29559. 12,
  29560. 46
  29561. ],
  29562. [
  29563. 12,
  29564. 47
  29565. ],
  29566. [
  29567. 12,
  29568. 57
  29569. ],
  29570. [
  29571. 12,
  29572. 58
  29573. ],
  29574. [
  29575. 12,
  29576. 61
  29577. ],
  29578. [
  29579. 12,
  29580. 256
  29581. ],
  29582. [
  29583. 10,
  29584. 16
  29585. ],
  29586. [
  29587. 10,
  29588. 16
  29589. ],
  29590. [
  29591. 10,
  29592. 16
  29593. ],
  29594. [
  29595. 10,
  29596. 16
  29597. ],
  29598. [
  29599. 10,
  29600. 17
  29601. ],
  29602. [
  29603. 10,
  29604. 17
  29605. ],
  29606. [
  29607. 10,
  29608. 17
  29609. ],
  29610. [
  29611. 10,
  29612. 17
  29613. ],
  29614. [
  29615. 12,
  29616. 48
  29617. ],
  29618. [
  29619. 12,
  29620. 49
  29621. ],
  29622. [
  29623. 12,
  29624. 62
  29625. ],
  29626. [
  29627. 12,
  29628. 63
  29629. ],
  29630. [
  29631. 12,
  29632. 30
  29633. ],
  29634. [
  29635. 12,
  29636. 31
  29637. ],
  29638. [
  29639. 12,
  29640. 32
  29641. ],
  29642. [
  29643. 12,
  29644. 33
  29645. ],
  29646. [
  29647. 12,
  29648. 40
  29649. ],
  29650. [
  29651. 12,
  29652. 41
  29653. ],
  29654. [
  29655. 11,
  29656. 22
  29657. ],
  29658. [
  29659. 11,
  29660. 22
  29661. ],
  29662. [
  29663. 8,
  29664. 14
  29665. ],
  29666. [
  29667. 8,
  29668. 14
  29669. ],
  29670. [
  29671. 8,
  29672. 14
  29673. ],
  29674. [
  29675. 8,
  29676. 14
  29677. ],
  29678. [
  29679. 8,
  29680. 14
  29681. ],
  29682. [
  29683. 8,
  29684. 14
  29685. ],
  29686. [
  29687. 8,
  29688. 14
  29689. ],
  29690. [
  29691. 8,
  29692. 14
  29693. ],
  29694. [
  29695. 8,
  29696. 14
  29697. ],
  29698. [
  29699. 8,
  29700. 14
  29701. ],
  29702. [
  29703. 8,
  29704. 14
  29705. ],
  29706. [
  29707. 8,
  29708. 14
  29709. ],
  29710. [
  29711. 8,
  29712. 14
  29713. ],
  29714. [
  29715. 8,
  29716. 14
  29717. ],
  29718. [
  29719. 8,
  29720. 14
  29721. ],
  29722. [
  29723. 8,
  29724. 14
  29725. ],
  29726. [
  29727. 7,
  29728. 10
  29729. ],
  29730. [
  29731. 7,
  29732. 10
  29733. ],
  29734. [
  29735. 7,
  29736. 10
  29737. ],
  29738. [
  29739. 7,
  29740. 10
  29741. ],
  29742. [
  29743. 7,
  29744. 10
  29745. ],
  29746. [
  29747. 7,
  29748. 10
  29749. ],
  29750. [
  29751. 7,
  29752. 10
  29753. ],
  29754. [
  29755. 7,
  29756. 10
  29757. ],
  29758. [
  29759. 7,
  29760. 10
  29761. ],
  29762. [
  29763. 7,
  29764. 10
  29765. ],
  29766. [
  29767. 7,
  29768. 10
  29769. ],
  29770. [
  29771. 7,
  29772. 10
  29773. ],
  29774. [
  29775. 7,
  29776. 10
  29777. ],
  29778. [
  29779. 7,
  29780. 10
  29781. ],
  29782. [
  29783. 7,
  29784. 10
  29785. ],
  29786. [
  29787. 7,
  29788. 10
  29789. ],
  29790. [
  29791. 7,
  29792. 10
  29793. ],
  29794. [
  29795. 7,
  29796. 10
  29797. ],
  29798. [
  29799. 7,
  29800. 10
  29801. ],
  29802. [
  29803. 7,
  29804. 10
  29805. ],
  29806. [
  29807. 7,
  29808. 10
  29809. ],
  29810. [
  29811. 7,
  29812. 10
  29813. ],
  29814. [
  29815. 7,
  29816. 10
  29817. ],
  29818. [
  29819. 7,
  29820. 10
  29821. ],
  29822. [
  29823. 7,
  29824. 10
  29825. ],
  29826. [
  29827. 7,
  29828. 10
  29829. ],
  29830. [
  29831. 7,
  29832. 10
  29833. ],
  29834. [
  29835. 7,
  29836. 10
  29837. ],
  29838. [
  29839. 7,
  29840. 10
  29841. ],
  29842. [
  29843. 7,
  29844. 10
  29845. ],
  29846. [
  29847. 7,
  29848. 10
  29849. ],
  29850. [
  29851. 7,
  29852. 10
  29853. ],
  29854. [
  29855. 7,
  29856. 11
  29857. ],
  29858. [
  29859. 7,
  29860. 11
  29861. ],
  29862. [
  29863. 7,
  29864. 11
  29865. ],
  29866. [
  29867. 7,
  29868. 11
  29869. ],
  29870. [
  29871. 7,
  29872. 11
  29873. ],
  29874. [
  29875. 7,
  29876. 11
  29877. ],
  29878. [
  29879. 7,
  29880. 11
  29881. ],
  29882. [
  29883. 7,
  29884. 11
  29885. ],
  29886. [
  29887. 7,
  29888. 11
  29889. ],
  29890. [
  29891. 7,
  29892. 11
  29893. ],
  29894. [
  29895. 7,
  29896. 11
  29897. ],
  29898. [
  29899. 7,
  29900. 11
  29901. ],
  29902. [
  29903. 7,
  29904. 11
  29905. ],
  29906. [
  29907. 7,
  29908. 11
  29909. ],
  29910. [
  29911. 7,
  29912. 11
  29913. ],
  29914. [
  29915. 7,
  29916. 11
  29917. ],
  29918. [
  29919. 7,
  29920. 11
  29921. ],
  29922. [
  29923. 7,
  29924. 11
  29925. ],
  29926. [
  29927. 7,
  29928. 11
  29929. ],
  29930. [
  29931. 7,
  29932. 11
  29933. ],
  29934. [
  29935. 7,
  29936. 11
  29937. ],
  29938. [
  29939. 7,
  29940. 11
  29941. ],
  29942. [
  29943. 7,
  29944. 11
  29945. ],
  29946. [
  29947. 7,
  29948. 11
  29949. ],
  29950. [
  29951. 7,
  29952. 11
  29953. ],
  29954. [
  29955. 7,
  29956. 11
  29957. ],
  29958. [
  29959. 7,
  29960. 11
  29961. ],
  29962. [
  29963. 7,
  29964. 11
  29965. ],
  29966. [
  29967. 7,
  29968. 11
  29969. ],
  29970. [
  29971. 7,
  29972. 11
  29973. ],
  29974. [
  29975. 7,
  29976. 11
  29977. ],
  29978. [
  29979. 7,
  29980. 11
  29981. ],
  29982. [
  29983. 9,
  29984. 15
  29985. ],
  29986. [
  29987. 9,
  29988. 15
  29989. ],
  29990. [
  29991. 9,
  29992. 15
  29993. ],
  29994. [
  29995. 9,
  29996. 15
  29997. ],
  29998. [
  29999. 9,
  30000. 15
  30001. ],
  30002. [
  30003. 9,
  30004. 15
  30005. ],
  30006. [
  30007. 9,
  30008. 15
  30009. ],
  30010. [
  30011. 9,
  30012. 15
  30013. ],
  30014. [
  30015. 12,
  30016. 128
  30017. ],
  30018. [
  30019. 12,
  30020. 192
  30021. ],
  30022. [
  30023. 12,
  30024. 26
  30025. ],
  30026. [
  30027. 12,
  30028. 27
  30029. ],
  30030. [
  30031. 12,
  30032. 28
  30033. ],
  30034. [
  30035. 12,
  30036. 29
  30037. ],
  30038. [
  30039. 11,
  30040. 19
  30041. ],
  30042. [
  30043. 11,
  30044. 19
  30045. ],
  30046. [
  30047. 11,
  30048. 20
  30049. ],
  30050. [
  30051. 11,
  30052. 20
  30053. ],
  30054. [
  30055. 12,
  30056. 34
  30057. ],
  30058. [
  30059. 12,
  30060. 35
  30061. ],
  30062. [
  30063. 12,
  30064. 36
  30065. ],
  30066. [
  30067. 12,
  30068. 37
  30069. ],
  30070. [
  30071. 12,
  30072. 38
  30073. ],
  30074. [
  30075. 12,
  30076. 39
  30077. ],
  30078. [
  30079. 11,
  30080. 21
  30081. ],
  30082. [
  30083. 11,
  30084. 21
  30085. ],
  30086. [
  30087. 12,
  30088. 42
  30089. ],
  30090. [
  30091. 12,
  30092. 43
  30093. ],
  30094. [
  30095. 10,
  30096. 0
  30097. ],
  30098. [
  30099. 10,
  30100. 0
  30101. ],
  30102. [
  30103. 10,
  30104. 0
  30105. ],
  30106. [
  30107. 10,
  30108. 0
  30109. ],
  30110. [
  30111. 7,
  30112. 12
  30113. ],
  30114. [
  30115. 7,
  30116. 12
  30117. ],
  30118. [
  30119. 7,
  30120. 12
  30121. ],
  30122. [
  30123. 7,
  30124. 12
  30125. ],
  30126. [
  30127. 7,
  30128. 12
  30129. ],
  30130. [
  30131. 7,
  30132. 12
  30133. ],
  30134. [
  30135. 7,
  30136. 12
  30137. ],
  30138. [
  30139. 7,
  30140. 12
  30141. ],
  30142. [
  30143. 7,
  30144. 12
  30145. ],
  30146. [
  30147. 7,
  30148. 12
  30149. ],
  30150. [
  30151. 7,
  30152. 12
  30153. ],
  30154. [
  30155. 7,
  30156. 12
  30157. ],
  30158. [
  30159. 7,
  30160. 12
  30161. ],
  30162. [
  30163. 7,
  30164. 12
  30165. ],
  30166. [
  30167. 7,
  30168. 12
  30169. ],
  30170. [
  30171. 7,
  30172. 12
  30173. ],
  30174. [
  30175. 7,
  30176. 12
  30177. ],
  30178. [
  30179. 7,
  30180. 12
  30181. ],
  30182. [
  30183. 7,
  30184. 12
  30185. ],
  30186. [
  30187. 7,
  30188. 12
  30189. ],
  30190. [
  30191. 7,
  30192. 12
  30193. ],
  30194. [
  30195. 7,
  30196. 12
  30197. ],
  30198. [
  30199. 7,
  30200. 12
  30201. ],
  30202. [
  30203. 7,
  30204. 12
  30205. ],
  30206. [
  30207. 7,
  30208. 12
  30209. ],
  30210. [
  30211. 7,
  30212. 12
  30213. ],
  30214. [
  30215. 7,
  30216. 12
  30217. ],
  30218. [
  30219. 7,
  30220. 12
  30221. ],
  30222. [
  30223. 7,
  30224. 12
  30225. ],
  30226. [
  30227. 7,
  30228. 12
  30229. ],
  30230. [
  30231. 7,
  30232. 12
  30233. ],
  30234. [
  30235. 7,
  30236. 12
  30237. ]
  30238. ];
  30239. var blackTable3 = [
  30240. [
  30241. -1,
  30242. -1
  30243. ],
  30244. [
  30245. -1,
  30246. -1
  30247. ],
  30248. [
  30249. -1,
  30250. -1
  30251. ],
  30252. [
  30253. -1,
  30254. -1
  30255. ],
  30256. [
  30257. 6,
  30258. 9
  30259. ],
  30260. [
  30261. 6,
  30262. 8
  30263. ],
  30264. [
  30265. 5,
  30266. 7
  30267. ],
  30268. [
  30269. 5,
  30270. 7
  30271. ],
  30272. [
  30273. 4,
  30274. 6
  30275. ],
  30276. [
  30277. 4,
  30278. 6
  30279. ],
  30280. [
  30281. 4,
  30282. 6
  30283. ],
  30284. [
  30285. 4,
  30286. 6
  30287. ],
  30288. [
  30289. 4,
  30290. 5
  30291. ],
  30292. [
  30293. 4,
  30294. 5
  30295. ],
  30296. [
  30297. 4,
  30298. 5
  30299. ],
  30300. [
  30301. 4,
  30302. 5
  30303. ],
  30304. [
  30305. 3,
  30306. 1
  30307. ],
  30308. [
  30309. 3,
  30310. 1
  30311. ],
  30312. [
  30313. 3,
  30314. 1
  30315. ],
  30316. [
  30317. 3,
  30318. 1
  30319. ],
  30320. [
  30321. 3,
  30322. 1
  30323. ],
  30324. [
  30325. 3,
  30326. 1
  30327. ],
  30328. [
  30329. 3,
  30330. 1
  30331. ],
  30332. [
  30333. 3,
  30334. 1
  30335. ],
  30336. [
  30337. 3,
  30338. 4
  30339. ],
  30340. [
  30341. 3,
  30342. 4
  30343. ],
  30344. [
  30345. 3,
  30346. 4
  30347. ],
  30348. [
  30349. 3,
  30350. 4
  30351. ],
  30352. [
  30353. 3,
  30354. 4
  30355. ],
  30356. [
  30357. 3,
  30358. 4
  30359. ],
  30360. [
  30361. 3,
  30362. 4
  30363. ],
  30364. [
  30365. 3,
  30366. 4
  30367. ],
  30368. [
  30369. 2,
  30370. 3
  30371. ],
  30372. [
  30373. 2,
  30374. 3
  30375. ],
  30376. [
  30377. 2,
  30378. 3
  30379. ],
  30380. [
  30381. 2,
  30382. 3
  30383. ],
  30384. [
  30385. 2,
  30386. 3
  30387. ],
  30388. [
  30389. 2,
  30390. 3
  30391. ],
  30392. [
  30393. 2,
  30394. 3
  30395. ],
  30396. [
  30397. 2,
  30398. 3
  30399. ],
  30400. [
  30401. 2,
  30402. 3
  30403. ],
  30404. [
  30405. 2,
  30406. 3
  30407. ],
  30408. [
  30409. 2,
  30410. 3
  30411. ],
  30412. [
  30413. 2,
  30414. 3
  30415. ],
  30416. [
  30417. 2,
  30418. 3
  30419. ],
  30420. [
  30421. 2,
  30422. 3
  30423. ],
  30424. [
  30425. 2,
  30426. 3
  30427. ],
  30428. [
  30429. 2,
  30430. 3
  30431. ],
  30432. [
  30433. 2,
  30434. 2
  30435. ],
  30436. [
  30437. 2,
  30438. 2
  30439. ],
  30440. [
  30441. 2,
  30442. 2
  30443. ],
  30444. [
  30445. 2,
  30446. 2
  30447. ],
  30448. [
  30449. 2,
  30450. 2
  30451. ],
  30452. [
  30453. 2,
  30454. 2
  30455. ],
  30456. [
  30457. 2,
  30458. 2
  30459. ],
  30460. [
  30461. 2,
  30462. 2
  30463. ],
  30464. [
  30465. 2,
  30466. 2
  30467. ],
  30468. [
  30469. 2,
  30470. 2
  30471. ],
  30472. [
  30473. 2,
  30474. 2
  30475. ],
  30476. [
  30477. 2,
  30478. 2
  30479. ],
  30480. [
  30481. 2,
  30482. 2
  30483. ],
  30484. [
  30485. 2,
  30486. 2
  30487. ],
  30488. [
  30489. 2,
  30490. 2
  30491. ],
  30492. [
  30493. 2,
  30494. 2
  30495. ]
  30496. ];
  30497. function CCITTFaxStream(str, maybeLength, params) {
  30498. this.str = str;
  30499. this.dict = str.dict;
  30500. params = params || Dict.empty;
  30501. this.encoding = params.get('K') || 0;
  30502. this.eoline = params.get('EndOfLine') || false;
  30503. this.byteAlign = params.get('EncodedByteAlign') || false;
  30504. this.columns = params.get('Columns') || 1728;
  30505. this.rows = params.get('Rows') || 0;
  30506. var eoblock = params.get('EndOfBlock');
  30507. if (eoblock === null || eoblock === undefined) {
  30508. eoblock = true;
  30509. }
  30510. this.eoblock = eoblock;
  30511. this.black = params.get('BlackIs1') || false;
  30512. this.codingLine = new Uint32Array(this.columns + 1);
  30513. this.refLine = new Uint32Array(this.columns + 2);
  30514. this.codingLine[0] = this.columns;
  30515. this.codingPos = 0;
  30516. this.row = 0;
  30517. this.nextLine2D = this.encoding < 0;
  30518. this.inputBits = 0;
  30519. this.inputBuf = 0;
  30520. this.outputBits = 0;
  30521. var code1;
  30522. while ((code1 = this.lookBits(12)) === 0) {
  30523. this.eatBits(1);
  30524. }
  30525. if (code1 === 1) {
  30526. this.eatBits(12);
  30527. }
  30528. if (this.encoding > 0) {
  30529. this.nextLine2D = !this.lookBits(1);
  30530. this.eatBits(1);
  30531. }
  30532. DecodeStream.call(this, maybeLength);
  30533. }
  30534. CCITTFaxStream.prototype = Object.create(DecodeStream.prototype);
  30535. CCITTFaxStream.prototype.readBlock = function CCITTFaxStream_readBlock() {
  30536. while (!this.eof) {
  30537. var c = this.lookChar();
  30538. this.ensureBuffer(this.bufferLength + 1);
  30539. this.buffer[this.bufferLength++] = c;
  30540. }
  30541. };
  30542. CCITTFaxStream.prototype.addPixels = function ccittFaxStreamAddPixels(a1, blackPixels) {
  30543. var codingLine = this.codingLine;
  30544. var codingPos = this.codingPos;
  30545. if (a1 > codingLine[codingPos]) {
  30546. if (a1 > this.columns) {
  30547. info('row is wrong length');
  30548. this.err = true;
  30549. a1 = this.columns;
  30550. }
  30551. if (codingPos & 1 ^ blackPixels) {
  30552. ++codingPos;
  30553. }
  30554. codingLine[codingPos] = a1;
  30555. }
  30556. this.codingPos = codingPos;
  30557. };
  30558. CCITTFaxStream.prototype.addPixelsNeg = function ccittFaxStreamAddPixelsNeg(a1, blackPixels) {
  30559. var codingLine = this.codingLine;
  30560. var codingPos = this.codingPos;
  30561. if (a1 > codingLine[codingPos]) {
  30562. if (a1 > this.columns) {
  30563. info('row is wrong length');
  30564. this.err = true;
  30565. a1 = this.columns;
  30566. }
  30567. if (codingPos & 1 ^ blackPixels) {
  30568. ++codingPos;
  30569. }
  30570. codingLine[codingPos] = a1;
  30571. } else if (a1 < codingLine[codingPos]) {
  30572. if (a1 < 0) {
  30573. info('invalid code');
  30574. this.err = true;
  30575. a1 = 0;
  30576. }
  30577. while (codingPos > 0 && a1 < codingLine[codingPos - 1]) {
  30578. --codingPos;
  30579. }
  30580. codingLine[codingPos] = a1;
  30581. }
  30582. this.codingPos = codingPos;
  30583. };
  30584. CCITTFaxStream.prototype.lookChar = function CCITTFaxStream_lookChar() {
  30585. var refLine = this.refLine;
  30586. var codingLine = this.codingLine;
  30587. var columns = this.columns;
  30588. var refPos, blackPixels, bits, i;
  30589. if (this.outputBits === 0) {
  30590. if (this.eof) {
  30591. return null;
  30592. }
  30593. this.err = false;
  30594. var code1, code2, code3;
  30595. if (this.nextLine2D) {
  30596. for (i = 0; codingLine[i] < columns; ++i) {
  30597. refLine[i] = codingLine[i];
  30598. }
  30599. refLine[i++] = columns;
  30600. refLine[i] = columns;
  30601. codingLine[0] = 0;
  30602. this.codingPos = 0;
  30603. refPos = 0;
  30604. blackPixels = 0;
  30605. while (codingLine[this.codingPos] < columns) {
  30606. code1 = this.getTwoDimCode();
  30607. switch (code1) {
  30608. case twoDimPass:
  30609. this.addPixels(refLine[refPos + 1], blackPixels);
  30610. if (refLine[refPos + 1] < columns) {
  30611. refPos += 2;
  30612. }
  30613. break;
  30614. case twoDimHoriz:
  30615. code1 = code2 = 0;
  30616. if (blackPixels) {
  30617. do {
  30618. code1 += code3 = this.getBlackCode();
  30619. } while (code3 >= 64);
  30620. do {
  30621. code2 += code3 = this.getWhiteCode();
  30622. } while (code3 >= 64);
  30623. } else {
  30624. do {
  30625. code1 += code3 = this.getWhiteCode();
  30626. } while (code3 >= 64);
  30627. do {
  30628. code2 += code3 = this.getBlackCode();
  30629. } while (code3 >= 64);
  30630. }
  30631. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30632. if (codingLine[this.codingPos] < columns) {
  30633. this.addPixels(codingLine[this.codingPos] + code2, blackPixels ^ 1);
  30634. }
  30635. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30636. refPos += 2;
  30637. }
  30638. break;
  30639. case twoDimVertR3:
  30640. this.addPixels(refLine[refPos] + 3, blackPixels);
  30641. blackPixels ^= 1;
  30642. if (codingLine[this.codingPos] < columns) {
  30643. ++refPos;
  30644. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30645. refPos += 2;
  30646. }
  30647. }
  30648. break;
  30649. case twoDimVertR2:
  30650. this.addPixels(refLine[refPos] + 2, blackPixels);
  30651. blackPixels ^= 1;
  30652. if (codingLine[this.codingPos] < columns) {
  30653. ++refPos;
  30654. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30655. refPos += 2;
  30656. }
  30657. }
  30658. break;
  30659. case twoDimVertR1:
  30660. this.addPixels(refLine[refPos] + 1, blackPixels);
  30661. blackPixels ^= 1;
  30662. if (codingLine[this.codingPos] < columns) {
  30663. ++refPos;
  30664. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30665. refPos += 2;
  30666. }
  30667. }
  30668. break;
  30669. case twoDimVert0:
  30670. this.addPixels(refLine[refPos], blackPixels);
  30671. blackPixels ^= 1;
  30672. if (codingLine[this.codingPos] < columns) {
  30673. ++refPos;
  30674. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30675. refPos += 2;
  30676. }
  30677. }
  30678. break;
  30679. case twoDimVertL3:
  30680. this.addPixelsNeg(refLine[refPos] - 3, blackPixels);
  30681. blackPixels ^= 1;
  30682. if (codingLine[this.codingPos] < columns) {
  30683. if (refPos > 0) {
  30684. --refPos;
  30685. } else {
  30686. ++refPos;
  30687. }
  30688. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30689. refPos += 2;
  30690. }
  30691. }
  30692. break;
  30693. case twoDimVertL2:
  30694. this.addPixelsNeg(refLine[refPos] - 2, blackPixels);
  30695. blackPixels ^= 1;
  30696. if (codingLine[this.codingPos] < columns) {
  30697. if (refPos > 0) {
  30698. --refPos;
  30699. } else {
  30700. ++refPos;
  30701. }
  30702. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30703. refPos += 2;
  30704. }
  30705. }
  30706. break;
  30707. case twoDimVertL1:
  30708. this.addPixelsNeg(refLine[refPos] - 1, blackPixels);
  30709. blackPixels ^= 1;
  30710. if (codingLine[this.codingPos] < columns) {
  30711. if (refPos > 0) {
  30712. --refPos;
  30713. } else {
  30714. ++refPos;
  30715. }
  30716. while (refLine[refPos] <= codingLine[this.codingPos] && refLine[refPos] < columns) {
  30717. refPos += 2;
  30718. }
  30719. }
  30720. break;
  30721. case ccittEOF:
  30722. this.addPixels(columns, 0);
  30723. this.eof = true;
  30724. break;
  30725. default:
  30726. info('bad 2d code');
  30727. this.addPixels(columns, 0);
  30728. this.err = true;
  30729. }
  30730. }
  30731. } else {
  30732. codingLine[0] = 0;
  30733. this.codingPos = 0;
  30734. blackPixels = 0;
  30735. while (codingLine[this.codingPos] < columns) {
  30736. code1 = 0;
  30737. if (blackPixels) {
  30738. do {
  30739. code1 += code3 = this.getBlackCode();
  30740. } while (code3 >= 64);
  30741. } else {
  30742. do {
  30743. code1 += code3 = this.getWhiteCode();
  30744. } while (code3 >= 64);
  30745. }
  30746. this.addPixels(codingLine[this.codingPos] + code1, blackPixels);
  30747. blackPixels ^= 1;
  30748. }
  30749. }
  30750. var gotEOL = false;
  30751. if (this.byteAlign) {
  30752. this.inputBits &= ~7;
  30753. }
  30754. if (!this.eoblock && this.row === this.rows - 1) {
  30755. this.eof = true;
  30756. } else {
  30757. code1 = this.lookBits(12);
  30758. if (this.eoline) {
  30759. while (code1 !== ccittEOF && code1 !== 1) {
  30760. this.eatBits(1);
  30761. code1 = this.lookBits(12);
  30762. }
  30763. } else {
  30764. while (code1 === 0) {
  30765. this.eatBits(1);
  30766. code1 = this.lookBits(12);
  30767. }
  30768. }
  30769. if (code1 === 1) {
  30770. this.eatBits(12);
  30771. gotEOL = true;
  30772. } else if (code1 === ccittEOF) {
  30773. this.eof = true;
  30774. }
  30775. }
  30776. if (!this.eof && this.encoding > 0) {
  30777. this.nextLine2D = !this.lookBits(1);
  30778. this.eatBits(1);
  30779. }
  30780. if (this.eoblock && gotEOL && this.byteAlign) {
  30781. code1 = this.lookBits(12);
  30782. if (code1 === 1) {
  30783. this.eatBits(12);
  30784. if (this.encoding > 0) {
  30785. this.lookBits(1);
  30786. this.eatBits(1);
  30787. }
  30788. if (this.encoding >= 0) {
  30789. for (i = 0; i < 4; ++i) {
  30790. code1 = this.lookBits(12);
  30791. if (code1 !== 1) {
  30792. info('bad rtc code: ' + code1);
  30793. }
  30794. this.eatBits(12);
  30795. if (this.encoding > 0) {
  30796. this.lookBits(1);
  30797. this.eatBits(1);
  30798. }
  30799. }
  30800. }
  30801. this.eof = true;
  30802. }
  30803. } else if (this.err && this.eoline) {
  30804. while (true) {
  30805. code1 = this.lookBits(13);
  30806. if (code1 === ccittEOF) {
  30807. this.eof = true;
  30808. return null;
  30809. }
  30810. if (code1 >> 1 === 1) {
  30811. break;
  30812. }
  30813. this.eatBits(1);
  30814. }
  30815. this.eatBits(12);
  30816. if (this.encoding > 0) {
  30817. this.eatBits(1);
  30818. this.nextLine2D = !(code1 & 1);
  30819. }
  30820. }
  30821. if (codingLine[0] > 0) {
  30822. this.outputBits = codingLine[this.codingPos = 0];
  30823. } else {
  30824. this.outputBits = codingLine[this.codingPos = 1];
  30825. }
  30826. this.row++;
  30827. }
  30828. var c;
  30829. if (this.outputBits >= 8) {
  30830. c = this.codingPos & 1 ? 0 : 0xFF;
  30831. this.outputBits -= 8;
  30832. if (this.outputBits === 0 && codingLine[this.codingPos] < columns) {
  30833. this.codingPos++;
  30834. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30835. }
  30836. } else {
  30837. bits = 8;
  30838. c = 0;
  30839. do {
  30840. if (this.outputBits > bits) {
  30841. c <<= bits;
  30842. if (!(this.codingPos & 1)) {
  30843. c |= 0xFF >> 8 - bits;
  30844. }
  30845. this.outputBits -= bits;
  30846. bits = 0;
  30847. } else {
  30848. c <<= this.outputBits;
  30849. if (!(this.codingPos & 1)) {
  30850. c |= 0xFF >> 8 - this.outputBits;
  30851. }
  30852. bits -= this.outputBits;
  30853. this.outputBits = 0;
  30854. if (codingLine[this.codingPos] < columns) {
  30855. this.codingPos++;
  30856. this.outputBits = codingLine[this.codingPos] - codingLine[this.codingPos - 1];
  30857. } else if (bits > 0) {
  30858. c <<= bits;
  30859. bits = 0;
  30860. }
  30861. }
  30862. } while (bits);
  30863. }
  30864. if (this.black) {
  30865. c ^= 0xFF;
  30866. }
  30867. return c;
  30868. };
  30869. CCITTFaxStream.prototype.findTableCode = function ccittFaxStreamFindTableCode(start, end, table, limit) {
  30870. var limitValue = limit || 0;
  30871. for (var i = start; i <= end; ++i) {
  30872. var code = this.lookBits(i);
  30873. if (code === ccittEOF) {
  30874. return [
  30875. true,
  30876. 1,
  30877. false
  30878. ];
  30879. }
  30880. if (i < end) {
  30881. code <<= end - i;
  30882. }
  30883. if (!limitValue || code >= limitValue) {
  30884. var p = table[code - limitValue];
  30885. if (p[0] === i) {
  30886. this.eatBits(i);
  30887. return [
  30888. true,
  30889. p[1],
  30890. true
  30891. ];
  30892. }
  30893. }
  30894. }
  30895. return [
  30896. false,
  30897. 0,
  30898. false
  30899. ];
  30900. };
  30901. CCITTFaxStream.prototype.getTwoDimCode = function ccittFaxStreamGetTwoDimCode() {
  30902. var code = 0;
  30903. var p;
  30904. if (this.eoblock) {
  30905. code = this.lookBits(7);
  30906. p = twoDimTable[code];
  30907. if (p && p[0] > 0) {
  30908. this.eatBits(p[0]);
  30909. return p[1];
  30910. }
  30911. } else {
  30912. var result = this.findTableCode(1, 7, twoDimTable);
  30913. if (result[0] && result[2]) {
  30914. return result[1];
  30915. }
  30916. }
  30917. info('Bad two dim code');
  30918. return ccittEOF;
  30919. };
  30920. CCITTFaxStream.prototype.getWhiteCode = function ccittFaxStreamGetWhiteCode() {
  30921. var code = 0;
  30922. var p;
  30923. if (this.eoblock) {
  30924. code = this.lookBits(12);
  30925. if (code === ccittEOF) {
  30926. return 1;
  30927. }
  30928. if (code >> 5 === 0) {
  30929. p = whiteTable1[code];
  30930. } else {
  30931. p = whiteTable2[code >> 3];
  30932. }
  30933. if (p[0] > 0) {
  30934. this.eatBits(p[0]);
  30935. return p[1];
  30936. }
  30937. } else {
  30938. var result = this.findTableCode(1, 9, whiteTable2);
  30939. if (result[0]) {
  30940. return result[1];
  30941. }
  30942. result = this.findTableCode(11, 12, whiteTable1);
  30943. if (result[0]) {
  30944. return result[1];
  30945. }
  30946. }
  30947. info('bad white code');
  30948. this.eatBits(1);
  30949. return 1;
  30950. };
  30951. CCITTFaxStream.prototype.getBlackCode = function ccittFaxStreamGetBlackCode() {
  30952. var code, p;
  30953. if (this.eoblock) {
  30954. code = this.lookBits(13);
  30955. if (code === ccittEOF) {
  30956. return 1;
  30957. }
  30958. if (code >> 7 === 0) {
  30959. p = blackTable1[code];
  30960. } else if (code >> 9 === 0 && code >> 7 !== 0) {
  30961. p = blackTable2[(code >> 1) - 64];
  30962. } else {
  30963. p = blackTable3[code >> 7];
  30964. }
  30965. if (p[0] > 0) {
  30966. this.eatBits(p[0]);
  30967. return p[1];
  30968. }
  30969. } else {
  30970. var result = this.findTableCode(2, 6, blackTable3);
  30971. if (result[0]) {
  30972. return result[1];
  30973. }
  30974. result = this.findTableCode(7, 12, blackTable2, 64);
  30975. if (result[0]) {
  30976. return result[1];
  30977. }
  30978. result = this.findTableCode(10, 13, blackTable1);
  30979. if (result[0]) {
  30980. return result[1];
  30981. }
  30982. }
  30983. info('bad black code');
  30984. this.eatBits(1);
  30985. return 1;
  30986. };
  30987. CCITTFaxStream.prototype.lookBits = function CCITTFaxStream_lookBits(n) {
  30988. var c;
  30989. while (this.inputBits < n) {
  30990. if ((c = this.str.getByte()) === -1) {
  30991. if (this.inputBits === 0) {
  30992. return ccittEOF;
  30993. }
  30994. return this.inputBuf << n - this.inputBits & 0xFFFF >> 16 - n;
  30995. }
  30996. this.inputBuf = this.inputBuf << 8 | c;
  30997. this.inputBits += 8;
  30998. }
  30999. return this.inputBuf >> this.inputBits - n & 0xFFFF >> 16 - n;
  31000. };
  31001. CCITTFaxStream.prototype.eatBits = function CCITTFaxStream_eatBits(n) {
  31002. if ((this.inputBits -= n) < 0) {
  31003. this.inputBits = 0;
  31004. }
  31005. };
  31006. return CCITTFaxStream;
  31007. }();
  31008. var LZWStream = function LZWStreamClosure() {
  31009. function LZWStream(str, maybeLength, earlyChange) {
  31010. this.str = str;
  31011. this.dict = str.dict;
  31012. this.cachedData = 0;
  31013. this.bitsCached = 0;
  31014. var maxLzwDictionarySize = 4096;
  31015. var lzwState = {
  31016. earlyChange: earlyChange,
  31017. codeLength: 9,
  31018. nextCode: 258,
  31019. dictionaryValues: new Uint8Array(maxLzwDictionarySize),
  31020. dictionaryLengths: new Uint16Array(maxLzwDictionarySize),
  31021. dictionaryPrevCodes: new Uint16Array(maxLzwDictionarySize),
  31022. currentSequence: new Uint8Array(maxLzwDictionarySize),
  31023. currentSequenceLength: 0
  31024. };
  31025. for (var i = 0; i < 256; ++i) {
  31026. lzwState.dictionaryValues[i] = i;
  31027. lzwState.dictionaryLengths[i] = 1;
  31028. }
  31029. this.lzwState = lzwState;
  31030. DecodeStream.call(this, maybeLength);
  31031. }
  31032. LZWStream.prototype = Object.create(DecodeStream.prototype);
  31033. LZWStream.prototype.readBits = function LZWStream_readBits(n) {
  31034. var bitsCached = this.bitsCached;
  31035. var cachedData = this.cachedData;
  31036. while (bitsCached < n) {
  31037. var c = this.str.getByte();
  31038. if (c === -1) {
  31039. this.eof = true;
  31040. return null;
  31041. }
  31042. cachedData = cachedData << 8 | c;
  31043. bitsCached += 8;
  31044. }
  31045. this.bitsCached = bitsCached -= n;
  31046. this.cachedData = cachedData;
  31047. this.lastCode = null;
  31048. return cachedData >>> bitsCached & (1 << n) - 1;
  31049. };
  31050. LZWStream.prototype.readBlock = function LZWStream_readBlock() {
  31051. var blockSize = 512;
  31052. var estimatedDecodedSize = blockSize * 2, decodedSizeDelta = blockSize;
  31053. var i, j, q;
  31054. var lzwState = this.lzwState;
  31055. if (!lzwState) {
  31056. return;
  31057. }
  31058. var earlyChange = lzwState.earlyChange;
  31059. var nextCode = lzwState.nextCode;
  31060. var dictionaryValues = lzwState.dictionaryValues;
  31061. var dictionaryLengths = lzwState.dictionaryLengths;
  31062. var dictionaryPrevCodes = lzwState.dictionaryPrevCodes;
  31063. var codeLength = lzwState.codeLength;
  31064. var prevCode = lzwState.prevCode;
  31065. var currentSequence = lzwState.currentSequence;
  31066. var currentSequenceLength = lzwState.currentSequenceLength;
  31067. var decodedLength = 0;
  31068. var currentBufferLength = this.bufferLength;
  31069. var buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31070. for (i = 0; i < blockSize; i++) {
  31071. var code = this.readBits(codeLength);
  31072. var hasPrev = currentSequenceLength > 0;
  31073. if (code < 256) {
  31074. currentSequence[0] = code;
  31075. currentSequenceLength = 1;
  31076. } else if (code >= 258) {
  31077. if (code < nextCode) {
  31078. currentSequenceLength = dictionaryLengths[code];
  31079. for (j = currentSequenceLength - 1, q = code; j >= 0; j--) {
  31080. currentSequence[j] = dictionaryValues[q];
  31081. q = dictionaryPrevCodes[q];
  31082. }
  31083. } else {
  31084. currentSequence[currentSequenceLength++] = currentSequence[0];
  31085. }
  31086. } else if (code === 256) {
  31087. codeLength = 9;
  31088. nextCode = 258;
  31089. currentSequenceLength = 0;
  31090. continue;
  31091. } else {
  31092. this.eof = true;
  31093. delete this.lzwState;
  31094. break;
  31095. }
  31096. if (hasPrev) {
  31097. dictionaryPrevCodes[nextCode] = prevCode;
  31098. dictionaryLengths[nextCode] = dictionaryLengths[prevCode] + 1;
  31099. dictionaryValues[nextCode] = currentSequence[0];
  31100. nextCode++;
  31101. codeLength = nextCode + earlyChange & nextCode + earlyChange - 1 ? codeLength : Math.min(Math.log(nextCode + earlyChange) / 0.6931471805599453 + 1, 12) | 0;
  31102. }
  31103. prevCode = code;
  31104. decodedLength += currentSequenceLength;
  31105. if (estimatedDecodedSize < decodedLength) {
  31106. do {
  31107. estimatedDecodedSize += decodedSizeDelta;
  31108. } while (estimatedDecodedSize < decodedLength);
  31109. buffer = this.ensureBuffer(this.bufferLength + estimatedDecodedSize);
  31110. }
  31111. for (j = 0; j < currentSequenceLength; j++) {
  31112. buffer[currentBufferLength++] = currentSequence[j];
  31113. }
  31114. }
  31115. lzwState.nextCode = nextCode;
  31116. lzwState.codeLength = codeLength;
  31117. lzwState.prevCode = prevCode;
  31118. lzwState.currentSequenceLength = currentSequenceLength;
  31119. this.bufferLength = currentBufferLength;
  31120. };
  31121. return LZWStream;
  31122. }();
  31123. var NullStream = function NullStreamClosure() {
  31124. function NullStream() {
  31125. Stream.call(this, new Uint8Array(0));
  31126. }
  31127. NullStream.prototype = Stream.prototype;
  31128. return NullStream;
  31129. }();
  31130. exports.Ascii85Stream = Ascii85Stream;
  31131. exports.AsciiHexStream = AsciiHexStream;
  31132. exports.CCITTFaxStream = CCITTFaxStream;
  31133. exports.DecryptStream = DecryptStream;
  31134. exports.DecodeStream = DecodeStream;
  31135. exports.FlateStream = FlateStream;
  31136. exports.Jbig2Stream = Jbig2Stream;
  31137. exports.JpegStream = JpegStream;
  31138. exports.JpxStream = JpxStream;
  31139. exports.NullStream = NullStream;
  31140. exports.PredictorStream = PredictorStream;
  31141. exports.RunLengthStream = RunLengthStream;
  31142. exports.Stream = Stream;
  31143. exports.StreamsSequenceStream = StreamsSequenceStream;
  31144. exports.StringStream = StringStream;
  31145. exports.LZWStream = LZWStream;
  31146. }));
  31147. (function (root, factory) {
  31148. factory(root.pdfjsDisplayAnnotationLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31149. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31150. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  31151. var AnnotationType = sharedUtil.AnnotationType;
  31152. var Util = sharedUtil.Util;
  31153. var addLinkAttributes = displayDOMUtils.addLinkAttributes;
  31154. var LinkTarget = displayDOMUtils.LinkTarget;
  31155. var getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  31156. var warn = sharedUtil.warn;
  31157. var CustomStyle = displayDOMUtils.CustomStyle;
  31158. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31159. function AnnotationElementFactory() {
  31160. }
  31161. AnnotationElementFactory.prototype = {
  31162. create: function AnnotationElementFactory_create(parameters) {
  31163. var subtype = parameters.data.annotationType;
  31164. switch (subtype) {
  31165. case AnnotationType.LINK:
  31166. return new LinkAnnotationElement(parameters);
  31167. case AnnotationType.TEXT:
  31168. return new TextAnnotationElement(parameters);
  31169. case AnnotationType.WIDGET:
  31170. var fieldType = parameters.data.fieldType;
  31171. switch (fieldType) {
  31172. case 'Tx':
  31173. return new TextWidgetAnnotationElement(parameters);
  31174. case 'Ch':
  31175. return new ChoiceWidgetAnnotationElement(parameters);
  31176. }
  31177. return new WidgetAnnotationElement(parameters);
  31178. case AnnotationType.POPUP:
  31179. return new PopupAnnotationElement(parameters);
  31180. case AnnotationType.HIGHLIGHT:
  31181. return new HighlightAnnotationElement(parameters);
  31182. case AnnotationType.UNDERLINE:
  31183. return new UnderlineAnnotationElement(parameters);
  31184. case AnnotationType.SQUIGGLY:
  31185. return new SquigglyAnnotationElement(parameters);
  31186. case AnnotationType.STRIKEOUT:
  31187. return new StrikeOutAnnotationElement(parameters);
  31188. case AnnotationType.FILEATTACHMENT:
  31189. return new FileAttachmentAnnotationElement(parameters);
  31190. default:
  31191. return new AnnotationElement(parameters);
  31192. }
  31193. }
  31194. };
  31195. var AnnotationElement = function AnnotationElementClosure() {
  31196. function AnnotationElement(parameters, isRenderable) {
  31197. this.isRenderable = isRenderable || false;
  31198. this.data = parameters.data;
  31199. this.layer = parameters.layer;
  31200. this.page = parameters.page;
  31201. this.viewport = parameters.viewport;
  31202. this.linkService = parameters.linkService;
  31203. this.downloadManager = parameters.downloadManager;
  31204. this.imageResourcesPath = parameters.imageResourcesPath;
  31205. this.renderInteractiveForms = parameters.renderInteractiveForms;
  31206. if (isRenderable) {
  31207. this.container = this._createContainer();
  31208. }
  31209. }
  31210. AnnotationElement.prototype = {
  31211. _createContainer: function AnnotationElement_createContainer() {
  31212. var data = this.data, page = this.page, viewport = this.viewport;
  31213. var container = document.createElement('section');
  31214. var width = data.rect[2] - data.rect[0];
  31215. var height = data.rect[3] - data.rect[1];
  31216. container.setAttribute('data-annotation-id', data.id);
  31217. var rect = Util.normalizeRect([
  31218. data.rect[0],
  31219. page.view[3] - data.rect[1] + page.view[1],
  31220. data.rect[2],
  31221. page.view[3] - data.rect[3] + page.view[1]
  31222. ]);
  31223. CustomStyle.setProp('transform', container, 'matrix(' + viewport.transform.join(',') + ')');
  31224. CustomStyle.setProp('transformOrigin', container, -rect[0] + 'px ' + -rect[1] + 'px');
  31225. if (data.borderStyle.width > 0) {
  31226. container.style.borderWidth = data.borderStyle.width + 'px';
  31227. if (data.borderStyle.style !== AnnotationBorderStyleType.UNDERLINE) {
  31228. width = width - 2 * data.borderStyle.width;
  31229. height = height - 2 * data.borderStyle.width;
  31230. }
  31231. var horizontalRadius = data.borderStyle.horizontalCornerRadius;
  31232. var verticalRadius = data.borderStyle.verticalCornerRadius;
  31233. if (horizontalRadius > 0 || verticalRadius > 0) {
  31234. var radius = horizontalRadius + 'px / ' + verticalRadius + 'px';
  31235. CustomStyle.setProp('borderRadius', container, radius);
  31236. }
  31237. switch (data.borderStyle.style) {
  31238. case AnnotationBorderStyleType.SOLID:
  31239. container.style.borderStyle = 'solid';
  31240. break;
  31241. case AnnotationBorderStyleType.DASHED:
  31242. container.style.borderStyle = 'dashed';
  31243. break;
  31244. case AnnotationBorderStyleType.BEVELED:
  31245. warn('Unimplemented border style: beveled');
  31246. break;
  31247. case AnnotationBorderStyleType.INSET:
  31248. warn('Unimplemented border style: inset');
  31249. break;
  31250. case AnnotationBorderStyleType.UNDERLINE:
  31251. container.style.borderBottomStyle = 'solid';
  31252. break;
  31253. default:
  31254. break;
  31255. }
  31256. if (data.color) {
  31257. container.style.borderColor = Util.makeCssRgb(data.color[0] | 0, data.color[1] | 0, data.color[2] | 0);
  31258. } else {
  31259. container.style.borderWidth = 0;
  31260. }
  31261. }
  31262. container.style.left = rect[0] + 'px';
  31263. container.style.top = rect[1] + 'px';
  31264. container.style.width = width + 'px';
  31265. container.style.height = height + 'px';
  31266. return container;
  31267. },
  31268. _createPopup: function AnnotationElement_createPopup(container, trigger, data) {
  31269. if (!trigger) {
  31270. trigger = document.createElement('div');
  31271. trigger.style.height = container.style.height;
  31272. trigger.style.width = container.style.width;
  31273. container.appendChild(trigger);
  31274. }
  31275. var popupElement = new PopupElement({
  31276. container: container,
  31277. trigger: trigger,
  31278. color: data.color,
  31279. title: data.title,
  31280. contents: data.contents,
  31281. hideWrapper: true
  31282. });
  31283. var popup = popupElement.render();
  31284. popup.style.left = container.style.width;
  31285. container.appendChild(popup);
  31286. },
  31287. render: function AnnotationElement_render() {
  31288. throw new Error('Abstract method AnnotationElement.render called');
  31289. }
  31290. };
  31291. return AnnotationElement;
  31292. }();
  31293. var LinkAnnotationElement = function LinkAnnotationElementClosure() {
  31294. function LinkAnnotationElement(parameters) {
  31295. AnnotationElement.call(this, parameters, true);
  31296. }
  31297. Util.inherit(LinkAnnotationElement, AnnotationElement, {
  31298. render: function LinkAnnotationElement_render() {
  31299. this.container.className = 'linkAnnotation';
  31300. var link = document.createElement('a');
  31301. addLinkAttributes(link, {
  31302. url: this.data.url,
  31303. target: this.data.newWindow ? LinkTarget.BLANK : undefined
  31304. });
  31305. if (!this.data.url) {
  31306. if (this.data.action) {
  31307. this._bindNamedAction(link, this.data.action);
  31308. } else {
  31309. this._bindLink(link, this.data.dest);
  31310. }
  31311. }
  31312. this.container.appendChild(link);
  31313. return this.container;
  31314. },
  31315. _bindLink: function LinkAnnotationElement_bindLink(link, destination) {
  31316. var self = this;
  31317. link.href = this.linkService.getDestinationHash(destination);
  31318. link.onclick = function () {
  31319. if (destination) {
  31320. self.linkService.navigateTo(destination);
  31321. }
  31322. return false;
  31323. };
  31324. if (destination) {
  31325. link.className = 'internalLink';
  31326. }
  31327. },
  31328. _bindNamedAction: function LinkAnnotationElement_bindNamedAction(link, action) {
  31329. var self = this;
  31330. link.href = this.linkService.getAnchorUrl('');
  31331. link.onclick = function () {
  31332. self.linkService.executeNamedAction(action);
  31333. return false;
  31334. };
  31335. link.className = 'internalLink';
  31336. }
  31337. });
  31338. return LinkAnnotationElement;
  31339. }();
  31340. var TextAnnotationElement = function TextAnnotationElementClosure() {
  31341. function TextAnnotationElement(parameters) {
  31342. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31343. AnnotationElement.call(this, parameters, isRenderable);
  31344. }
  31345. Util.inherit(TextAnnotationElement, AnnotationElement, {
  31346. render: function TextAnnotationElement_render() {
  31347. this.container.className = 'textAnnotation';
  31348. var image = document.createElement('img');
  31349. image.style.height = this.container.style.height;
  31350. image.style.width = this.container.style.width;
  31351. image.src = this.imageResourcesPath + 'annotation-' + this.data.name.toLowerCase() + '.svg';
  31352. image.alt = '[{{type}} Annotation]';
  31353. image.dataset.l10nId = 'text_annotation_type';
  31354. image.dataset.l10nArgs = JSON.stringify({ type: this.data.name });
  31355. if (!this.data.hasPopup) {
  31356. this._createPopup(this.container, image, this.data);
  31357. }
  31358. this.container.appendChild(image);
  31359. return this.container;
  31360. }
  31361. });
  31362. return TextAnnotationElement;
  31363. }();
  31364. var WidgetAnnotationElement = function WidgetAnnotationElementClosure() {
  31365. function WidgetAnnotationElement(parameters, isRenderable) {
  31366. AnnotationElement.call(this, parameters, isRenderable);
  31367. }
  31368. Util.inherit(WidgetAnnotationElement, AnnotationElement, {
  31369. render: function WidgetAnnotationElement_render() {
  31370. return this.container;
  31371. }
  31372. });
  31373. return WidgetAnnotationElement;
  31374. }();
  31375. var TextWidgetAnnotationElement = function TextWidgetAnnotationElementClosure() {
  31376. var TEXT_ALIGNMENT = [
  31377. 'left',
  31378. 'center',
  31379. 'right'
  31380. ];
  31381. function TextWidgetAnnotationElement(parameters) {
  31382. var isRenderable = parameters.renderInteractiveForms || !parameters.data.hasAppearance && !!parameters.data.fieldValue;
  31383. WidgetAnnotationElement.call(this, parameters, isRenderable);
  31384. }
  31385. Util.inherit(TextWidgetAnnotationElement, WidgetAnnotationElement, {
  31386. render: function TextWidgetAnnotationElement_render() {
  31387. this.container.className = 'textWidgetAnnotation';
  31388. var element = null;
  31389. if (this.renderInteractiveForms) {
  31390. if (this.data.multiLine) {
  31391. element = document.createElement('textarea');
  31392. element.textContent = this.data.fieldValue;
  31393. } else {
  31394. element = document.createElement('input');
  31395. element.type = 'text';
  31396. element.setAttribute('value', this.data.fieldValue);
  31397. }
  31398. element.disabled = this.data.readOnly;
  31399. if (this.data.maxLen !== null) {
  31400. element.maxLength = this.data.maxLen;
  31401. }
  31402. if (this.data.comb) {
  31403. var fieldWidth = this.data.rect[2] - this.data.rect[0];
  31404. var combWidth = fieldWidth / this.data.maxLen;
  31405. element.classList.add('comb');
  31406. element.style.letterSpacing = 'calc(' + combWidth + 'px - 1ch)';
  31407. }
  31408. } else {
  31409. element = document.createElement('div');
  31410. element.textContent = this.data.fieldValue;
  31411. element.style.verticalAlign = 'middle';
  31412. element.style.display = 'table-cell';
  31413. var font = null;
  31414. if (this.data.fontRefName) {
  31415. font = this.page.commonObjs.getData(this.data.fontRefName);
  31416. }
  31417. this._setTextStyle(element, font);
  31418. }
  31419. if (this.data.textAlignment !== null) {
  31420. element.style.textAlign = TEXT_ALIGNMENT[this.data.textAlignment];
  31421. }
  31422. this.container.appendChild(element);
  31423. return this.container;
  31424. },
  31425. _setTextStyle: function TextWidgetAnnotationElement_setTextStyle(element, font) {
  31426. var style = element.style;
  31427. style.fontSize = this.data.fontSize + 'px';
  31428. style.direction = this.data.fontDirection < 0 ? 'rtl' : 'ltr';
  31429. if (!font) {
  31430. return;
  31431. }
  31432. style.fontWeight = font.black ? font.bold ? '900' : 'bold' : font.bold ? 'bold' : 'normal';
  31433. style.fontStyle = font.italic ? 'italic' : 'normal';
  31434. var fontFamily = font.loadedName ? '"' + font.loadedName + '", ' : '';
  31435. var fallbackName = font.fallbackName || 'Helvetica, sans-serif';
  31436. style.fontFamily = fontFamily + fallbackName;
  31437. }
  31438. });
  31439. return TextWidgetAnnotationElement;
  31440. }();
  31441. var ChoiceWidgetAnnotationElement = function ChoiceWidgetAnnotationElementClosure() {
  31442. function ChoiceWidgetAnnotationElement(parameters) {
  31443. WidgetAnnotationElement.call(this, parameters, parameters.renderInteractiveForms);
  31444. }
  31445. Util.inherit(ChoiceWidgetAnnotationElement, WidgetAnnotationElement, {
  31446. render: function ChoiceWidgetAnnotationElement_render() {
  31447. this.container.className = 'choiceWidgetAnnotation';
  31448. var selectElement = document.createElement('select');
  31449. selectElement.disabled = this.data.readOnly;
  31450. if (!this.data.combo) {
  31451. selectElement.size = this.data.options.length;
  31452. if (this.data.multiSelect) {
  31453. selectElement.multiple = true;
  31454. }
  31455. }
  31456. for (var i = 0, ii = this.data.options.length; i < ii; i++) {
  31457. var option = this.data.options[i];
  31458. var optionElement = document.createElement('option');
  31459. optionElement.textContent = option.displayValue;
  31460. optionElement.value = option.exportValue;
  31461. if (this.data.fieldValue.indexOf(option.displayValue) >= 0) {
  31462. optionElement.setAttribute('selected', true);
  31463. }
  31464. selectElement.appendChild(optionElement);
  31465. }
  31466. this.container.appendChild(selectElement);
  31467. return this.container;
  31468. }
  31469. });
  31470. return ChoiceWidgetAnnotationElement;
  31471. }();
  31472. var PopupAnnotationElement = function PopupAnnotationElementClosure() {
  31473. function PopupAnnotationElement(parameters) {
  31474. var isRenderable = !!(parameters.data.title || parameters.data.contents);
  31475. AnnotationElement.call(this, parameters, isRenderable);
  31476. }
  31477. Util.inherit(PopupAnnotationElement, AnnotationElement, {
  31478. render: function PopupAnnotationElement_render() {
  31479. this.container.className = 'popupAnnotation';
  31480. var selector = '[data-annotation-id="' + this.data.parentId + '"]';
  31481. var parentElement = this.layer.querySelector(selector);
  31482. if (!parentElement) {
  31483. return this.container;
  31484. }
  31485. var popup = new PopupElement({
  31486. container: this.container,
  31487. trigger: parentElement,
  31488. color: this.data.color,
  31489. title: this.data.title,
  31490. contents: this.data.contents
  31491. });
  31492. var parentLeft = parseFloat(parentElement.style.left);
  31493. var parentWidth = parseFloat(parentElement.style.width);
  31494. CustomStyle.setProp('transformOrigin', this.container, -(parentLeft + parentWidth) + 'px -' + parentElement.style.top);
  31495. this.container.style.left = parentLeft + parentWidth + 'px';
  31496. this.container.appendChild(popup.render());
  31497. return this.container;
  31498. }
  31499. });
  31500. return PopupAnnotationElement;
  31501. }();
  31502. var PopupElement = function PopupElementClosure() {
  31503. var BACKGROUND_ENLIGHT = 0.7;
  31504. function PopupElement(parameters) {
  31505. this.container = parameters.container;
  31506. this.trigger = parameters.trigger;
  31507. this.color = parameters.color;
  31508. this.title = parameters.title;
  31509. this.contents = parameters.contents;
  31510. this.hideWrapper = parameters.hideWrapper || false;
  31511. this.pinned = false;
  31512. }
  31513. PopupElement.prototype = {
  31514. render: function PopupElement_render() {
  31515. var wrapper = document.createElement('div');
  31516. wrapper.className = 'popupWrapper';
  31517. this.hideElement = this.hideWrapper ? wrapper : this.container;
  31518. this.hideElement.setAttribute('hidden', true);
  31519. var popup = document.createElement('div');
  31520. popup.className = 'popup';
  31521. var color = this.color;
  31522. if (color) {
  31523. var r = BACKGROUND_ENLIGHT * (255 - color[0]) + color[0];
  31524. var g = BACKGROUND_ENLIGHT * (255 - color[1]) + color[1];
  31525. var b = BACKGROUND_ENLIGHT * (255 - color[2]) + color[2];
  31526. popup.style.backgroundColor = Util.makeCssRgb(r | 0, g | 0, b | 0);
  31527. }
  31528. var contents = this._formatContents(this.contents);
  31529. var title = document.createElement('h1');
  31530. title.textContent = this.title;
  31531. this.trigger.addEventListener('click', this._toggle.bind(this));
  31532. this.trigger.addEventListener('mouseover', this._show.bind(this, false));
  31533. this.trigger.addEventListener('mouseout', this._hide.bind(this, false));
  31534. popup.addEventListener('click', this._hide.bind(this, true));
  31535. popup.appendChild(title);
  31536. popup.appendChild(contents);
  31537. wrapper.appendChild(popup);
  31538. return wrapper;
  31539. },
  31540. _formatContents: function PopupElement_formatContents(contents) {
  31541. var p = document.createElement('p');
  31542. var lines = contents.split(/(?:\r\n?|\n)/);
  31543. for (var i = 0, ii = lines.length; i < ii; ++i) {
  31544. var line = lines[i];
  31545. p.appendChild(document.createTextNode(line));
  31546. if (i < ii - 1) {
  31547. p.appendChild(document.createElement('br'));
  31548. }
  31549. }
  31550. return p;
  31551. },
  31552. _toggle: function PopupElement_toggle() {
  31553. if (this.pinned) {
  31554. this._hide(true);
  31555. } else {
  31556. this._show(true);
  31557. }
  31558. },
  31559. _show: function PopupElement_show(pin) {
  31560. if (pin) {
  31561. this.pinned = true;
  31562. }
  31563. if (this.hideElement.hasAttribute('hidden')) {
  31564. this.hideElement.removeAttribute('hidden');
  31565. this.container.style.zIndex += 1;
  31566. }
  31567. },
  31568. _hide: function PopupElement_hide(unpin) {
  31569. if (unpin) {
  31570. this.pinned = false;
  31571. }
  31572. if (!this.hideElement.hasAttribute('hidden') && !this.pinned) {
  31573. this.hideElement.setAttribute('hidden', true);
  31574. this.container.style.zIndex -= 1;
  31575. }
  31576. }
  31577. };
  31578. return PopupElement;
  31579. }();
  31580. var HighlightAnnotationElement = function HighlightAnnotationElementClosure() {
  31581. function HighlightAnnotationElement(parameters) {
  31582. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31583. AnnotationElement.call(this, parameters, isRenderable);
  31584. }
  31585. Util.inherit(HighlightAnnotationElement, AnnotationElement, {
  31586. render: function HighlightAnnotationElement_render() {
  31587. this.container.className = 'highlightAnnotation';
  31588. if (!this.data.hasPopup) {
  31589. this._createPopup(this.container, null, this.data);
  31590. }
  31591. return this.container;
  31592. }
  31593. });
  31594. return HighlightAnnotationElement;
  31595. }();
  31596. var UnderlineAnnotationElement = function UnderlineAnnotationElementClosure() {
  31597. function UnderlineAnnotationElement(parameters) {
  31598. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31599. AnnotationElement.call(this, parameters, isRenderable);
  31600. }
  31601. Util.inherit(UnderlineAnnotationElement, AnnotationElement, {
  31602. render: function UnderlineAnnotationElement_render() {
  31603. this.container.className = 'underlineAnnotation';
  31604. if (!this.data.hasPopup) {
  31605. this._createPopup(this.container, null, this.data);
  31606. }
  31607. return this.container;
  31608. }
  31609. });
  31610. return UnderlineAnnotationElement;
  31611. }();
  31612. var SquigglyAnnotationElement = function SquigglyAnnotationElementClosure() {
  31613. function SquigglyAnnotationElement(parameters) {
  31614. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31615. AnnotationElement.call(this, parameters, isRenderable);
  31616. }
  31617. Util.inherit(SquigglyAnnotationElement, AnnotationElement, {
  31618. render: function SquigglyAnnotationElement_render() {
  31619. this.container.className = 'squigglyAnnotation';
  31620. if (!this.data.hasPopup) {
  31621. this._createPopup(this.container, null, this.data);
  31622. }
  31623. return this.container;
  31624. }
  31625. });
  31626. return SquigglyAnnotationElement;
  31627. }();
  31628. var StrikeOutAnnotationElement = function StrikeOutAnnotationElementClosure() {
  31629. function StrikeOutAnnotationElement(parameters) {
  31630. var isRenderable = !!(parameters.data.hasPopup || parameters.data.title || parameters.data.contents);
  31631. AnnotationElement.call(this, parameters, isRenderable);
  31632. }
  31633. Util.inherit(StrikeOutAnnotationElement, AnnotationElement, {
  31634. render: function StrikeOutAnnotationElement_render() {
  31635. this.container.className = 'strikeoutAnnotation';
  31636. if (!this.data.hasPopup) {
  31637. this._createPopup(this.container, null, this.data);
  31638. }
  31639. return this.container;
  31640. }
  31641. });
  31642. return StrikeOutAnnotationElement;
  31643. }();
  31644. var FileAttachmentAnnotationElement = function FileAttachmentAnnotationElementClosure() {
  31645. function FileAttachmentAnnotationElement(parameters) {
  31646. AnnotationElement.call(this, parameters, true);
  31647. this.filename = getFilenameFromUrl(parameters.data.file.filename);
  31648. this.content = parameters.data.file.content;
  31649. }
  31650. Util.inherit(FileAttachmentAnnotationElement, AnnotationElement, {
  31651. render: function FileAttachmentAnnotationElement_render() {
  31652. this.container.className = 'fileAttachmentAnnotation';
  31653. var trigger = document.createElement('div');
  31654. trigger.style.height = this.container.style.height;
  31655. trigger.style.width = this.container.style.width;
  31656. trigger.addEventListener('dblclick', this._download.bind(this));
  31657. if (!this.data.hasPopup && (this.data.title || this.data.contents)) {
  31658. this._createPopup(this.container, trigger, this.data);
  31659. }
  31660. this.container.appendChild(trigger);
  31661. return this.container;
  31662. },
  31663. _download: function FileAttachmentAnnotationElement_download() {
  31664. if (!this.downloadManager) {
  31665. warn('Download cannot be started due to unavailable download manager');
  31666. return;
  31667. }
  31668. this.downloadManager.downloadData(this.content, this.filename, '');
  31669. }
  31670. });
  31671. return FileAttachmentAnnotationElement;
  31672. }();
  31673. var AnnotationLayer = function AnnotationLayerClosure() {
  31674. return {
  31675. render: function AnnotationLayer_render(parameters) {
  31676. var annotationElementFactory = new AnnotationElementFactory();
  31677. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31678. var data = parameters.annotations[i];
  31679. if (!data) {
  31680. continue;
  31681. }
  31682. var properties = {
  31683. data: data,
  31684. layer: parameters.div,
  31685. page: parameters.page,
  31686. viewport: parameters.viewport,
  31687. linkService: parameters.linkService,
  31688. downloadManager: parameters.downloadManager,
  31689. imageResourcesPath: parameters.imageResourcesPath || getDefaultSetting('imageResourcesPath'),
  31690. renderInteractiveForms: parameters.renderInteractiveForms || false
  31691. };
  31692. var element = annotationElementFactory.create(properties);
  31693. if (element.isRenderable) {
  31694. parameters.div.appendChild(element.render());
  31695. }
  31696. }
  31697. },
  31698. update: function AnnotationLayer_update(parameters) {
  31699. for (var i = 0, ii = parameters.annotations.length; i < ii; i++) {
  31700. var data = parameters.annotations[i];
  31701. var element = parameters.div.querySelector('[data-annotation-id="' + data.id + '"]');
  31702. if (element) {
  31703. CustomStyle.setProp('transform', element, 'matrix(' + parameters.viewport.transform.join(',') + ')');
  31704. }
  31705. }
  31706. parameters.div.removeAttribute('hidden');
  31707. }
  31708. };
  31709. }();
  31710. exports.AnnotationLayer = AnnotationLayer;
  31711. }));
  31712. (function (root, factory) {
  31713. factory(root.pdfjsDisplayTextLayer = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  31714. }(this, function (exports, sharedUtil, displayDOMUtils) {
  31715. var Util = sharedUtil.Util;
  31716. var createPromiseCapability = sharedUtil.createPromiseCapability;
  31717. var CustomStyle = displayDOMUtils.CustomStyle;
  31718. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  31719. var renderTextLayer = function renderTextLayerClosure() {
  31720. var MAX_TEXT_DIVS_TO_RENDER = 100000;
  31721. var NonWhitespaceRegexp = /\S/;
  31722. function isAllWhitespace(str) {
  31723. return !NonWhitespaceRegexp.test(str);
  31724. }
  31725. var styleBuf = [
  31726. 'left: ',
  31727. 0,
  31728. 'px; top: ',
  31729. 0,
  31730. 'px; font-size: ',
  31731. 0,
  31732. 'px; font-family: ',
  31733. '',
  31734. ';'
  31735. ];
  31736. function appendText(task, geom, styles) {
  31737. var textDiv = document.createElement('div');
  31738. var textDivProperties = {
  31739. style: null,
  31740. angle: 0,
  31741. canvasWidth: 0,
  31742. isWhitespace: false,
  31743. originalTransform: null,
  31744. paddingBottom: 0,
  31745. paddingLeft: 0,
  31746. paddingRight: 0,
  31747. paddingTop: 0,
  31748. scale: 1
  31749. };
  31750. task._textDivs.push(textDiv);
  31751. if (isAllWhitespace(geom.str)) {
  31752. textDivProperties.isWhitespace = true;
  31753. task._textDivProperties.set(textDiv, textDivProperties);
  31754. return;
  31755. }
  31756. var tx = Util.transform(task._viewport.transform, geom.transform);
  31757. var angle = Math.atan2(tx[1], tx[0]);
  31758. var style = styles[geom.fontName];
  31759. if (style.vertical) {
  31760. angle += Math.PI / 2;
  31761. }
  31762. var fontHeight = Math.sqrt(tx[2] * tx[2] + tx[3] * tx[3]);
  31763. var fontAscent = fontHeight;
  31764. if (style.ascent) {
  31765. fontAscent = style.ascent * fontAscent;
  31766. } else if (style.descent) {
  31767. fontAscent = (1 + style.descent) * fontAscent;
  31768. }
  31769. var left;
  31770. var top;
  31771. if (angle === 0) {
  31772. left = tx[4];
  31773. top = tx[5] - fontAscent;
  31774. } else {
  31775. left = tx[4] + fontAscent * Math.sin(angle);
  31776. top = tx[5] - fontAscent * Math.cos(angle);
  31777. }
  31778. styleBuf[1] = left;
  31779. styleBuf[3] = top;
  31780. styleBuf[5] = fontHeight;
  31781. styleBuf[7] = style.fontFamily;
  31782. textDivProperties.style = styleBuf.join('');
  31783. textDiv.setAttribute('style', textDivProperties.style);
  31784. textDiv.textContent = geom.str;
  31785. if (getDefaultSetting('pdfBug')) {
  31786. textDiv.dataset.fontName = geom.fontName;
  31787. }
  31788. if (angle !== 0) {
  31789. textDivProperties.angle = angle * (180 / Math.PI);
  31790. }
  31791. if (geom.str.length > 1) {
  31792. if (style.vertical) {
  31793. textDivProperties.canvasWidth = geom.height * task._viewport.scale;
  31794. } else {
  31795. textDivProperties.canvasWidth = geom.width * task._viewport.scale;
  31796. }
  31797. }
  31798. task._textDivProperties.set(textDiv, textDivProperties);
  31799. if (task._enhanceTextSelection) {
  31800. var angleCos = 1, angleSin = 0;
  31801. if (angle !== 0) {
  31802. angleCos = Math.cos(angle);
  31803. angleSin = Math.sin(angle);
  31804. }
  31805. var divWidth = (style.vertical ? geom.height : geom.width) * task._viewport.scale;
  31806. var divHeight = fontHeight;
  31807. var m, b;
  31808. if (angle !== 0) {
  31809. m = [
  31810. angleCos,
  31811. angleSin,
  31812. -angleSin,
  31813. angleCos,
  31814. left,
  31815. top
  31816. ];
  31817. b = Util.getAxialAlignedBoundingBox([
  31818. 0,
  31819. 0,
  31820. divWidth,
  31821. divHeight
  31822. ], m);
  31823. } else {
  31824. b = [
  31825. left,
  31826. top,
  31827. left + divWidth,
  31828. top + divHeight
  31829. ];
  31830. }
  31831. task._bounds.push({
  31832. left: b[0],
  31833. top: b[1],
  31834. right: b[2],
  31835. bottom: b[3],
  31836. div: textDiv,
  31837. size: [
  31838. divWidth,
  31839. divHeight
  31840. ],
  31841. m: m
  31842. });
  31843. }
  31844. }
  31845. function render(task) {
  31846. if (task._canceled) {
  31847. return;
  31848. }
  31849. var textLayerFrag = task._container;
  31850. var textDivs = task._textDivs;
  31851. var capability = task._capability;
  31852. var textDivsLength = textDivs.length;
  31853. if (textDivsLength > MAX_TEXT_DIVS_TO_RENDER) {
  31854. task._renderingDone = true;
  31855. capability.resolve();
  31856. return;
  31857. }
  31858. var canvas = document.createElement('canvas');
  31859. var ctx = canvas.getContext('2d', { alpha: false });
  31860. var lastFontSize;
  31861. var lastFontFamily;
  31862. for (var i = 0; i < textDivsLength; i++) {
  31863. var textDiv = textDivs[i];
  31864. var textDivProperties = task._textDivProperties.get(textDiv);
  31865. if (textDivProperties.isWhitespace) {
  31866. continue;
  31867. }
  31868. var fontSize = textDiv.style.fontSize;
  31869. var fontFamily = textDiv.style.fontFamily;
  31870. if (fontSize !== lastFontSize || fontFamily !== lastFontFamily) {
  31871. ctx.font = fontSize + ' ' + fontFamily;
  31872. lastFontSize = fontSize;
  31873. lastFontFamily = fontFamily;
  31874. }
  31875. var width = ctx.measureText(textDiv.textContent).width;
  31876. textLayerFrag.appendChild(textDiv);
  31877. var transform = '';
  31878. if (textDivProperties.canvasWidth !== 0 && width > 0) {
  31879. textDivProperties.scale = textDivProperties.canvasWidth / width;
  31880. transform = 'scaleX(' + textDivProperties.scale + ')';
  31881. }
  31882. if (textDivProperties.angle !== 0) {
  31883. transform = 'rotate(' + textDivProperties.angle + 'deg) ' + transform;
  31884. }
  31885. if (transform !== '') {
  31886. textDivProperties.originalTransform = transform;
  31887. CustomStyle.setProp('transform', textDiv, transform);
  31888. }
  31889. task._textDivProperties.set(textDiv, textDivProperties);
  31890. }
  31891. task._renderingDone = true;
  31892. capability.resolve();
  31893. }
  31894. function expand(task) {
  31895. var bounds = task._bounds;
  31896. var viewport = task._viewport;
  31897. var expanded = expandBounds(viewport.width, viewport.height, bounds);
  31898. for (var i = 0; i < expanded.length; i++) {
  31899. var div = bounds[i].div;
  31900. var divProperties = task._textDivProperties.get(div);
  31901. if (divProperties.angle === 0) {
  31902. divProperties.paddingLeft = bounds[i].left - expanded[i].left;
  31903. divProperties.paddingTop = bounds[i].top - expanded[i].top;
  31904. divProperties.paddingRight = expanded[i].right - bounds[i].right;
  31905. divProperties.paddingBottom = expanded[i].bottom - bounds[i].bottom;
  31906. task._textDivProperties.set(div, divProperties);
  31907. continue;
  31908. }
  31909. var e = expanded[i], b = bounds[i];
  31910. var m = b.m, c = m[0], s = m[1];
  31911. var points = [
  31912. [
  31913. 0,
  31914. 0
  31915. ],
  31916. [
  31917. 0,
  31918. b.size[1]
  31919. ],
  31920. [
  31921. b.size[0],
  31922. 0
  31923. ],
  31924. b.size
  31925. ];
  31926. var ts = new Float64Array(64);
  31927. points.forEach(function (p, i) {
  31928. var t = Util.applyTransform(p, m);
  31929. ts[i + 0] = c && (e.left - t[0]) / c;
  31930. ts[i + 4] = s && (e.top - t[1]) / s;
  31931. ts[i + 8] = c && (e.right - t[0]) / c;
  31932. ts[i + 12] = s && (e.bottom - t[1]) / s;
  31933. ts[i + 16] = s && (e.left - t[0]) / -s;
  31934. ts[i + 20] = c && (e.top - t[1]) / c;
  31935. ts[i + 24] = s && (e.right - t[0]) / -s;
  31936. ts[i + 28] = c && (e.bottom - t[1]) / c;
  31937. ts[i + 32] = c && (e.left - t[0]) / -c;
  31938. ts[i + 36] = s && (e.top - t[1]) / -s;
  31939. ts[i + 40] = c && (e.right - t[0]) / -c;
  31940. ts[i + 44] = s && (e.bottom - t[1]) / -s;
  31941. ts[i + 48] = s && (e.left - t[0]) / s;
  31942. ts[i + 52] = c && (e.top - t[1]) / -c;
  31943. ts[i + 56] = s && (e.right - t[0]) / s;
  31944. ts[i + 60] = c && (e.bottom - t[1]) / -c;
  31945. });
  31946. var findPositiveMin = function (ts, offset, count) {
  31947. var result = 0;
  31948. for (var i = 0; i < count; i++) {
  31949. var t = ts[offset++];
  31950. if (t > 0) {
  31951. result = result ? Math.min(t, result) : t;
  31952. }
  31953. }
  31954. return result;
  31955. };
  31956. var boxScale = 1 + Math.min(Math.abs(c), Math.abs(s));
  31957. divProperties.paddingLeft = findPositiveMin(ts, 32, 16) / boxScale;
  31958. divProperties.paddingTop = findPositiveMin(ts, 48, 16) / boxScale;
  31959. divProperties.paddingRight = findPositiveMin(ts, 0, 16) / boxScale;
  31960. divProperties.paddingBottom = findPositiveMin(ts, 16, 16) / boxScale;
  31961. task._textDivProperties.set(div, divProperties);
  31962. }
  31963. }
  31964. function expandBounds(width, height, boxes) {
  31965. var bounds = boxes.map(function (box, i) {
  31966. return {
  31967. x1: box.left,
  31968. y1: box.top,
  31969. x2: box.right,
  31970. y2: box.bottom,
  31971. index: i,
  31972. x1New: undefined,
  31973. x2New: undefined
  31974. };
  31975. });
  31976. expandBoundsLTR(width, bounds);
  31977. var expanded = new Array(boxes.length);
  31978. bounds.forEach(function (b) {
  31979. var i = b.index;
  31980. expanded[i] = {
  31981. left: b.x1New,
  31982. top: 0,
  31983. right: b.x2New,
  31984. bottom: 0
  31985. };
  31986. });
  31987. boxes.map(function (box, i) {
  31988. var e = expanded[i], b = bounds[i];
  31989. b.x1 = box.top;
  31990. b.y1 = width - e.right;
  31991. b.x2 = box.bottom;
  31992. b.y2 = width - e.left;
  31993. b.index = i;
  31994. b.x1New = undefined;
  31995. b.x2New = undefined;
  31996. });
  31997. expandBoundsLTR(height, bounds);
  31998. bounds.forEach(function (b) {
  31999. var i = b.index;
  32000. expanded[i].top = b.x1New;
  32001. expanded[i].bottom = b.x2New;
  32002. });
  32003. return expanded;
  32004. }
  32005. function expandBoundsLTR(width, bounds) {
  32006. bounds.sort(function (a, b) {
  32007. return a.x1 - b.x1 || a.index - b.index;
  32008. });
  32009. var fakeBoundary = {
  32010. x1: -Infinity,
  32011. y1: -Infinity,
  32012. x2: 0,
  32013. y2: Infinity,
  32014. index: -1,
  32015. x1New: 0,
  32016. x2New: 0
  32017. };
  32018. var horizon = [{
  32019. start: -Infinity,
  32020. end: Infinity,
  32021. boundary: fakeBoundary
  32022. }];
  32023. bounds.forEach(function (boundary) {
  32024. var i = 0;
  32025. while (i < horizon.length && horizon[i].end <= boundary.y1) {
  32026. i++;
  32027. }
  32028. var j = horizon.length - 1;
  32029. while (j >= 0 && horizon[j].start >= boundary.y2) {
  32030. j--;
  32031. }
  32032. var horizonPart, affectedBoundary;
  32033. var q, k, maxXNew = -Infinity;
  32034. for (q = i; q <= j; q++) {
  32035. horizonPart = horizon[q];
  32036. affectedBoundary = horizonPart.boundary;
  32037. var xNew;
  32038. if (affectedBoundary.x2 > boundary.x1) {
  32039. xNew = affectedBoundary.index > boundary.index ? affectedBoundary.x1New : boundary.x1;
  32040. } else if (affectedBoundary.x2New === undefined) {
  32041. xNew = (affectedBoundary.x2 + boundary.x1) / 2;
  32042. } else {
  32043. xNew = affectedBoundary.x2New;
  32044. }
  32045. if (xNew > maxXNew) {
  32046. maxXNew = xNew;
  32047. }
  32048. }
  32049. boundary.x1New = maxXNew;
  32050. for (q = i; q <= j; q++) {
  32051. horizonPart = horizon[q];
  32052. affectedBoundary = horizonPart.boundary;
  32053. if (affectedBoundary.x2New === undefined) {
  32054. if (affectedBoundary.x2 > boundary.x1) {
  32055. if (affectedBoundary.index > boundary.index) {
  32056. affectedBoundary.x2New = affectedBoundary.x2;
  32057. }
  32058. } else {
  32059. affectedBoundary.x2New = maxXNew;
  32060. }
  32061. } else if (affectedBoundary.x2New > maxXNew) {
  32062. affectedBoundary.x2New = Math.max(maxXNew, affectedBoundary.x2);
  32063. }
  32064. }
  32065. var changedHorizon = [], lastBoundary = null;
  32066. for (q = i; q <= j; q++) {
  32067. horizonPart = horizon[q];
  32068. affectedBoundary = horizonPart.boundary;
  32069. var useBoundary = affectedBoundary.x2 > boundary.x2 ? affectedBoundary : boundary;
  32070. if (lastBoundary === useBoundary) {
  32071. changedHorizon[changedHorizon.length - 1].end = horizonPart.end;
  32072. } else {
  32073. changedHorizon.push({
  32074. start: horizonPart.start,
  32075. end: horizonPart.end,
  32076. boundary: useBoundary
  32077. });
  32078. lastBoundary = useBoundary;
  32079. }
  32080. }
  32081. if (horizon[i].start < boundary.y1) {
  32082. changedHorizon[0].start = boundary.y1;
  32083. changedHorizon.unshift({
  32084. start: horizon[i].start,
  32085. end: boundary.y1,
  32086. boundary: horizon[i].boundary
  32087. });
  32088. }
  32089. if (boundary.y2 < horizon[j].end) {
  32090. changedHorizon[changedHorizon.length - 1].end = boundary.y2;
  32091. changedHorizon.push({
  32092. start: boundary.y2,
  32093. end: horizon[j].end,
  32094. boundary: horizon[j].boundary
  32095. });
  32096. }
  32097. for (q = i; q <= j; q++) {
  32098. horizonPart = horizon[q];
  32099. affectedBoundary = horizonPart.boundary;
  32100. if (affectedBoundary.x2New !== undefined) {
  32101. continue;
  32102. }
  32103. var used = false;
  32104. for (k = i - 1; !used && k >= 0 && horizon[k].start >= affectedBoundary.y1; k--) {
  32105. used = horizon[k].boundary === affectedBoundary;
  32106. }
  32107. for (k = j + 1; !used && k < horizon.length && horizon[k].end <= affectedBoundary.y2; k++) {
  32108. used = horizon[k].boundary === affectedBoundary;
  32109. }
  32110. for (k = 0; !used && k < changedHorizon.length; k++) {
  32111. used = changedHorizon[k].boundary === affectedBoundary;
  32112. }
  32113. if (!used) {
  32114. affectedBoundary.x2New = maxXNew;
  32115. }
  32116. }
  32117. Array.prototype.splice.apply(horizon, [
  32118. i,
  32119. j - i + 1
  32120. ].concat(changedHorizon));
  32121. });
  32122. horizon.forEach(function (horizonPart) {
  32123. var affectedBoundary = horizonPart.boundary;
  32124. if (affectedBoundary.x2New === undefined) {
  32125. affectedBoundary.x2New = Math.max(width, affectedBoundary.x2);
  32126. }
  32127. });
  32128. }
  32129. function TextLayerRenderTask(textContent, container, viewport, textDivs, enhanceTextSelection) {
  32130. this._textContent = textContent;
  32131. this._container = container;
  32132. this._viewport = viewport;
  32133. this._textDivs = textDivs || [];
  32134. this._textDivProperties = new WeakMap();
  32135. this._renderingDone = false;
  32136. this._canceled = false;
  32137. this._capability = createPromiseCapability();
  32138. this._renderTimer = null;
  32139. this._bounds = [];
  32140. this._enhanceTextSelection = !!enhanceTextSelection;
  32141. }
  32142. TextLayerRenderTask.prototype = {
  32143. get promise() {
  32144. return this._capability.promise;
  32145. },
  32146. cancel: function TextLayer_cancel() {
  32147. this._canceled = true;
  32148. if (this._renderTimer !== null) {
  32149. clearTimeout(this._renderTimer);
  32150. this._renderTimer = null;
  32151. }
  32152. this._capability.reject('canceled');
  32153. },
  32154. _render: function TextLayer_render(timeout) {
  32155. var textItems = this._textContent.items;
  32156. var textStyles = this._textContent.styles;
  32157. for (var i = 0, len = textItems.length; i < len; i++) {
  32158. appendText(this, textItems[i], textStyles);
  32159. }
  32160. if (!timeout) {
  32161. render(this);
  32162. } else {
  32163. var self = this;
  32164. this._renderTimer = setTimeout(function () {
  32165. render(self);
  32166. self._renderTimer = null;
  32167. }, timeout);
  32168. }
  32169. },
  32170. expandTextDivs: function TextLayer_expandTextDivs(expandDivs) {
  32171. if (!this._enhanceTextSelection || !this._renderingDone) {
  32172. return;
  32173. }
  32174. if (this._bounds !== null) {
  32175. expand(this);
  32176. this._bounds = null;
  32177. }
  32178. for (var i = 0, ii = this._textDivs.length; i < ii; i++) {
  32179. var div = this._textDivs[i];
  32180. var divProperties = this._textDivProperties.get(div);
  32181. if (divProperties.isWhitespace) {
  32182. continue;
  32183. }
  32184. if (expandDivs) {
  32185. var transform = '', padding = '';
  32186. if (divProperties.scale !== 1) {
  32187. transform = 'scaleX(' + divProperties.scale + ')';
  32188. }
  32189. if (divProperties.angle !== 0) {
  32190. transform = 'rotate(' + divProperties.angle + 'deg) ' + transform;
  32191. }
  32192. if (divProperties.paddingLeft !== 0) {
  32193. padding += ' padding-left: ' + divProperties.paddingLeft / divProperties.scale + 'px;';
  32194. transform += ' translateX(' + -divProperties.paddingLeft / divProperties.scale + 'px)';
  32195. }
  32196. if (divProperties.paddingTop !== 0) {
  32197. padding += ' padding-top: ' + divProperties.paddingTop + 'px;';
  32198. transform += ' translateY(' + -divProperties.paddingTop + 'px)';
  32199. }
  32200. if (divProperties.paddingRight !== 0) {
  32201. padding += ' padding-right: ' + divProperties.paddingRight / divProperties.scale + 'px;';
  32202. }
  32203. if (divProperties.paddingBottom !== 0) {
  32204. padding += ' padding-bottom: ' + divProperties.paddingBottom + 'px;';
  32205. }
  32206. if (padding !== '') {
  32207. div.setAttribute('style', divProperties.style + padding);
  32208. }
  32209. if (transform !== '') {
  32210. CustomStyle.setProp('transform', div, transform);
  32211. }
  32212. } else {
  32213. div.style.padding = 0;
  32214. CustomStyle.setProp('transform', div, divProperties.originalTransform || '');
  32215. }
  32216. }
  32217. }
  32218. };
  32219. function renderTextLayer(renderParameters) {
  32220. var task = new TextLayerRenderTask(renderParameters.textContent, renderParameters.container, renderParameters.viewport, renderParameters.textDivs, renderParameters.enhanceTextSelection);
  32221. task._render(renderParameters.timeout);
  32222. return task;
  32223. }
  32224. return renderTextLayer;
  32225. }();
  32226. exports.renderTextLayer = renderTextLayer;
  32227. }));
  32228. (function (root, factory) {
  32229. factory(root.pdfjsDisplayWebGL = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils);
  32230. }(this, function (exports, sharedUtil, displayDOMUtils) {
  32231. var shadow = sharedUtil.shadow;
  32232. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  32233. var WebGLUtils = function WebGLUtilsClosure() {
  32234. function loadShader(gl, code, shaderType) {
  32235. var shader = gl.createShader(shaderType);
  32236. gl.shaderSource(shader, code);
  32237. gl.compileShader(shader);
  32238. var compiled = gl.getShaderParameter(shader, gl.COMPILE_STATUS);
  32239. if (!compiled) {
  32240. var errorMsg = gl.getShaderInfoLog(shader);
  32241. throw new Error('Error during shader compilation: ' + errorMsg);
  32242. }
  32243. return shader;
  32244. }
  32245. function createVertexShader(gl, code) {
  32246. return loadShader(gl, code, gl.VERTEX_SHADER);
  32247. }
  32248. function createFragmentShader(gl, code) {
  32249. return loadShader(gl, code, gl.FRAGMENT_SHADER);
  32250. }
  32251. function createProgram(gl, shaders) {
  32252. var program = gl.createProgram();
  32253. for (var i = 0, ii = shaders.length; i < ii; ++i) {
  32254. gl.attachShader(program, shaders[i]);
  32255. }
  32256. gl.linkProgram(program);
  32257. var linked = gl.getProgramParameter(program, gl.LINK_STATUS);
  32258. if (!linked) {
  32259. var errorMsg = gl.getProgramInfoLog(program);
  32260. throw new Error('Error during program linking: ' + errorMsg);
  32261. }
  32262. return program;
  32263. }
  32264. function createTexture(gl, image, textureId) {
  32265. gl.activeTexture(textureId);
  32266. var texture = gl.createTexture();
  32267. gl.bindTexture(gl.TEXTURE_2D, texture);
  32268. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32269. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32270. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  32271. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  32272. gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, image);
  32273. return texture;
  32274. }
  32275. var currentGL, currentCanvas;
  32276. function generateGL() {
  32277. if (currentGL) {
  32278. return;
  32279. }
  32280. currentCanvas = document.createElement('canvas');
  32281. currentGL = currentCanvas.getContext('webgl', { premultipliedalpha: false });
  32282. }
  32283. var smaskVertexShaderCode = '\
  32284. attribute vec2 a_position; \
  32285. attribute vec2 a_texCoord; \
  32286. \
  32287. uniform vec2 u_resolution; \
  32288. \
  32289. varying vec2 v_texCoord; \
  32290. \
  32291. void main() { \
  32292. vec2 clipSpace = (a_position / u_resolution) * 2.0 - 1.0; \
  32293. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32294. \
  32295. v_texCoord = a_texCoord; \
  32296. } ';
  32297. var smaskFragmentShaderCode = '\
  32298. precision mediump float; \
  32299. \
  32300. uniform vec4 u_backdrop; \
  32301. uniform int u_subtype; \
  32302. uniform sampler2D u_image; \
  32303. uniform sampler2D u_mask; \
  32304. \
  32305. varying vec2 v_texCoord; \
  32306. \
  32307. void main() { \
  32308. vec4 imageColor = texture2D(u_image, v_texCoord); \
  32309. vec4 maskColor = texture2D(u_mask, v_texCoord); \
  32310. if (u_backdrop.a > 0.0) { \
  32311. maskColor.rgb = maskColor.rgb * maskColor.a + \
  32312. u_backdrop.rgb * (1.0 - maskColor.a); \
  32313. } \
  32314. float lum; \
  32315. if (u_subtype == 0) { \
  32316. lum = maskColor.a; \
  32317. } else { \
  32318. lum = maskColor.r * 0.3 + maskColor.g * 0.59 + \
  32319. maskColor.b * 0.11; \
  32320. } \
  32321. imageColor.a *= lum; \
  32322. imageColor.rgb *= imageColor.a; \
  32323. gl_FragColor = imageColor; \
  32324. } ';
  32325. var smaskCache = null;
  32326. function initSmaskGL() {
  32327. var canvas, gl;
  32328. generateGL();
  32329. canvas = currentCanvas;
  32330. currentCanvas = null;
  32331. gl = currentGL;
  32332. currentGL = null;
  32333. var vertexShader = createVertexShader(gl, smaskVertexShaderCode);
  32334. var fragmentShader = createFragmentShader(gl, smaskFragmentShaderCode);
  32335. var program = createProgram(gl, [
  32336. vertexShader,
  32337. fragmentShader
  32338. ]);
  32339. gl.useProgram(program);
  32340. var cache = {};
  32341. cache.gl = gl;
  32342. cache.canvas = canvas;
  32343. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32344. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32345. cache.backdropLocation = gl.getUniformLocation(program, 'u_backdrop');
  32346. cache.subtypeLocation = gl.getUniformLocation(program, 'u_subtype');
  32347. var texCoordLocation = gl.getAttribLocation(program, 'a_texCoord');
  32348. var texLayerLocation = gl.getUniformLocation(program, 'u_image');
  32349. var texMaskLocation = gl.getUniformLocation(program, 'u_mask');
  32350. var texCoordBuffer = gl.createBuffer();
  32351. gl.bindBuffer(gl.ARRAY_BUFFER, texCoordBuffer);
  32352. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32353. 0.0,
  32354. 0.0,
  32355. 1.0,
  32356. 0.0,
  32357. 0.0,
  32358. 1.0,
  32359. 0.0,
  32360. 1.0,
  32361. 1.0,
  32362. 0.0,
  32363. 1.0,
  32364. 1.0
  32365. ]), gl.STATIC_DRAW);
  32366. gl.enableVertexAttribArray(texCoordLocation);
  32367. gl.vertexAttribPointer(texCoordLocation, 2, gl.FLOAT, false, 0, 0);
  32368. gl.uniform1i(texLayerLocation, 0);
  32369. gl.uniform1i(texMaskLocation, 1);
  32370. smaskCache = cache;
  32371. }
  32372. function composeSMask(layer, mask, properties) {
  32373. var width = layer.width, height = layer.height;
  32374. if (!smaskCache) {
  32375. initSmaskGL();
  32376. }
  32377. var cache = smaskCache, canvas = cache.canvas, gl = cache.gl;
  32378. canvas.width = width;
  32379. canvas.height = height;
  32380. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32381. gl.uniform2f(cache.resolutionLocation, width, height);
  32382. if (properties.backdrop) {
  32383. gl.uniform4f(cache.resolutionLocation, properties.backdrop[0], properties.backdrop[1], properties.backdrop[2], 1);
  32384. } else {
  32385. gl.uniform4f(cache.resolutionLocation, 0, 0, 0, 0);
  32386. }
  32387. gl.uniform1i(cache.subtypeLocation, properties.subtype === 'Luminosity' ? 1 : 0);
  32388. var texture = createTexture(gl, layer, gl.TEXTURE0);
  32389. var maskTexture = createTexture(gl, mask, gl.TEXTURE1);
  32390. var buffer = gl.createBuffer();
  32391. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  32392. gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
  32393. 0,
  32394. 0,
  32395. width,
  32396. 0,
  32397. 0,
  32398. height,
  32399. 0,
  32400. height,
  32401. width,
  32402. 0,
  32403. width,
  32404. height
  32405. ]), gl.STATIC_DRAW);
  32406. gl.enableVertexAttribArray(cache.positionLocation);
  32407. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32408. gl.clearColor(0, 0, 0, 0);
  32409. gl.enable(gl.BLEND);
  32410. gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
  32411. gl.clear(gl.COLOR_BUFFER_BIT);
  32412. gl.drawArrays(gl.TRIANGLES, 0, 6);
  32413. gl.flush();
  32414. gl.deleteTexture(texture);
  32415. gl.deleteTexture(maskTexture);
  32416. gl.deleteBuffer(buffer);
  32417. return canvas;
  32418. }
  32419. var figuresVertexShaderCode = '\
  32420. attribute vec2 a_position; \
  32421. attribute vec3 a_color; \
  32422. \
  32423. uniform vec2 u_resolution; \
  32424. uniform vec2 u_scale; \
  32425. uniform vec2 u_offset; \
  32426. \
  32427. varying vec4 v_color; \
  32428. \
  32429. void main() { \
  32430. vec2 position = (a_position + u_offset) * u_scale; \
  32431. vec2 clipSpace = (position / u_resolution) * 2.0 - 1.0; \
  32432. gl_Position = vec4(clipSpace * vec2(1, -1), 0, 1); \
  32433. \
  32434. v_color = vec4(a_color / 255.0, 1.0); \
  32435. } ';
  32436. var figuresFragmentShaderCode = '\
  32437. precision mediump float; \
  32438. \
  32439. varying vec4 v_color; \
  32440. \
  32441. void main() { \
  32442. gl_FragColor = v_color; \
  32443. } ';
  32444. var figuresCache = null;
  32445. function initFiguresGL() {
  32446. var canvas, gl;
  32447. generateGL();
  32448. canvas = currentCanvas;
  32449. currentCanvas = null;
  32450. gl = currentGL;
  32451. currentGL = null;
  32452. var vertexShader = createVertexShader(gl, figuresVertexShaderCode);
  32453. var fragmentShader = createFragmentShader(gl, figuresFragmentShaderCode);
  32454. var program = createProgram(gl, [
  32455. vertexShader,
  32456. fragmentShader
  32457. ]);
  32458. gl.useProgram(program);
  32459. var cache = {};
  32460. cache.gl = gl;
  32461. cache.canvas = canvas;
  32462. cache.resolutionLocation = gl.getUniformLocation(program, 'u_resolution');
  32463. cache.scaleLocation = gl.getUniformLocation(program, 'u_scale');
  32464. cache.offsetLocation = gl.getUniformLocation(program, 'u_offset');
  32465. cache.positionLocation = gl.getAttribLocation(program, 'a_position');
  32466. cache.colorLocation = gl.getAttribLocation(program, 'a_color');
  32467. figuresCache = cache;
  32468. }
  32469. function drawFigures(width, height, backgroundColor, figures, context) {
  32470. if (!figuresCache) {
  32471. initFiguresGL();
  32472. }
  32473. var cache = figuresCache, canvas = cache.canvas, gl = cache.gl;
  32474. canvas.width = width;
  32475. canvas.height = height;
  32476. gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
  32477. gl.uniform2f(cache.resolutionLocation, width, height);
  32478. var count = 0;
  32479. var i, ii, rows;
  32480. for (i = 0, ii = figures.length; i < ii; i++) {
  32481. switch (figures[i].type) {
  32482. case 'lattice':
  32483. rows = figures[i].coords.length / figures[i].verticesPerRow | 0;
  32484. count += (rows - 1) * (figures[i].verticesPerRow - 1) * 6;
  32485. break;
  32486. case 'triangles':
  32487. count += figures[i].coords.length;
  32488. break;
  32489. }
  32490. }
  32491. var coords = new Float32Array(count * 2);
  32492. var colors = new Uint8Array(count * 3);
  32493. var coordsMap = context.coords, colorsMap = context.colors;
  32494. var pIndex = 0, cIndex = 0;
  32495. for (i = 0, ii = figures.length; i < ii; i++) {
  32496. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  32497. switch (figure.type) {
  32498. case 'lattice':
  32499. var cols = figure.verticesPerRow;
  32500. rows = ps.length / cols | 0;
  32501. for (var row = 1; row < rows; row++) {
  32502. var offset = row * cols + 1;
  32503. for (var col = 1; col < cols; col++, offset++) {
  32504. coords[pIndex] = coordsMap[ps[offset - cols - 1]];
  32505. coords[pIndex + 1] = coordsMap[ps[offset - cols - 1] + 1];
  32506. coords[pIndex + 2] = coordsMap[ps[offset - cols]];
  32507. coords[pIndex + 3] = coordsMap[ps[offset - cols] + 1];
  32508. coords[pIndex + 4] = coordsMap[ps[offset - 1]];
  32509. coords[pIndex + 5] = coordsMap[ps[offset - 1] + 1];
  32510. colors[cIndex] = colorsMap[cs[offset - cols - 1]];
  32511. colors[cIndex + 1] = colorsMap[cs[offset - cols - 1] + 1];
  32512. colors[cIndex + 2] = colorsMap[cs[offset - cols - 1] + 2];
  32513. colors[cIndex + 3] = colorsMap[cs[offset - cols]];
  32514. colors[cIndex + 4] = colorsMap[cs[offset - cols] + 1];
  32515. colors[cIndex + 5] = colorsMap[cs[offset - cols] + 2];
  32516. colors[cIndex + 6] = colorsMap[cs[offset - 1]];
  32517. colors[cIndex + 7] = colorsMap[cs[offset - 1] + 1];
  32518. colors[cIndex + 8] = colorsMap[cs[offset - 1] + 2];
  32519. coords[pIndex + 6] = coords[pIndex + 2];
  32520. coords[pIndex + 7] = coords[pIndex + 3];
  32521. coords[pIndex + 8] = coords[pIndex + 4];
  32522. coords[pIndex + 9] = coords[pIndex + 5];
  32523. coords[pIndex + 10] = coordsMap[ps[offset]];
  32524. coords[pIndex + 11] = coordsMap[ps[offset] + 1];
  32525. colors[cIndex + 9] = colors[cIndex + 3];
  32526. colors[cIndex + 10] = colors[cIndex + 4];
  32527. colors[cIndex + 11] = colors[cIndex + 5];
  32528. colors[cIndex + 12] = colors[cIndex + 6];
  32529. colors[cIndex + 13] = colors[cIndex + 7];
  32530. colors[cIndex + 14] = colors[cIndex + 8];
  32531. colors[cIndex + 15] = colorsMap[cs[offset]];
  32532. colors[cIndex + 16] = colorsMap[cs[offset] + 1];
  32533. colors[cIndex + 17] = colorsMap[cs[offset] + 2];
  32534. pIndex += 12;
  32535. cIndex += 18;
  32536. }
  32537. }
  32538. break;
  32539. case 'triangles':
  32540. for (var j = 0, jj = ps.length; j < jj; j++) {
  32541. coords[pIndex] = coordsMap[ps[j]];
  32542. coords[pIndex + 1] = coordsMap[ps[j] + 1];
  32543. colors[cIndex] = colorsMap[cs[j]];
  32544. colors[cIndex + 1] = colorsMap[cs[j] + 1];
  32545. colors[cIndex + 2] = colorsMap[cs[j] + 2];
  32546. pIndex += 2;
  32547. cIndex += 3;
  32548. }
  32549. break;
  32550. }
  32551. }
  32552. if (backgroundColor) {
  32553. gl.clearColor(backgroundColor[0] / 255, backgroundColor[1] / 255, backgroundColor[2] / 255, 1.0);
  32554. } else {
  32555. gl.clearColor(0, 0, 0, 0);
  32556. }
  32557. gl.clear(gl.COLOR_BUFFER_BIT);
  32558. var coordsBuffer = gl.createBuffer();
  32559. gl.bindBuffer(gl.ARRAY_BUFFER, coordsBuffer);
  32560. gl.bufferData(gl.ARRAY_BUFFER, coords, gl.STATIC_DRAW);
  32561. gl.enableVertexAttribArray(cache.positionLocation);
  32562. gl.vertexAttribPointer(cache.positionLocation, 2, gl.FLOAT, false, 0, 0);
  32563. var colorsBuffer = gl.createBuffer();
  32564. gl.bindBuffer(gl.ARRAY_BUFFER, colorsBuffer);
  32565. gl.bufferData(gl.ARRAY_BUFFER, colors, gl.STATIC_DRAW);
  32566. gl.enableVertexAttribArray(cache.colorLocation);
  32567. gl.vertexAttribPointer(cache.colorLocation, 3, gl.UNSIGNED_BYTE, false, 0, 0);
  32568. gl.uniform2f(cache.scaleLocation, context.scaleX, context.scaleY);
  32569. gl.uniform2f(cache.offsetLocation, context.offsetX, context.offsetY);
  32570. gl.drawArrays(gl.TRIANGLES, 0, count);
  32571. gl.flush();
  32572. gl.deleteBuffer(coordsBuffer);
  32573. gl.deleteBuffer(colorsBuffer);
  32574. return canvas;
  32575. }
  32576. function cleanup() {
  32577. if (smaskCache && smaskCache.canvas) {
  32578. smaskCache.canvas.width = 0;
  32579. smaskCache.canvas.height = 0;
  32580. }
  32581. if (figuresCache && figuresCache.canvas) {
  32582. figuresCache.canvas.width = 0;
  32583. figuresCache.canvas.height = 0;
  32584. }
  32585. smaskCache = null;
  32586. figuresCache = null;
  32587. }
  32588. return {
  32589. get isEnabled() {
  32590. if (getDefaultSetting('disableWebGL')) {
  32591. return false;
  32592. }
  32593. var enabled = false;
  32594. try {
  32595. generateGL();
  32596. enabled = !!currentGL;
  32597. } catch (e) {
  32598. }
  32599. return shadow(this, 'isEnabled', enabled);
  32600. },
  32601. composeSMask: composeSMask,
  32602. drawFigures: drawFigures,
  32603. clear: cleanup
  32604. };
  32605. }();
  32606. exports.WebGLUtils = WebGLUtils;
  32607. }));
  32608. (function (root, factory) {
  32609. factory(root.pdfjsCoreCrypto = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  32610. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  32611. var PasswordException = sharedUtil.PasswordException;
  32612. var PasswordResponses = sharedUtil.PasswordResponses;
  32613. var bytesToString = sharedUtil.bytesToString;
  32614. var warn = sharedUtil.warn;
  32615. var error = sharedUtil.error;
  32616. var assert = sharedUtil.assert;
  32617. var isInt = sharedUtil.isInt;
  32618. var stringToBytes = sharedUtil.stringToBytes;
  32619. var utf8StringToString = sharedUtil.utf8StringToString;
  32620. var Name = corePrimitives.Name;
  32621. var isName = corePrimitives.isName;
  32622. var isDict = corePrimitives.isDict;
  32623. var DecryptStream = coreStream.DecryptStream;
  32624. var ARCFourCipher = function ARCFourCipherClosure() {
  32625. function ARCFourCipher(key) {
  32626. this.a = 0;
  32627. this.b = 0;
  32628. var s = new Uint8Array(256);
  32629. var i, j = 0, tmp, keyLength = key.length;
  32630. for (i = 0; i < 256; ++i) {
  32631. s[i] = i;
  32632. }
  32633. for (i = 0; i < 256; ++i) {
  32634. tmp = s[i];
  32635. j = j + tmp + key[i % keyLength] & 0xFF;
  32636. s[i] = s[j];
  32637. s[j] = tmp;
  32638. }
  32639. this.s = s;
  32640. }
  32641. ARCFourCipher.prototype = {
  32642. encryptBlock: function ARCFourCipher_encryptBlock(data) {
  32643. var i, n = data.length, tmp, tmp2;
  32644. var a = this.a, b = this.b, s = this.s;
  32645. var output = new Uint8Array(n);
  32646. for (i = 0; i < n; ++i) {
  32647. a = a + 1 & 0xFF;
  32648. tmp = s[a];
  32649. b = b + tmp & 0xFF;
  32650. tmp2 = s[b];
  32651. s[a] = tmp2;
  32652. s[b] = tmp;
  32653. output[i] = data[i] ^ s[tmp + tmp2 & 0xFF];
  32654. }
  32655. this.a = a;
  32656. this.b = b;
  32657. return output;
  32658. }
  32659. };
  32660. ARCFourCipher.prototype.decryptBlock = ARCFourCipher.prototype.encryptBlock;
  32661. return ARCFourCipher;
  32662. }();
  32663. var calculateMD5 = function calculateMD5Closure() {
  32664. var r = new Uint8Array([
  32665. 7,
  32666. 12,
  32667. 17,
  32668. 22,
  32669. 7,
  32670. 12,
  32671. 17,
  32672. 22,
  32673. 7,
  32674. 12,
  32675. 17,
  32676. 22,
  32677. 7,
  32678. 12,
  32679. 17,
  32680. 22,
  32681. 5,
  32682. 9,
  32683. 14,
  32684. 20,
  32685. 5,
  32686. 9,
  32687. 14,
  32688. 20,
  32689. 5,
  32690. 9,
  32691. 14,
  32692. 20,
  32693. 5,
  32694. 9,
  32695. 14,
  32696. 20,
  32697. 4,
  32698. 11,
  32699. 16,
  32700. 23,
  32701. 4,
  32702. 11,
  32703. 16,
  32704. 23,
  32705. 4,
  32706. 11,
  32707. 16,
  32708. 23,
  32709. 4,
  32710. 11,
  32711. 16,
  32712. 23,
  32713. 6,
  32714. 10,
  32715. 15,
  32716. 21,
  32717. 6,
  32718. 10,
  32719. 15,
  32720. 21,
  32721. 6,
  32722. 10,
  32723. 15,
  32724. 21,
  32725. 6,
  32726. 10,
  32727. 15,
  32728. 21
  32729. ]);
  32730. var k = new Int32Array([
  32731. -680876936,
  32732. -389564586,
  32733. 606105819,
  32734. -1044525330,
  32735. -176418897,
  32736. 1200080426,
  32737. -1473231341,
  32738. -45705983,
  32739. 1770035416,
  32740. -1958414417,
  32741. -42063,
  32742. -1990404162,
  32743. 1804603682,
  32744. -40341101,
  32745. -1502002290,
  32746. 1236535329,
  32747. -165796510,
  32748. -1069501632,
  32749. 643717713,
  32750. -373897302,
  32751. -701558691,
  32752. 38016083,
  32753. -660478335,
  32754. -405537848,
  32755. 568446438,
  32756. -1019803690,
  32757. -187363961,
  32758. 1163531501,
  32759. -1444681467,
  32760. -51403784,
  32761. 1735328473,
  32762. -1926607734,
  32763. -378558,
  32764. -2022574463,
  32765. 1839030562,
  32766. -35309556,
  32767. -1530992060,
  32768. 1272893353,
  32769. -155497632,
  32770. -1094730640,
  32771. 681279174,
  32772. -358537222,
  32773. -722521979,
  32774. 76029189,
  32775. -640364487,
  32776. -421815835,
  32777. 530742520,
  32778. -995338651,
  32779. -198630844,
  32780. 1126891415,
  32781. -1416354905,
  32782. -57434055,
  32783. 1700485571,
  32784. -1894986606,
  32785. -1051523,
  32786. -2054922799,
  32787. 1873313359,
  32788. -30611744,
  32789. -1560198380,
  32790. 1309151649,
  32791. -145523070,
  32792. -1120210379,
  32793. 718787259,
  32794. -343485551
  32795. ]);
  32796. function hash(data, offset, length) {
  32797. var h0 = 1732584193, h1 = -271733879, h2 = -1732584194, h3 = 271733878;
  32798. var paddedLength = length + 72 & ~63;
  32799. var padded = new Uint8Array(paddedLength);
  32800. var i, j, n;
  32801. for (i = 0; i < length; ++i) {
  32802. padded[i] = data[offset++];
  32803. }
  32804. padded[i++] = 0x80;
  32805. n = paddedLength - 8;
  32806. while (i < n) {
  32807. padded[i++] = 0;
  32808. }
  32809. padded[i++] = length << 3 & 0xFF;
  32810. padded[i++] = length >> 5 & 0xFF;
  32811. padded[i++] = length >> 13 & 0xFF;
  32812. padded[i++] = length >> 21 & 0xFF;
  32813. padded[i++] = length >>> 29 & 0xFF;
  32814. padded[i++] = 0;
  32815. padded[i++] = 0;
  32816. padded[i++] = 0;
  32817. var w = new Int32Array(16);
  32818. for (i = 0; i < paddedLength;) {
  32819. for (j = 0; j < 16; ++j, i += 4) {
  32820. w[j] = padded[i] | padded[i + 1] << 8 | padded[i + 2] << 16 | padded[i + 3] << 24;
  32821. }
  32822. var a = h0, b = h1, c = h2, d = h3, f, g;
  32823. for (j = 0; j < 64; ++j) {
  32824. if (j < 16) {
  32825. f = b & c | ~b & d;
  32826. g = j;
  32827. } else if (j < 32) {
  32828. f = d & b | ~d & c;
  32829. g = 5 * j + 1 & 15;
  32830. } else if (j < 48) {
  32831. f = b ^ c ^ d;
  32832. g = 3 * j + 5 & 15;
  32833. } else {
  32834. f = c ^ (b | ~d);
  32835. g = 7 * j & 15;
  32836. }
  32837. var tmp = d, rotateArg = a + f + k[j] + w[g] | 0, rotate = r[j];
  32838. d = c;
  32839. c = b;
  32840. b = b + (rotateArg << rotate | rotateArg >>> 32 - rotate) | 0;
  32841. a = tmp;
  32842. }
  32843. h0 = h0 + a | 0;
  32844. h1 = h1 + b | 0;
  32845. h2 = h2 + c | 0;
  32846. h3 = h3 + d | 0;
  32847. }
  32848. return new Uint8Array([
  32849. h0 & 0xFF,
  32850. h0 >> 8 & 0xFF,
  32851. h0 >> 16 & 0xFF,
  32852. h0 >>> 24 & 0xFF,
  32853. h1 & 0xFF,
  32854. h1 >> 8 & 0xFF,
  32855. h1 >> 16 & 0xFF,
  32856. h1 >>> 24 & 0xFF,
  32857. h2 & 0xFF,
  32858. h2 >> 8 & 0xFF,
  32859. h2 >> 16 & 0xFF,
  32860. h2 >>> 24 & 0xFF,
  32861. h3 & 0xFF,
  32862. h3 >> 8 & 0xFF,
  32863. h3 >> 16 & 0xFF,
  32864. h3 >>> 24 & 0xFF
  32865. ]);
  32866. }
  32867. return hash;
  32868. }();
  32869. var Word64 = function Word64Closure() {
  32870. function Word64(highInteger, lowInteger) {
  32871. this.high = highInteger | 0;
  32872. this.low = lowInteger | 0;
  32873. }
  32874. Word64.prototype = {
  32875. and: function Word64_and(word) {
  32876. this.high &= word.high;
  32877. this.low &= word.low;
  32878. },
  32879. xor: function Word64_xor(word) {
  32880. this.high ^= word.high;
  32881. this.low ^= word.low;
  32882. },
  32883. or: function Word64_or(word) {
  32884. this.high |= word.high;
  32885. this.low |= word.low;
  32886. },
  32887. shiftRight: function Word64_shiftRight(places) {
  32888. if (places >= 32) {
  32889. this.low = this.high >>> places - 32 | 0;
  32890. this.high = 0;
  32891. } else {
  32892. this.low = this.low >>> places | this.high << 32 - places;
  32893. this.high = this.high >>> places | 0;
  32894. }
  32895. },
  32896. shiftLeft: function Word64_shiftLeft(places) {
  32897. if (places >= 32) {
  32898. this.high = this.low << places - 32;
  32899. this.low = 0;
  32900. } else {
  32901. this.high = this.high << places | this.low >>> 32 - places;
  32902. this.low = this.low << places;
  32903. }
  32904. },
  32905. rotateRight: function Word64_rotateRight(places) {
  32906. var low, high;
  32907. if (places & 32) {
  32908. high = this.low;
  32909. low = this.high;
  32910. } else {
  32911. low = this.low;
  32912. high = this.high;
  32913. }
  32914. places &= 31;
  32915. this.low = low >>> places | high << 32 - places;
  32916. this.high = high >>> places | low << 32 - places;
  32917. },
  32918. not: function Word64_not() {
  32919. this.high = ~this.high;
  32920. this.low = ~this.low;
  32921. },
  32922. add: function Word64_add(word) {
  32923. var lowAdd = (this.low >>> 0) + (word.low >>> 0);
  32924. var highAdd = (this.high >>> 0) + (word.high >>> 0);
  32925. if (lowAdd > 0xFFFFFFFF) {
  32926. highAdd += 1;
  32927. }
  32928. this.low = lowAdd | 0;
  32929. this.high = highAdd | 0;
  32930. },
  32931. copyTo: function Word64_copyTo(bytes, offset) {
  32932. bytes[offset] = this.high >>> 24 & 0xFF;
  32933. bytes[offset + 1] = this.high >> 16 & 0xFF;
  32934. bytes[offset + 2] = this.high >> 8 & 0xFF;
  32935. bytes[offset + 3] = this.high & 0xFF;
  32936. bytes[offset + 4] = this.low >>> 24 & 0xFF;
  32937. bytes[offset + 5] = this.low >> 16 & 0xFF;
  32938. bytes[offset + 6] = this.low >> 8 & 0xFF;
  32939. bytes[offset + 7] = this.low & 0xFF;
  32940. },
  32941. assign: function Word64_assign(word) {
  32942. this.high = word.high;
  32943. this.low = word.low;
  32944. }
  32945. };
  32946. return Word64;
  32947. }();
  32948. var calculateSHA256 = function calculateSHA256Closure() {
  32949. function rotr(x, n) {
  32950. return x >>> n | x << 32 - n;
  32951. }
  32952. function ch(x, y, z) {
  32953. return x & y ^ ~x & z;
  32954. }
  32955. function maj(x, y, z) {
  32956. return x & y ^ x & z ^ y & z;
  32957. }
  32958. function sigma(x) {
  32959. return rotr(x, 2) ^ rotr(x, 13) ^ rotr(x, 22);
  32960. }
  32961. function sigmaPrime(x) {
  32962. return rotr(x, 6) ^ rotr(x, 11) ^ rotr(x, 25);
  32963. }
  32964. function littleSigma(x) {
  32965. return rotr(x, 7) ^ rotr(x, 18) ^ x >>> 3;
  32966. }
  32967. function littleSigmaPrime(x) {
  32968. return rotr(x, 17) ^ rotr(x, 19) ^ x >>> 10;
  32969. }
  32970. var k = [
  32971. 0x428a2f98,
  32972. 0x71374491,
  32973. 0xb5c0fbcf,
  32974. 0xe9b5dba5,
  32975. 0x3956c25b,
  32976. 0x59f111f1,
  32977. 0x923f82a4,
  32978. 0xab1c5ed5,
  32979. 0xd807aa98,
  32980. 0x12835b01,
  32981. 0x243185be,
  32982. 0x550c7dc3,
  32983. 0x72be5d74,
  32984. 0x80deb1fe,
  32985. 0x9bdc06a7,
  32986. 0xc19bf174,
  32987. 0xe49b69c1,
  32988. 0xefbe4786,
  32989. 0x0fc19dc6,
  32990. 0x240ca1cc,
  32991. 0x2de92c6f,
  32992. 0x4a7484aa,
  32993. 0x5cb0a9dc,
  32994. 0x76f988da,
  32995. 0x983e5152,
  32996. 0xa831c66d,
  32997. 0xb00327c8,
  32998. 0xbf597fc7,
  32999. 0xc6e00bf3,
  33000. 0xd5a79147,
  33001. 0x06ca6351,
  33002. 0x14292967,
  33003. 0x27b70a85,
  33004. 0x2e1b2138,
  33005. 0x4d2c6dfc,
  33006. 0x53380d13,
  33007. 0x650a7354,
  33008. 0x766a0abb,
  33009. 0x81c2c92e,
  33010. 0x92722c85,
  33011. 0xa2bfe8a1,
  33012. 0xa81a664b,
  33013. 0xc24b8b70,
  33014. 0xc76c51a3,
  33015. 0xd192e819,
  33016. 0xd6990624,
  33017. 0xf40e3585,
  33018. 0x106aa070,
  33019. 0x19a4c116,
  33020. 0x1e376c08,
  33021. 0x2748774c,
  33022. 0x34b0bcb5,
  33023. 0x391c0cb3,
  33024. 0x4ed8aa4a,
  33025. 0x5b9cca4f,
  33026. 0x682e6ff3,
  33027. 0x748f82ee,
  33028. 0x78a5636f,
  33029. 0x84c87814,
  33030. 0x8cc70208,
  33031. 0x90befffa,
  33032. 0xa4506ceb,
  33033. 0xbef9a3f7,
  33034. 0xc67178f2
  33035. ];
  33036. function hash(data, offset, length) {
  33037. var h0 = 0x6a09e667, h1 = 0xbb67ae85, h2 = 0x3c6ef372, h3 = 0xa54ff53a, h4 = 0x510e527f, h5 = 0x9b05688c, h6 = 0x1f83d9ab, h7 = 0x5be0cd19;
  33038. var paddedLength = Math.ceil((length + 9) / 64) * 64;
  33039. var padded = new Uint8Array(paddedLength);
  33040. var i, j, n;
  33041. for (i = 0; i < length; ++i) {
  33042. padded[i] = data[offset++];
  33043. }
  33044. padded[i++] = 0x80;
  33045. n = paddedLength - 8;
  33046. while (i < n) {
  33047. padded[i++] = 0;
  33048. }
  33049. padded[i++] = 0;
  33050. padded[i++] = 0;
  33051. padded[i++] = 0;
  33052. padded[i++] = length >>> 29 & 0xFF;
  33053. padded[i++] = length >> 21 & 0xFF;
  33054. padded[i++] = length >> 13 & 0xFF;
  33055. padded[i++] = length >> 5 & 0xFF;
  33056. padded[i++] = length << 3 & 0xFF;
  33057. var w = new Uint32Array(64);
  33058. for (i = 0; i < paddedLength;) {
  33059. for (j = 0; j < 16; ++j) {
  33060. w[j] = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33061. i += 4;
  33062. }
  33063. for (j = 16; j < 64; ++j) {
  33064. w[j] = littleSigmaPrime(w[j - 2]) + w[j - 7] + littleSigma(w[j - 15]) + w[j - 16] | 0;
  33065. }
  33066. var a = h0, b = h1, c = h2, d = h3, e = h4, f = h5, g = h6, h = h7, t1, t2;
  33067. for (j = 0; j < 64; ++j) {
  33068. t1 = h + sigmaPrime(e) + ch(e, f, g) + k[j] + w[j];
  33069. t2 = sigma(a) + maj(a, b, c);
  33070. h = g;
  33071. g = f;
  33072. f = e;
  33073. e = d + t1 | 0;
  33074. d = c;
  33075. c = b;
  33076. b = a;
  33077. a = t1 + t2 | 0;
  33078. }
  33079. h0 = h0 + a | 0;
  33080. h1 = h1 + b | 0;
  33081. h2 = h2 + c | 0;
  33082. h3 = h3 + d | 0;
  33083. h4 = h4 + e | 0;
  33084. h5 = h5 + f | 0;
  33085. h6 = h6 + g | 0;
  33086. h7 = h7 + h | 0;
  33087. }
  33088. return new Uint8Array([
  33089. h0 >> 24 & 0xFF,
  33090. h0 >> 16 & 0xFF,
  33091. h0 >> 8 & 0xFF,
  33092. h0 & 0xFF,
  33093. h1 >> 24 & 0xFF,
  33094. h1 >> 16 & 0xFF,
  33095. h1 >> 8 & 0xFF,
  33096. h1 & 0xFF,
  33097. h2 >> 24 & 0xFF,
  33098. h2 >> 16 & 0xFF,
  33099. h2 >> 8 & 0xFF,
  33100. h2 & 0xFF,
  33101. h3 >> 24 & 0xFF,
  33102. h3 >> 16 & 0xFF,
  33103. h3 >> 8 & 0xFF,
  33104. h3 & 0xFF,
  33105. h4 >> 24 & 0xFF,
  33106. h4 >> 16 & 0xFF,
  33107. h4 >> 8 & 0xFF,
  33108. h4 & 0xFF,
  33109. h5 >> 24 & 0xFF,
  33110. h5 >> 16 & 0xFF,
  33111. h5 >> 8 & 0xFF,
  33112. h5 & 0xFF,
  33113. h6 >> 24 & 0xFF,
  33114. h6 >> 16 & 0xFF,
  33115. h6 >> 8 & 0xFF,
  33116. h6 & 0xFF,
  33117. h7 >> 24 & 0xFF,
  33118. h7 >> 16 & 0xFF,
  33119. h7 >> 8 & 0xFF,
  33120. h7 & 0xFF
  33121. ]);
  33122. }
  33123. return hash;
  33124. }();
  33125. var calculateSHA512 = function calculateSHA512Closure() {
  33126. function ch(result, x, y, z, tmp) {
  33127. result.assign(x);
  33128. result.and(y);
  33129. tmp.assign(x);
  33130. tmp.not();
  33131. tmp.and(z);
  33132. result.xor(tmp);
  33133. }
  33134. function maj(result, x, y, z, tmp) {
  33135. result.assign(x);
  33136. result.and(y);
  33137. tmp.assign(x);
  33138. tmp.and(z);
  33139. result.xor(tmp);
  33140. tmp.assign(y);
  33141. tmp.and(z);
  33142. result.xor(tmp);
  33143. }
  33144. function sigma(result, x, tmp) {
  33145. result.assign(x);
  33146. result.rotateRight(28);
  33147. tmp.assign(x);
  33148. tmp.rotateRight(34);
  33149. result.xor(tmp);
  33150. tmp.assign(x);
  33151. tmp.rotateRight(39);
  33152. result.xor(tmp);
  33153. }
  33154. function sigmaPrime(result, x, tmp) {
  33155. result.assign(x);
  33156. result.rotateRight(14);
  33157. tmp.assign(x);
  33158. tmp.rotateRight(18);
  33159. result.xor(tmp);
  33160. tmp.assign(x);
  33161. tmp.rotateRight(41);
  33162. result.xor(tmp);
  33163. }
  33164. function littleSigma(result, x, tmp) {
  33165. result.assign(x);
  33166. result.rotateRight(1);
  33167. tmp.assign(x);
  33168. tmp.rotateRight(8);
  33169. result.xor(tmp);
  33170. tmp.assign(x);
  33171. tmp.shiftRight(7);
  33172. result.xor(tmp);
  33173. }
  33174. function littleSigmaPrime(result, x, tmp) {
  33175. result.assign(x);
  33176. result.rotateRight(19);
  33177. tmp.assign(x);
  33178. tmp.rotateRight(61);
  33179. result.xor(tmp);
  33180. tmp.assign(x);
  33181. tmp.shiftRight(6);
  33182. result.xor(tmp);
  33183. }
  33184. var k = [
  33185. new Word64(0x428a2f98, 0xd728ae22),
  33186. new Word64(0x71374491, 0x23ef65cd),
  33187. new Word64(0xb5c0fbcf, 0xec4d3b2f),
  33188. new Word64(0xe9b5dba5, 0x8189dbbc),
  33189. new Word64(0x3956c25b, 0xf348b538),
  33190. new Word64(0x59f111f1, 0xb605d019),
  33191. new Word64(0x923f82a4, 0xaf194f9b),
  33192. new Word64(0xab1c5ed5, 0xda6d8118),
  33193. new Word64(0xd807aa98, 0xa3030242),
  33194. new Word64(0x12835b01, 0x45706fbe),
  33195. new Word64(0x243185be, 0x4ee4b28c),
  33196. new Word64(0x550c7dc3, 0xd5ffb4e2),
  33197. new Word64(0x72be5d74, 0xf27b896f),
  33198. new Word64(0x80deb1fe, 0x3b1696b1),
  33199. new Word64(0x9bdc06a7, 0x25c71235),
  33200. new Word64(0xc19bf174, 0xcf692694),
  33201. new Word64(0xe49b69c1, 0x9ef14ad2),
  33202. new Word64(0xefbe4786, 0x384f25e3),
  33203. new Word64(0x0fc19dc6, 0x8b8cd5b5),
  33204. new Word64(0x240ca1cc, 0x77ac9c65),
  33205. new Word64(0x2de92c6f, 0x592b0275),
  33206. new Word64(0x4a7484aa, 0x6ea6e483),
  33207. new Word64(0x5cb0a9dc, 0xbd41fbd4),
  33208. new Word64(0x76f988da, 0x831153b5),
  33209. new Word64(0x983e5152, 0xee66dfab),
  33210. new Word64(0xa831c66d, 0x2db43210),
  33211. new Word64(0xb00327c8, 0x98fb213f),
  33212. new Word64(0xbf597fc7, 0xbeef0ee4),
  33213. new Word64(0xc6e00bf3, 0x3da88fc2),
  33214. new Word64(0xd5a79147, 0x930aa725),
  33215. new Word64(0x06ca6351, 0xe003826f),
  33216. new Word64(0x14292967, 0x0a0e6e70),
  33217. new Word64(0x27b70a85, 0x46d22ffc),
  33218. new Word64(0x2e1b2138, 0x5c26c926),
  33219. new Word64(0x4d2c6dfc, 0x5ac42aed),
  33220. new Word64(0x53380d13, 0x9d95b3df),
  33221. new Word64(0x650a7354, 0x8baf63de),
  33222. new Word64(0x766a0abb, 0x3c77b2a8),
  33223. new Word64(0x81c2c92e, 0x47edaee6),
  33224. new Word64(0x92722c85, 0x1482353b),
  33225. new Word64(0xa2bfe8a1, 0x4cf10364),
  33226. new Word64(0xa81a664b, 0xbc423001),
  33227. new Word64(0xc24b8b70, 0xd0f89791),
  33228. new Word64(0xc76c51a3, 0x0654be30),
  33229. new Word64(0xd192e819, 0xd6ef5218),
  33230. new Word64(0xd6990624, 0x5565a910),
  33231. new Word64(0xf40e3585, 0x5771202a),
  33232. new Word64(0x106aa070, 0x32bbd1b8),
  33233. new Word64(0x19a4c116, 0xb8d2d0c8),
  33234. new Word64(0x1e376c08, 0x5141ab53),
  33235. new Word64(0x2748774c, 0xdf8eeb99),
  33236. new Word64(0x34b0bcb5, 0xe19b48a8),
  33237. new Word64(0x391c0cb3, 0xc5c95a63),
  33238. new Word64(0x4ed8aa4a, 0xe3418acb),
  33239. new Word64(0x5b9cca4f, 0x7763e373),
  33240. new Word64(0x682e6ff3, 0xd6b2b8a3),
  33241. new Word64(0x748f82ee, 0x5defb2fc),
  33242. new Word64(0x78a5636f, 0x43172f60),
  33243. new Word64(0x84c87814, 0xa1f0ab72),
  33244. new Word64(0x8cc70208, 0x1a6439ec),
  33245. new Word64(0x90befffa, 0x23631e28),
  33246. new Word64(0xa4506ceb, 0xde82bde9),
  33247. new Word64(0xbef9a3f7, 0xb2c67915),
  33248. new Word64(0xc67178f2, 0xe372532b),
  33249. new Word64(0xca273ece, 0xea26619c),
  33250. new Word64(0xd186b8c7, 0x21c0c207),
  33251. new Word64(0xeada7dd6, 0xcde0eb1e),
  33252. new Word64(0xf57d4f7f, 0xee6ed178),
  33253. new Word64(0x06f067aa, 0x72176fba),
  33254. new Word64(0x0a637dc5, 0xa2c898a6),
  33255. new Word64(0x113f9804, 0xbef90dae),
  33256. new Word64(0x1b710b35, 0x131c471b),
  33257. new Word64(0x28db77f5, 0x23047d84),
  33258. new Word64(0x32caab7b, 0x40c72493),
  33259. new Word64(0x3c9ebe0a, 0x15c9bebc),
  33260. new Word64(0x431d67c4, 0x9c100d4c),
  33261. new Word64(0x4cc5d4be, 0xcb3e42b6),
  33262. new Word64(0x597f299c, 0xfc657e2a),
  33263. new Word64(0x5fcb6fab, 0x3ad6faec),
  33264. new Word64(0x6c44198c, 0x4a475817)
  33265. ];
  33266. function hash(data, offset, length, mode384) {
  33267. mode384 = !!mode384;
  33268. var h0, h1, h2, h3, h4, h5, h6, h7;
  33269. if (!mode384) {
  33270. h0 = new Word64(0x6a09e667, 0xf3bcc908);
  33271. h1 = new Word64(0xbb67ae85, 0x84caa73b);
  33272. h2 = new Word64(0x3c6ef372, 0xfe94f82b);
  33273. h3 = new Word64(0xa54ff53a, 0x5f1d36f1);
  33274. h4 = new Word64(0x510e527f, 0xade682d1);
  33275. h5 = new Word64(0x9b05688c, 0x2b3e6c1f);
  33276. h6 = new Word64(0x1f83d9ab, 0xfb41bd6b);
  33277. h7 = new Word64(0x5be0cd19, 0x137e2179);
  33278. } else {
  33279. h0 = new Word64(0xcbbb9d5d, 0xc1059ed8);
  33280. h1 = new Word64(0x629a292a, 0x367cd507);
  33281. h2 = new Word64(0x9159015a, 0x3070dd17);
  33282. h3 = new Word64(0x152fecd8, 0xf70e5939);
  33283. h4 = new Word64(0x67332667, 0xffc00b31);
  33284. h5 = new Word64(0x8eb44a87, 0x68581511);
  33285. h6 = new Word64(0xdb0c2e0d, 0x64f98fa7);
  33286. h7 = new Word64(0x47b5481d, 0xbefa4fa4);
  33287. }
  33288. var paddedLength = Math.ceil((length + 17) / 128) * 128;
  33289. var padded = new Uint8Array(paddedLength);
  33290. var i, j, n;
  33291. for (i = 0; i < length; ++i) {
  33292. padded[i] = data[offset++];
  33293. }
  33294. padded[i++] = 0x80;
  33295. n = paddedLength - 16;
  33296. while (i < n) {
  33297. padded[i++] = 0;
  33298. }
  33299. padded[i++] = 0;
  33300. padded[i++] = 0;
  33301. padded[i++] = 0;
  33302. padded[i++] = 0;
  33303. padded[i++] = 0;
  33304. padded[i++] = 0;
  33305. padded[i++] = 0;
  33306. padded[i++] = 0;
  33307. padded[i++] = 0;
  33308. padded[i++] = 0;
  33309. padded[i++] = 0;
  33310. padded[i++] = length >>> 29 & 0xFF;
  33311. padded[i++] = length >> 21 & 0xFF;
  33312. padded[i++] = length >> 13 & 0xFF;
  33313. padded[i++] = length >> 5 & 0xFF;
  33314. padded[i++] = length << 3 & 0xFF;
  33315. var w = new Array(80);
  33316. for (i = 0; i < 80; i++) {
  33317. w[i] = new Word64(0, 0);
  33318. }
  33319. var a = new Word64(0, 0), b = new Word64(0, 0), c = new Word64(0, 0);
  33320. var d = new Word64(0, 0), e = new Word64(0, 0), f = new Word64(0, 0);
  33321. var g = new Word64(0, 0), h = new Word64(0, 0);
  33322. var t1 = new Word64(0, 0), t2 = new Word64(0, 0);
  33323. var tmp1 = new Word64(0, 0), tmp2 = new Word64(0, 0), tmp3;
  33324. for (i = 0; i < paddedLength;) {
  33325. for (j = 0; j < 16; ++j) {
  33326. w[j].high = padded[i] << 24 | padded[i + 1] << 16 | padded[i + 2] << 8 | padded[i + 3];
  33327. w[j].low = padded[i + 4] << 24 | padded[i + 5] << 16 | padded[i + 6] << 8 | padded[i + 7];
  33328. i += 8;
  33329. }
  33330. for (j = 16; j < 80; ++j) {
  33331. tmp3 = w[j];
  33332. littleSigmaPrime(tmp3, w[j - 2], tmp2);
  33333. tmp3.add(w[j - 7]);
  33334. littleSigma(tmp1, w[j - 15], tmp2);
  33335. tmp3.add(tmp1);
  33336. tmp3.add(w[j - 16]);
  33337. }
  33338. a.assign(h0);
  33339. b.assign(h1);
  33340. c.assign(h2);
  33341. d.assign(h3);
  33342. e.assign(h4);
  33343. f.assign(h5);
  33344. g.assign(h6);
  33345. h.assign(h7);
  33346. for (j = 0; j < 80; ++j) {
  33347. t1.assign(h);
  33348. sigmaPrime(tmp1, e, tmp2);
  33349. t1.add(tmp1);
  33350. ch(tmp1, e, f, g, tmp2);
  33351. t1.add(tmp1);
  33352. t1.add(k[j]);
  33353. t1.add(w[j]);
  33354. sigma(t2, a, tmp2);
  33355. maj(tmp1, a, b, c, tmp2);
  33356. t2.add(tmp1);
  33357. tmp3 = h;
  33358. h = g;
  33359. g = f;
  33360. f = e;
  33361. d.add(t1);
  33362. e = d;
  33363. d = c;
  33364. c = b;
  33365. b = a;
  33366. tmp3.assign(t1);
  33367. tmp3.add(t2);
  33368. a = tmp3;
  33369. }
  33370. h0.add(a);
  33371. h1.add(b);
  33372. h2.add(c);
  33373. h3.add(d);
  33374. h4.add(e);
  33375. h5.add(f);
  33376. h6.add(g);
  33377. h7.add(h);
  33378. }
  33379. var result;
  33380. if (!mode384) {
  33381. result = new Uint8Array(64);
  33382. h0.copyTo(result, 0);
  33383. h1.copyTo(result, 8);
  33384. h2.copyTo(result, 16);
  33385. h3.copyTo(result, 24);
  33386. h4.copyTo(result, 32);
  33387. h5.copyTo(result, 40);
  33388. h6.copyTo(result, 48);
  33389. h7.copyTo(result, 56);
  33390. } else {
  33391. result = new Uint8Array(48);
  33392. h0.copyTo(result, 0);
  33393. h1.copyTo(result, 8);
  33394. h2.copyTo(result, 16);
  33395. h3.copyTo(result, 24);
  33396. h4.copyTo(result, 32);
  33397. h5.copyTo(result, 40);
  33398. }
  33399. return result;
  33400. }
  33401. return hash;
  33402. }();
  33403. var calculateSHA384 = function calculateSHA384Closure() {
  33404. function hash(data, offset, length) {
  33405. return calculateSHA512(data, offset, length, true);
  33406. }
  33407. return hash;
  33408. }();
  33409. var NullCipher = function NullCipherClosure() {
  33410. function NullCipher() {
  33411. }
  33412. NullCipher.prototype = {
  33413. decryptBlock: function NullCipher_decryptBlock(data) {
  33414. return data;
  33415. }
  33416. };
  33417. return NullCipher;
  33418. }();
  33419. var AES128Cipher = function AES128CipherClosure() {
  33420. var rcon = new Uint8Array([
  33421. 0x8d,
  33422. 0x01,
  33423. 0x02,
  33424. 0x04,
  33425. 0x08,
  33426. 0x10,
  33427. 0x20,
  33428. 0x40,
  33429. 0x80,
  33430. 0x1b,
  33431. 0x36,
  33432. 0x6c,
  33433. 0xd8,
  33434. 0xab,
  33435. 0x4d,
  33436. 0x9a,
  33437. 0x2f,
  33438. 0x5e,
  33439. 0xbc,
  33440. 0x63,
  33441. 0xc6,
  33442. 0x97,
  33443. 0x35,
  33444. 0x6a,
  33445. 0xd4,
  33446. 0xb3,
  33447. 0x7d,
  33448. 0xfa,
  33449. 0xef,
  33450. 0xc5,
  33451. 0x91,
  33452. 0x39,
  33453. 0x72,
  33454. 0xe4,
  33455. 0xd3,
  33456. 0xbd,
  33457. 0x61,
  33458. 0xc2,
  33459. 0x9f,
  33460. 0x25,
  33461. 0x4a,
  33462. 0x94,
  33463. 0x33,
  33464. 0x66,
  33465. 0xcc,
  33466. 0x83,
  33467. 0x1d,
  33468. 0x3a,
  33469. 0x74,
  33470. 0xe8,
  33471. 0xcb,
  33472. 0x8d,
  33473. 0x01,
  33474. 0x02,
  33475. 0x04,
  33476. 0x08,
  33477. 0x10,
  33478. 0x20,
  33479. 0x40,
  33480. 0x80,
  33481. 0x1b,
  33482. 0x36,
  33483. 0x6c,
  33484. 0xd8,
  33485. 0xab,
  33486. 0x4d,
  33487. 0x9a,
  33488. 0x2f,
  33489. 0x5e,
  33490. 0xbc,
  33491. 0x63,
  33492. 0xc6,
  33493. 0x97,
  33494. 0x35,
  33495. 0x6a,
  33496. 0xd4,
  33497. 0xb3,
  33498. 0x7d,
  33499. 0xfa,
  33500. 0xef,
  33501. 0xc5,
  33502. 0x91,
  33503. 0x39,
  33504. 0x72,
  33505. 0xe4,
  33506. 0xd3,
  33507. 0xbd,
  33508. 0x61,
  33509. 0xc2,
  33510. 0x9f,
  33511. 0x25,
  33512. 0x4a,
  33513. 0x94,
  33514. 0x33,
  33515. 0x66,
  33516. 0xcc,
  33517. 0x83,
  33518. 0x1d,
  33519. 0x3a,
  33520. 0x74,
  33521. 0xe8,
  33522. 0xcb,
  33523. 0x8d,
  33524. 0x01,
  33525. 0x02,
  33526. 0x04,
  33527. 0x08,
  33528. 0x10,
  33529. 0x20,
  33530. 0x40,
  33531. 0x80,
  33532. 0x1b,
  33533. 0x36,
  33534. 0x6c,
  33535. 0xd8,
  33536. 0xab,
  33537. 0x4d,
  33538. 0x9a,
  33539. 0x2f,
  33540. 0x5e,
  33541. 0xbc,
  33542. 0x63,
  33543. 0xc6,
  33544. 0x97,
  33545. 0x35,
  33546. 0x6a,
  33547. 0xd4,
  33548. 0xb3,
  33549. 0x7d,
  33550. 0xfa,
  33551. 0xef,
  33552. 0xc5,
  33553. 0x91,
  33554. 0x39,
  33555. 0x72,
  33556. 0xe4,
  33557. 0xd3,
  33558. 0xbd,
  33559. 0x61,
  33560. 0xc2,
  33561. 0x9f,
  33562. 0x25,
  33563. 0x4a,
  33564. 0x94,
  33565. 0x33,
  33566. 0x66,
  33567. 0xcc,
  33568. 0x83,
  33569. 0x1d,
  33570. 0x3a,
  33571. 0x74,
  33572. 0xe8,
  33573. 0xcb,
  33574. 0x8d,
  33575. 0x01,
  33576. 0x02,
  33577. 0x04,
  33578. 0x08,
  33579. 0x10,
  33580. 0x20,
  33581. 0x40,
  33582. 0x80,
  33583. 0x1b,
  33584. 0x36,
  33585. 0x6c,
  33586. 0xd8,
  33587. 0xab,
  33588. 0x4d,
  33589. 0x9a,
  33590. 0x2f,
  33591. 0x5e,
  33592. 0xbc,
  33593. 0x63,
  33594. 0xc6,
  33595. 0x97,
  33596. 0x35,
  33597. 0x6a,
  33598. 0xd4,
  33599. 0xb3,
  33600. 0x7d,
  33601. 0xfa,
  33602. 0xef,
  33603. 0xc5,
  33604. 0x91,
  33605. 0x39,
  33606. 0x72,
  33607. 0xe4,
  33608. 0xd3,
  33609. 0xbd,
  33610. 0x61,
  33611. 0xc2,
  33612. 0x9f,
  33613. 0x25,
  33614. 0x4a,
  33615. 0x94,
  33616. 0x33,
  33617. 0x66,
  33618. 0xcc,
  33619. 0x83,
  33620. 0x1d,
  33621. 0x3a,
  33622. 0x74,
  33623. 0xe8,
  33624. 0xcb,
  33625. 0x8d,
  33626. 0x01,
  33627. 0x02,
  33628. 0x04,
  33629. 0x08,
  33630. 0x10,
  33631. 0x20,
  33632. 0x40,
  33633. 0x80,
  33634. 0x1b,
  33635. 0x36,
  33636. 0x6c,
  33637. 0xd8,
  33638. 0xab,
  33639. 0x4d,
  33640. 0x9a,
  33641. 0x2f,
  33642. 0x5e,
  33643. 0xbc,
  33644. 0x63,
  33645. 0xc6,
  33646. 0x97,
  33647. 0x35,
  33648. 0x6a,
  33649. 0xd4,
  33650. 0xb3,
  33651. 0x7d,
  33652. 0xfa,
  33653. 0xef,
  33654. 0xc5,
  33655. 0x91,
  33656. 0x39,
  33657. 0x72,
  33658. 0xe4,
  33659. 0xd3,
  33660. 0xbd,
  33661. 0x61,
  33662. 0xc2,
  33663. 0x9f,
  33664. 0x25,
  33665. 0x4a,
  33666. 0x94,
  33667. 0x33,
  33668. 0x66,
  33669. 0xcc,
  33670. 0x83,
  33671. 0x1d,
  33672. 0x3a,
  33673. 0x74,
  33674. 0xe8,
  33675. 0xcb,
  33676. 0x8d
  33677. ]);
  33678. var s = new Uint8Array([
  33679. 0x63,
  33680. 0x7c,
  33681. 0x77,
  33682. 0x7b,
  33683. 0xf2,
  33684. 0x6b,
  33685. 0x6f,
  33686. 0xc5,
  33687. 0x30,
  33688. 0x01,
  33689. 0x67,
  33690. 0x2b,
  33691. 0xfe,
  33692. 0xd7,
  33693. 0xab,
  33694. 0x76,
  33695. 0xca,
  33696. 0x82,
  33697. 0xc9,
  33698. 0x7d,
  33699. 0xfa,
  33700. 0x59,
  33701. 0x47,
  33702. 0xf0,
  33703. 0xad,
  33704. 0xd4,
  33705. 0xa2,
  33706. 0xaf,
  33707. 0x9c,
  33708. 0xa4,
  33709. 0x72,
  33710. 0xc0,
  33711. 0xb7,
  33712. 0xfd,
  33713. 0x93,
  33714. 0x26,
  33715. 0x36,
  33716. 0x3f,
  33717. 0xf7,
  33718. 0xcc,
  33719. 0x34,
  33720. 0xa5,
  33721. 0xe5,
  33722. 0xf1,
  33723. 0x71,
  33724. 0xd8,
  33725. 0x31,
  33726. 0x15,
  33727. 0x04,
  33728. 0xc7,
  33729. 0x23,
  33730. 0xc3,
  33731. 0x18,
  33732. 0x96,
  33733. 0x05,
  33734. 0x9a,
  33735. 0x07,
  33736. 0x12,
  33737. 0x80,
  33738. 0xe2,
  33739. 0xeb,
  33740. 0x27,
  33741. 0xb2,
  33742. 0x75,
  33743. 0x09,
  33744. 0x83,
  33745. 0x2c,
  33746. 0x1a,
  33747. 0x1b,
  33748. 0x6e,
  33749. 0x5a,
  33750. 0xa0,
  33751. 0x52,
  33752. 0x3b,
  33753. 0xd6,
  33754. 0xb3,
  33755. 0x29,
  33756. 0xe3,
  33757. 0x2f,
  33758. 0x84,
  33759. 0x53,
  33760. 0xd1,
  33761. 0x00,
  33762. 0xed,
  33763. 0x20,
  33764. 0xfc,
  33765. 0xb1,
  33766. 0x5b,
  33767. 0x6a,
  33768. 0xcb,
  33769. 0xbe,
  33770. 0x39,
  33771. 0x4a,
  33772. 0x4c,
  33773. 0x58,
  33774. 0xcf,
  33775. 0xd0,
  33776. 0xef,
  33777. 0xaa,
  33778. 0xfb,
  33779. 0x43,
  33780. 0x4d,
  33781. 0x33,
  33782. 0x85,
  33783. 0x45,
  33784. 0xf9,
  33785. 0x02,
  33786. 0x7f,
  33787. 0x50,
  33788. 0x3c,
  33789. 0x9f,
  33790. 0xa8,
  33791. 0x51,
  33792. 0xa3,
  33793. 0x40,
  33794. 0x8f,
  33795. 0x92,
  33796. 0x9d,
  33797. 0x38,
  33798. 0xf5,
  33799. 0xbc,
  33800. 0xb6,
  33801. 0xda,
  33802. 0x21,
  33803. 0x10,
  33804. 0xff,
  33805. 0xf3,
  33806. 0xd2,
  33807. 0xcd,
  33808. 0x0c,
  33809. 0x13,
  33810. 0xec,
  33811. 0x5f,
  33812. 0x97,
  33813. 0x44,
  33814. 0x17,
  33815. 0xc4,
  33816. 0xa7,
  33817. 0x7e,
  33818. 0x3d,
  33819. 0x64,
  33820. 0x5d,
  33821. 0x19,
  33822. 0x73,
  33823. 0x60,
  33824. 0x81,
  33825. 0x4f,
  33826. 0xdc,
  33827. 0x22,
  33828. 0x2a,
  33829. 0x90,
  33830. 0x88,
  33831. 0x46,
  33832. 0xee,
  33833. 0xb8,
  33834. 0x14,
  33835. 0xde,
  33836. 0x5e,
  33837. 0x0b,
  33838. 0xdb,
  33839. 0xe0,
  33840. 0x32,
  33841. 0x3a,
  33842. 0x0a,
  33843. 0x49,
  33844. 0x06,
  33845. 0x24,
  33846. 0x5c,
  33847. 0xc2,
  33848. 0xd3,
  33849. 0xac,
  33850. 0x62,
  33851. 0x91,
  33852. 0x95,
  33853. 0xe4,
  33854. 0x79,
  33855. 0xe7,
  33856. 0xc8,
  33857. 0x37,
  33858. 0x6d,
  33859. 0x8d,
  33860. 0xd5,
  33861. 0x4e,
  33862. 0xa9,
  33863. 0x6c,
  33864. 0x56,
  33865. 0xf4,
  33866. 0xea,
  33867. 0x65,
  33868. 0x7a,
  33869. 0xae,
  33870. 0x08,
  33871. 0xba,
  33872. 0x78,
  33873. 0x25,
  33874. 0x2e,
  33875. 0x1c,
  33876. 0xa6,
  33877. 0xb4,
  33878. 0xc6,
  33879. 0xe8,
  33880. 0xdd,
  33881. 0x74,
  33882. 0x1f,
  33883. 0x4b,
  33884. 0xbd,
  33885. 0x8b,
  33886. 0x8a,
  33887. 0x70,
  33888. 0x3e,
  33889. 0xb5,
  33890. 0x66,
  33891. 0x48,
  33892. 0x03,
  33893. 0xf6,
  33894. 0x0e,
  33895. 0x61,
  33896. 0x35,
  33897. 0x57,
  33898. 0xb9,
  33899. 0x86,
  33900. 0xc1,
  33901. 0x1d,
  33902. 0x9e,
  33903. 0xe1,
  33904. 0xf8,
  33905. 0x98,
  33906. 0x11,
  33907. 0x69,
  33908. 0xd9,
  33909. 0x8e,
  33910. 0x94,
  33911. 0x9b,
  33912. 0x1e,
  33913. 0x87,
  33914. 0xe9,
  33915. 0xce,
  33916. 0x55,
  33917. 0x28,
  33918. 0xdf,
  33919. 0x8c,
  33920. 0xa1,
  33921. 0x89,
  33922. 0x0d,
  33923. 0xbf,
  33924. 0xe6,
  33925. 0x42,
  33926. 0x68,
  33927. 0x41,
  33928. 0x99,
  33929. 0x2d,
  33930. 0x0f,
  33931. 0xb0,
  33932. 0x54,
  33933. 0xbb,
  33934. 0x16
  33935. ]);
  33936. var inv_s = new Uint8Array([
  33937. 0x52,
  33938. 0x09,
  33939. 0x6a,
  33940. 0xd5,
  33941. 0x30,
  33942. 0x36,
  33943. 0xa5,
  33944. 0x38,
  33945. 0xbf,
  33946. 0x40,
  33947. 0xa3,
  33948. 0x9e,
  33949. 0x81,
  33950. 0xf3,
  33951. 0xd7,
  33952. 0xfb,
  33953. 0x7c,
  33954. 0xe3,
  33955. 0x39,
  33956. 0x82,
  33957. 0x9b,
  33958. 0x2f,
  33959. 0xff,
  33960. 0x87,
  33961. 0x34,
  33962. 0x8e,
  33963. 0x43,
  33964. 0x44,
  33965. 0xc4,
  33966. 0xde,
  33967. 0xe9,
  33968. 0xcb,
  33969. 0x54,
  33970. 0x7b,
  33971. 0x94,
  33972. 0x32,
  33973. 0xa6,
  33974. 0xc2,
  33975. 0x23,
  33976. 0x3d,
  33977. 0xee,
  33978. 0x4c,
  33979. 0x95,
  33980. 0x0b,
  33981. 0x42,
  33982. 0xfa,
  33983. 0xc3,
  33984. 0x4e,
  33985. 0x08,
  33986. 0x2e,
  33987. 0xa1,
  33988. 0x66,
  33989. 0x28,
  33990. 0xd9,
  33991. 0x24,
  33992. 0xb2,
  33993. 0x76,
  33994. 0x5b,
  33995. 0xa2,
  33996. 0x49,
  33997. 0x6d,
  33998. 0x8b,
  33999. 0xd1,
  34000. 0x25,
  34001. 0x72,
  34002. 0xf8,
  34003. 0xf6,
  34004. 0x64,
  34005. 0x86,
  34006. 0x68,
  34007. 0x98,
  34008. 0x16,
  34009. 0xd4,
  34010. 0xa4,
  34011. 0x5c,
  34012. 0xcc,
  34013. 0x5d,
  34014. 0x65,
  34015. 0xb6,
  34016. 0x92,
  34017. 0x6c,
  34018. 0x70,
  34019. 0x48,
  34020. 0x50,
  34021. 0xfd,
  34022. 0xed,
  34023. 0xb9,
  34024. 0xda,
  34025. 0x5e,
  34026. 0x15,
  34027. 0x46,
  34028. 0x57,
  34029. 0xa7,
  34030. 0x8d,
  34031. 0x9d,
  34032. 0x84,
  34033. 0x90,
  34034. 0xd8,
  34035. 0xab,
  34036. 0x00,
  34037. 0x8c,
  34038. 0xbc,
  34039. 0xd3,
  34040. 0x0a,
  34041. 0xf7,
  34042. 0xe4,
  34043. 0x58,
  34044. 0x05,
  34045. 0xb8,
  34046. 0xb3,
  34047. 0x45,
  34048. 0x06,
  34049. 0xd0,
  34050. 0x2c,
  34051. 0x1e,
  34052. 0x8f,
  34053. 0xca,
  34054. 0x3f,
  34055. 0x0f,
  34056. 0x02,
  34057. 0xc1,
  34058. 0xaf,
  34059. 0xbd,
  34060. 0x03,
  34061. 0x01,
  34062. 0x13,
  34063. 0x8a,
  34064. 0x6b,
  34065. 0x3a,
  34066. 0x91,
  34067. 0x11,
  34068. 0x41,
  34069. 0x4f,
  34070. 0x67,
  34071. 0xdc,
  34072. 0xea,
  34073. 0x97,
  34074. 0xf2,
  34075. 0xcf,
  34076. 0xce,
  34077. 0xf0,
  34078. 0xb4,
  34079. 0xe6,
  34080. 0x73,
  34081. 0x96,
  34082. 0xac,
  34083. 0x74,
  34084. 0x22,
  34085. 0xe7,
  34086. 0xad,
  34087. 0x35,
  34088. 0x85,
  34089. 0xe2,
  34090. 0xf9,
  34091. 0x37,
  34092. 0xe8,
  34093. 0x1c,
  34094. 0x75,
  34095. 0xdf,
  34096. 0x6e,
  34097. 0x47,
  34098. 0xf1,
  34099. 0x1a,
  34100. 0x71,
  34101. 0x1d,
  34102. 0x29,
  34103. 0xc5,
  34104. 0x89,
  34105. 0x6f,
  34106. 0xb7,
  34107. 0x62,
  34108. 0x0e,
  34109. 0xaa,
  34110. 0x18,
  34111. 0xbe,
  34112. 0x1b,
  34113. 0xfc,
  34114. 0x56,
  34115. 0x3e,
  34116. 0x4b,
  34117. 0xc6,
  34118. 0xd2,
  34119. 0x79,
  34120. 0x20,
  34121. 0x9a,
  34122. 0xdb,
  34123. 0xc0,
  34124. 0xfe,
  34125. 0x78,
  34126. 0xcd,
  34127. 0x5a,
  34128. 0xf4,
  34129. 0x1f,
  34130. 0xdd,
  34131. 0xa8,
  34132. 0x33,
  34133. 0x88,
  34134. 0x07,
  34135. 0xc7,
  34136. 0x31,
  34137. 0xb1,
  34138. 0x12,
  34139. 0x10,
  34140. 0x59,
  34141. 0x27,
  34142. 0x80,
  34143. 0xec,
  34144. 0x5f,
  34145. 0x60,
  34146. 0x51,
  34147. 0x7f,
  34148. 0xa9,
  34149. 0x19,
  34150. 0xb5,
  34151. 0x4a,
  34152. 0x0d,
  34153. 0x2d,
  34154. 0xe5,
  34155. 0x7a,
  34156. 0x9f,
  34157. 0x93,
  34158. 0xc9,
  34159. 0x9c,
  34160. 0xef,
  34161. 0xa0,
  34162. 0xe0,
  34163. 0x3b,
  34164. 0x4d,
  34165. 0xae,
  34166. 0x2a,
  34167. 0xf5,
  34168. 0xb0,
  34169. 0xc8,
  34170. 0xeb,
  34171. 0xbb,
  34172. 0x3c,
  34173. 0x83,
  34174. 0x53,
  34175. 0x99,
  34176. 0x61,
  34177. 0x17,
  34178. 0x2b,
  34179. 0x04,
  34180. 0x7e,
  34181. 0xba,
  34182. 0x77,
  34183. 0xd6,
  34184. 0x26,
  34185. 0xe1,
  34186. 0x69,
  34187. 0x14,
  34188. 0x63,
  34189. 0x55,
  34190. 0x21,
  34191. 0x0c,
  34192. 0x7d
  34193. ]);
  34194. var mixCol = new Uint8Array(256);
  34195. for (var i = 0; i < 256; i++) {
  34196. if (i < 128) {
  34197. mixCol[i] = i << 1;
  34198. } else {
  34199. mixCol[i] = i << 1 ^ 0x1b;
  34200. }
  34201. }
  34202. var mix = new Uint32Array([
  34203. 0x00000000,
  34204. 0x0e090d0b,
  34205. 0x1c121a16,
  34206. 0x121b171d,
  34207. 0x3824342c,
  34208. 0x362d3927,
  34209. 0x24362e3a,
  34210. 0x2a3f2331,
  34211. 0x70486858,
  34212. 0x7e416553,
  34213. 0x6c5a724e,
  34214. 0x62537f45,
  34215. 0x486c5c74,
  34216. 0x4665517f,
  34217. 0x547e4662,
  34218. 0x5a774b69,
  34219. 0xe090d0b0,
  34220. 0xee99ddbb,
  34221. 0xfc82caa6,
  34222. 0xf28bc7ad,
  34223. 0xd8b4e49c,
  34224. 0xd6bde997,
  34225. 0xc4a6fe8a,
  34226. 0xcaaff381,
  34227. 0x90d8b8e8,
  34228. 0x9ed1b5e3,
  34229. 0x8ccaa2fe,
  34230. 0x82c3aff5,
  34231. 0xa8fc8cc4,
  34232. 0xa6f581cf,
  34233. 0xb4ee96d2,
  34234. 0xbae79bd9,
  34235. 0xdb3bbb7b,
  34236. 0xd532b670,
  34237. 0xc729a16d,
  34238. 0xc920ac66,
  34239. 0xe31f8f57,
  34240. 0xed16825c,
  34241. 0xff0d9541,
  34242. 0xf104984a,
  34243. 0xab73d323,
  34244. 0xa57ade28,
  34245. 0xb761c935,
  34246. 0xb968c43e,
  34247. 0x9357e70f,
  34248. 0x9d5eea04,
  34249. 0x8f45fd19,
  34250. 0x814cf012,
  34251. 0x3bab6bcb,
  34252. 0x35a266c0,
  34253. 0x27b971dd,
  34254. 0x29b07cd6,
  34255. 0x038f5fe7,
  34256. 0x0d8652ec,
  34257. 0x1f9d45f1,
  34258. 0x119448fa,
  34259. 0x4be30393,
  34260. 0x45ea0e98,
  34261. 0x57f11985,
  34262. 0x59f8148e,
  34263. 0x73c737bf,
  34264. 0x7dce3ab4,
  34265. 0x6fd52da9,
  34266. 0x61dc20a2,
  34267. 0xad766df6,
  34268. 0xa37f60fd,
  34269. 0xb16477e0,
  34270. 0xbf6d7aeb,
  34271. 0x955259da,
  34272. 0x9b5b54d1,
  34273. 0x894043cc,
  34274. 0x87494ec7,
  34275. 0xdd3e05ae,
  34276. 0xd33708a5,
  34277. 0xc12c1fb8,
  34278. 0xcf2512b3,
  34279. 0xe51a3182,
  34280. 0xeb133c89,
  34281. 0xf9082b94,
  34282. 0xf701269f,
  34283. 0x4de6bd46,
  34284. 0x43efb04d,
  34285. 0x51f4a750,
  34286. 0x5ffdaa5b,
  34287. 0x75c2896a,
  34288. 0x7bcb8461,
  34289. 0x69d0937c,
  34290. 0x67d99e77,
  34291. 0x3daed51e,
  34292. 0x33a7d815,
  34293. 0x21bccf08,
  34294. 0x2fb5c203,
  34295. 0x058ae132,
  34296. 0x0b83ec39,
  34297. 0x1998fb24,
  34298. 0x1791f62f,
  34299. 0x764dd68d,
  34300. 0x7844db86,
  34301. 0x6a5fcc9b,
  34302. 0x6456c190,
  34303. 0x4e69e2a1,
  34304. 0x4060efaa,
  34305. 0x527bf8b7,
  34306. 0x5c72f5bc,
  34307. 0x0605bed5,
  34308. 0x080cb3de,
  34309. 0x1a17a4c3,
  34310. 0x141ea9c8,
  34311. 0x3e218af9,
  34312. 0x302887f2,
  34313. 0x223390ef,
  34314. 0x2c3a9de4,
  34315. 0x96dd063d,
  34316. 0x98d40b36,
  34317. 0x8acf1c2b,
  34318. 0x84c61120,
  34319. 0xaef93211,
  34320. 0xa0f03f1a,
  34321. 0xb2eb2807,
  34322. 0xbce2250c,
  34323. 0xe6956e65,
  34324. 0xe89c636e,
  34325. 0xfa877473,
  34326. 0xf48e7978,
  34327. 0xdeb15a49,
  34328. 0xd0b85742,
  34329. 0xc2a3405f,
  34330. 0xccaa4d54,
  34331. 0x41ecdaf7,
  34332. 0x4fe5d7fc,
  34333. 0x5dfec0e1,
  34334. 0x53f7cdea,
  34335. 0x79c8eedb,
  34336. 0x77c1e3d0,
  34337. 0x65daf4cd,
  34338. 0x6bd3f9c6,
  34339. 0x31a4b2af,
  34340. 0x3fadbfa4,
  34341. 0x2db6a8b9,
  34342. 0x23bfa5b2,
  34343. 0x09808683,
  34344. 0x07898b88,
  34345. 0x15929c95,
  34346. 0x1b9b919e,
  34347. 0xa17c0a47,
  34348. 0xaf75074c,
  34349. 0xbd6e1051,
  34350. 0xb3671d5a,
  34351. 0x99583e6b,
  34352. 0x97513360,
  34353. 0x854a247d,
  34354. 0x8b432976,
  34355. 0xd134621f,
  34356. 0xdf3d6f14,
  34357. 0xcd267809,
  34358. 0xc32f7502,
  34359. 0xe9105633,
  34360. 0xe7195b38,
  34361. 0xf5024c25,
  34362. 0xfb0b412e,
  34363. 0x9ad7618c,
  34364. 0x94de6c87,
  34365. 0x86c57b9a,
  34366. 0x88cc7691,
  34367. 0xa2f355a0,
  34368. 0xacfa58ab,
  34369. 0xbee14fb6,
  34370. 0xb0e842bd,
  34371. 0xea9f09d4,
  34372. 0xe49604df,
  34373. 0xf68d13c2,
  34374. 0xf8841ec9,
  34375. 0xd2bb3df8,
  34376. 0xdcb230f3,
  34377. 0xcea927ee,
  34378. 0xc0a02ae5,
  34379. 0x7a47b13c,
  34380. 0x744ebc37,
  34381. 0x6655ab2a,
  34382. 0x685ca621,
  34383. 0x42638510,
  34384. 0x4c6a881b,
  34385. 0x5e719f06,
  34386. 0x5078920d,
  34387. 0x0a0fd964,
  34388. 0x0406d46f,
  34389. 0x161dc372,
  34390. 0x1814ce79,
  34391. 0x322bed48,
  34392. 0x3c22e043,
  34393. 0x2e39f75e,
  34394. 0x2030fa55,
  34395. 0xec9ab701,
  34396. 0xe293ba0a,
  34397. 0xf088ad17,
  34398. 0xfe81a01c,
  34399. 0xd4be832d,
  34400. 0xdab78e26,
  34401. 0xc8ac993b,
  34402. 0xc6a59430,
  34403. 0x9cd2df59,
  34404. 0x92dbd252,
  34405. 0x80c0c54f,
  34406. 0x8ec9c844,
  34407. 0xa4f6eb75,
  34408. 0xaaffe67e,
  34409. 0xb8e4f163,
  34410. 0xb6edfc68,
  34411. 0x0c0a67b1,
  34412. 0x02036aba,
  34413. 0x10187da7,
  34414. 0x1e1170ac,
  34415. 0x342e539d,
  34416. 0x3a275e96,
  34417. 0x283c498b,
  34418. 0x26354480,
  34419. 0x7c420fe9,
  34420. 0x724b02e2,
  34421. 0x605015ff,
  34422. 0x6e5918f4,
  34423. 0x44663bc5,
  34424. 0x4a6f36ce,
  34425. 0x587421d3,
  34426. 0x567d2cd8,
  34427. 0x37a10c7a,
  34428. 0x39a80171,
  34429. 0x2bb3166c,
  34430. 0x25ba1b67,
  34431. 0x0f853856,
  34432. 0x018c355d,
  34433. 0x13972240,
  34434. 0x1d9e2f4b,
  34435. 0x47e96422,
  34436. 0x49e06929,
  34437. 0x5bfb7e34,
  34438. 0x55f2733f,
  34439. 0x7fcd500e,
  34440. 0x71c45d05,
  34441. 0x63df4a18,
  34442. 0x6dd64713,
  34443. 0xd731dcca,
  34444. 0xd938d1c1,
  34445. 0xcb23c6dc,
  34446. 0xc52acbd7,
  34447. 0xef15e8e6,
  34448. 0xe11ce5ed,
  34449. 0xf307f2f0,
  34450. 0xfd0efffb,
  34451. 0xa779b492,
  34452. 0xa970b999,
  34453. 0xbb6bae84,
  34454. 0xb562a38f,
  34455. 0x9f5d80be,
  34456. 0x91548db5,
  34457. 0x834f9aa8,
  34458. 0x8d4697a3
  34459. ]);
  34460. function expandKey128(cipherKey) {
  34461. var b = 176, result = new Uint8Array(b);
  34462. result.set(cipherKey);
  34463. for (var j = 16, i = 1; j < b; ++i) {
  34464. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  34465. t1 = s[t1];
  34466. t2 = s[t2];
  34467. t3 = s[t3];
  34468. t4 = s[t4];
  34469. t1 = t1 ^ rcon[i];
  34470. for (var n = 0; n < 4; ++n) {
  34471. result[j] = t1 ^= result[j - 16];
  34472. j++;
  34473. result[j] = t2 ^= result[j - 16];
  34474. j++;
  34475. result[j] = t3 ^= result[j - 16];
  34476. j++;
  34477. result[j] = t4 ^= result[j - 16];
  34478. j++;
  34479. }
  34480. }
  34481. return result;
  34482. }
  34483. function decrypt128(input, key) {
  34484. var state = new Uint8Array(16);
  34485. state.set(input);
  34486. var i, j, k;
  34487. var t, u, v;
  34488. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34489. state[j] ^= key[k];
  34490. }
  34491. for (i = 9; i >= 1; --i) {
  34492. t = state[13];
  34493. state[13] = state[9];
  34494. state[9] = state[5];
  34495. state[5] = state[1];
  34496. state[1] = t;
  34497. t = state[14];
  34498. u = state[10];
  34499. state[14] = state[6];
  34500. state[10] = state[2];
  34501. state[6] = t;
  34502. state[2] = u;
  34503. t = state[15];
  34504. u = state[11];
  34505. v = state[7];
  34506. state[15] = state[3];
  34507. state[11] = t;
  34508. state[7] = u;
  34509. state[3] = v;
  34510. for (j = 0; j < 16; ++j) {
  34511. state[j] = inv_s[state[j]];
  34512. }
  34513. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34514. state[j] ^= key[k];
  34515. }
  34516. for (j = 0; j < 16; j += 4) {
  34517. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  34518. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  34519. state[j] = t >>> 24 & 0xFF;
  34520. state[j + 1] = t >> 16 & 0xFF;
  34521. state[j + 2] = t >> 8 & 0xFF;
  34522. state[j + 3] = t & 0xFF;
  34523. }
  34524. }
  34525. t = state[13];
  34526. state[13] = state[9];
  34527. state[9] = state[5];
  34528. state[5] = state[1];
  34529. state[1] = t;
  34530. t = state[14];
  34531. u = state[10];
  34532. state[14] = state[6];
  34533. state[10] = state[2];
  34534. state[6] = t;
  34535. state[2] = u;
  34536. t = state[15];
  34537. u = state[11];
  34538. v = state[7];
  34539. state[15] = state[3];
  34540. state[11] = t;
  34541. state[7] = u;
  34542. state[3] = v;
  34543. for (j = 0; j < 16; ++j) {
  34544. state[j] = inv_s[state[j]];
  34545. state[j] ^= key[j];
  34546. }
  34547. return state;
  34548. }
  34549. function encrypt128(input, key) {
  34550. var t, u, v, k;
  34551. var state = new Uint8Array(16);
  34552. state.set(input);
  34553. for (j = 0; j < 16; ++j) {
  34554. state[j] ^= key[j];
  34555. }
  34556. for (i = 1; i < 10; i++) {
  34557. for (j = 0; j < 16; ++j) {
  34558. state[j] = s[state[j]];
  34559. }
  34560. v = state[1];
  34561. state[1] = state[5];
  34562. state[5] = state[9];
  34563. state[9] = state[13];
  34564. state[13] = v;
  34565. v = state[2];
  34566. u = state[6];
  34567. state[2] = state[10];
  34568. state[6] = state[14];
  34569. state[10] = v;
  34570. state[14] = u;
  34571. v = state[3];
  34572. u = state[7];
  34573. t = state[11];
  34574. state[3] = state[15];
  34575. state[7] = v;
  34576. state[11] = u;
  34577. state[15] = t;
  34578. for (var j = 0; j < 16; j += 4) {
  34579. var s0 = state[j + 0], s1 = state[j + 1];
  34580. var s2 = state[j + 2], s3 = state[j + 3];
  34581. t = s0 ^ s1 ^ s2 ^ s3;
  34582. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  34583. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  34584. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  34585. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  34586. }
  34587. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  34588. state[j] ^= key[k];
  34589. }
  34590. }
  34591. for (j = 0; j < 16; ++j) {
  34592. state[j] = s[state[j]];
  34593. }
  34594. v = state[1];
  34595. state[1] = state[5];
  34596. state[5] = state[9];
  34597. state[9] = state[13];
  34598. state[13] = v;
  34599. v = state[2];
  34600. u = state[6];
  34601. state[2] = state[10];
  34602. state[6] = state[14];
  34603. state[10] = v;
  34604. state[14] = u;
  34605. v = state[3];
  34606. u = state[7];
  34607. t = state[11];
  34608. state[3] = state[15];
  34609. state[7] = v;
  34610. state[11] = u;
  34611. state[15] = t;
  34612. for (j = 0, k = 160; j < 16; ++j, ++k) {
  34613. state[j] ^= key[k];
  34614. }
  34615. return state;
  34616. }
  34617. function AES128Cipher(key) {
  34618. this.key = expandKey128(key);
  34619. this.buffer = new Uint8Array(16);
  34620. this.bufferPosition = 0;
  34621. }
  34622. function decryptBlock2(data, finalize) {
  34623. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  34624. for (i = 0; i < sourceLength; ++i) {
  34625. buffer[bufferLength] = data[i];
  34626. ++bufferLength;
  34627. if (bufferLength < 16) {
  34628. continue;
  34629. }
  34630. var plain = decrypt128(buffer, this.key);
  34631. for (j = 0; j < 16; ++j) {
  34632. plain[j] ^= iv[j];
  34633. }
  34634. iv = buffer;
  34635. result.push(plain);
  34636. buffer = new Uint8Array(16);
  34637. bufferLength = 0;
  34638. }
  34639. this.buffer = buffer;
  34640. this.bufferLength = bufferLength;
  34641. this.iv = iv;
  34642. if (result.length === 0) {
  34643. return new Uint8Array([]);
  34644. }
  34645. var outputLength = 16 * result.length;
  34646. if (finalize) {
  34647. var lastBlock = result[result.length - 1];
  34648. var psLen = lastBlock[15];
  34649. if (psLen <= 16) {
  34650. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  34651. if (lastBlock[i] !== psLen) {
  34652. psLen = 0;
  34653. break;
  34654. }
  34655. }
  34656. outputLength -= psLen;
  34657. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  34658. }
  34659. }
  34660. var output = new Uint8Array(outputLength);
  34661. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34662. output.set(result[i], j);
  34663. }
  34664. return output;
  34665. }
  34666. AES128Cipher.prototype = {
  34667. decryptBlock: function AES128Cipher_decryptBlock(data, finalize) {
  34668. var i, sourceLength = data.length;
  34669. var buffer = this.buffer, bufferLength = this.bufferPosition;
  34670. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  34671. buffer[bufferLength] = data[i];
  34672. }
  34673. if (bufferLength < 16) {
  34674. this.bufferLength = bufferLength;
  34675. return new Uint8Array([]);
  34676. }
  34677. this.iv = buffer;
  34678. this.buffer = new Uint8Array(16);
  34679. this.bufferLength = 0;
  34680. this.decryptBlock = decryptBlock2;
  34681. return this.decryptBlock(data.subarray(16), finalize);
  34682. },
  34683. encrypt: function AES128Cipher_encrypt(data, iv) {
  34684. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  34685. if (!iv) {
  34686. iv = new Uint8Array(16);
  34687. }
  34688. for (i = 0; i < sourceLength; ++i) {
  34689. buffer[bufferLength] = data[i];
  34690. ++bufferLength;
  34691. if (bufferLength < 16) {
  34692. continue;
  34693. }
  34694. for (j = 0; j < 16; ++j) {
  34695. buffer[j] ^= iv[j];
  34696. }
  34697. var cipher = encrypt128(buffer, this.key);
  34698. iv = cipher;
  34699. result.push(cipher);
  34700. buffer = new Uint8Array(16);
  34701. bufferLength = 0;
  34702. }
  34703. this.buffer = buffer;
  34704. this.bufferLength = bufferLength;
  34705. this.iv = iv;
  34706. if (result.length === 0) {
  34707. return new Uint8Array([]);
  34708. }
  34709. var outputLength = 16 * result.length;
  34710. var output = new Uint8Array(outputLength);
  34711. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  34712. output.set(result[i], j);
  34713. }
  34714. return output;
  34715. }
  34716. };
  34717. return AES128Cipher;
  34718. }();
  34719. var AES256Cipher = function AES256CipherClosure() {
  34720. var rcon = new Uint8Array([
  34721. 0x8d,
  34722. 0x01,
  34723. 0x02,
  34724. 0x04,
  34725. 0x08,
  34726. 0x10,
  34727. 0x20,
  34728. 0x40,
  34729. 0x80,
  34730. 0x1b,
  34731. 0x36,
  34732. 0x6c,
  34733. 0xd8,
  34734. 0xab,
  34735. 0x4d,
  34736. 0x9a,
  34737. 0x2f,
  34738. 0x5e,
  34739. 0xbc,
  34740. 0x63,
  34741. 0xc6,
  34742. 0x97,
  34743. 0x35,
  34744. 0x6a,
  34745. 0xd4,
  34746. 0xb3,
  34747. 0x7d,
  34748. 0xfa,
  34749. 0xef,
  34750. 0xc5,
  34751. 0x91,
  34752. 0x39,
  34753. 0x72,
  34754. 0xe4,
  34755. 0xd3,
  34756. 0xbd,
  34757. 0x61,
  34758. 0xc2,
  34759. 0x9f,
  34760. 0x25,
  34761. 0x4a,
  34762. 0x94,
  34763. 0x33,
  34764. 0x66,
  34765. 0xcc,
  34766. 0x83,
  34767. 0x1d,
  34768. 0x3a,
  34769. 0x74,
  34770. 0xe8,
  34771. 0xcb,
  34772. 0x8d,
  34773. 0x01,
  34774. 0x02,
  34775. 0x04,
  34776. 0x08,
  34777. 0x10,
  34778. 0x20,
  34779. 0x40,
  34780. 0x80,
  34781. 0x1b,
  34782. 0x36,
  34783. 0x6c,
  34784. 0xd8,
  34785. 0xab,
  34786. 0x4d,
  34787. 0x9a,
  34788. 0x2f,
  34789. 0x5e,
  34790. 0xbc,
  34791. 0x63,
  34792. 0xc6,
  34793. 0x97,
  34794. 0x35,
  34795. 0x6a,
  34796. 0xd4,
  34797. 0xb3,
  34798. 0x7d,
  34799. 0xfa,
  34800. 0xef,
  34801. 0xc5,
  34802. 0x91,
  34803. 0x39,
  34804. 0x72,
  34805. 0xe4,
  34806. 0xd3,
  34807. 0xbd,
  34808. 0x61,
  34809. 0xc2,
  34810. 0x9f,
  34811. 0x25,
  34812. 0x4a,
  34813. 0x94,
  34814. 0x33,
  34815. 0x66,
  34816. 0xcc,
  34817. 0x83,
  34818. 0x1d,
  34819. 0x3a,
  34820. 0x74,
  34821. 0xe8,
  34822. 0xcb,
  34823. 0x8d,
  34824. 0x01,
  34825. 0x02,
  34826. 0x04,
  34827. 0x08,
  34828. 0x10,
  34829. 0x20,
  34830. 0x40,
  34831. 0x80,
  34832. 0x1b,
  34833. 0x36,
  34834. 0x6c,
  34835. 0xd8,
  34836. 0xab,
  34837. 0x4d,
  34838. 0x9a,
  34839. 0x2f,
  34840. 0x5e,
  34841. 0xbc,
  34842. 0x63,
  34843. 0xc6,
  34844. 0x97,
  34845. 0x35,
  34846. 0x6a,
  34847. 0xd4,
  34848. 0xb3,
  34849. 0x7d,
  34850. 0xfa,
  34851. 0xef,
  34852. 0xc5,
  34853. 0x91,
  34854. 0x39,
  34855. 0x72,
  34856. 0xe4,
  34857. 0xd3,
  34858. 0xbd,
  34859. 0x61,
  34860. 0xc2,
  34861. 0x9f,
  34862. 0x25,
  34863. 0x4a,
  34864. 0x94,
  34865. 0x33,
  34866. 0x66,
  34867. 0xcc,
  34868. 0x83,
  34869. 0x1d,
  34870. 0x3a,
  34871. 0x74,
  34872. 0xe8,
  34873. 0xcb,
  34874. 0x8d,
  34875. 0x01,
  34876. 0x02,
  34877. 0x04,
  34878. 0x08,
  34879. 0x10,
  34880. 0x20,
  34881. 0x40,
  34882. 0x80,
  34883. 0x1b,
  34884. 0x36,
  34885. 0x6c,
  34886. 0xd8,
  34887. 0xab,
  34888. 0x4d,
  34889. 0x9a,
  34890. 0x2f,
  34891. 0x5e,
  34892. 0xbc,
  34893. 0x63,
  34894. 0xc6,
  34895. 0x97,
  34896. 0x35,
  34897. 0x6a,
  34898. 0xd4,
  34899. 0xb3,
  34900. 0x7d,
  34901. 0xfa,
  34902. 0xef,
  34903. 0xc5,
  34904. 0x91,
  34905. 0x39,
  34906. 0x72,
  34907. 0xe4,
  34908. 0xd3,
  34909. 0xbd,
  34910. 0x61,
  34911. 0xc2,
  34912. 0x9f,
  34913. 0x25,
  34914. 0x4a,
  34915. 0x94,
  34916. 0x33,
  34917. 0x66,
  34918. 0xcc,
  34919. 0x83,
  34920. 0x1d,
  34921. 0x3a,
  34922. 0x74,
  34923. 0xe8,
  34924. 0xcb,
  34925. 0x8d,
  34926. 0x01,
  34927. 0x02,
  34928. 0x04,
  34929. 0x08,
  34930. 0x10,
  34931. 0x20,
  34932. 0x40,
  34933. 0x80,
  34934. 0x1b,
  34935. 0x36,
  34936. 0x6c,
  34937. 0xd8,
  34938. 0xab,
  34939. 0x4d,
  34940. 0x9a,
  34941. 0x2f,
  34942. 0x5e,
  34943. 0xbc,
  34944. 0x63,
  34945. 0xc6,
  34946. 0x97,
  34947. 0x35,
  34948. 0x6a,
  34949. 0xd4,
  34950. 0xb3,
  34951. 0x7d,
  34952. 0xfa,
  34953. 0xef,
  34954. 0xc5,
  34955. 0x91,
  34956. 0x39,
  34957. 0x72,
  34958. 0xe4,
  34959. 0xd3,
  34960. 0xbd,
  34961. 0x61,
  34962. 0xc2,
  34963. 0x9f,
  34964. 0x25,
  34965. 0x4a,
  34966. 0x94,
  34967. 0x33,
  34968. 0x66,
  34969. 0xcc,
  34970. 0x83,
  34971. 0x1d,
  34972. 0x3a,
  34973. 0x74,
  34974. 0xe8,
  34975. 0xcb,
  34976. 0x8d
  34977. ]);
  34978. var s = new Uint8Array([
  34979. 0x63,
  34980. 0x7c,
  34981. 0x77,
  34982. 0x7b,
  34983. 0xf2,
  34984. 0x6b,
  34985. 0x6f,
  34986. 0xc5,
  34987. 0x30,
  34988. 0x01,
  34989. 0x67,
  34990. 0x2b,
  34991. 0xfe,
  34992. 0xd7,
  34993. 0xab,
  34994. 0x76,
  34995. 0xca,
  34996. 0x82,
  34997. 0xc9,
  34998. 0x7d,
  34999. 0xfa,
  35000. 0x59,
  35001. 0x47,
  35002. 0xf0,
  35003. 0xad,
  35004. 0xd4,
  35005. 0xa2,
  35006. 0xaf,
  35007. 0x9c,
  35008. 0xa4,
  35009. 0x72,
  35010. 0xc0,
  35011. 0xb7,
  35012. 0xfd,
  35013. 0x93,
  35014. 0x26,
  35015. 0x36,
  35016. 0x3f,
  35017. 0xf7,
  35018. 0xcc,
  35019. 0x34,
  35020. 0xa5,
  35021. 0xe5,
  35022. 0xf1,
  35023. 0x71,
  35024. 0xd8,
  35025. 0x31,
  35026. 0x15,
  35027. 0x04,
  35028. 0xc7,
  35029. 0x23,
  35030. 0xc3,
  35031. 0x18,
  35032. 0x96,
  35033. 0x05,
  35034. 0x9a,
  35035. 0x07,
  35036. 0x12,
  35037. 0x80,
  35038. 0xe2,
  35039. 0xeb,
  35040. 0x27,
  35041. 0xb2,
  35042. 0x75,
  35043. 0x09,
  35044. 0x83,
  35045. 0x2c,
  35046. 0x1a,
  35047. 0x1b,
  35048. 0x6e,
  35049. 0x5a,
  35050. 0xa0,
  35051. 0x52,
  35052. 0x3b,
  35053. 0xd6,
  35054. 0xb3,
  35055. 0x29,
  35056. 0xe3,
  35057. 0x2f,
  35058. 0x84,
  35059. 0x53,
  35060. 0xd1,
  35061. 0x00,
  35062. 0xed,
  35063. 0x20,
  35064. 0xfc,
  35065. 0xb1,
  35066. 0x5b,
  35067. 0x6a,
  35068. 0xcb,
  35069. 0xbe,
  35070. 0x39,
  35071. 0x4a,
  35072. 0x4c,
  35073. 0x58,
  35074. 0xcf,
  35075. 0xd0,
  35076. 0xef,
  35077. 0xaa,
  35078. 0xfb,
  35079. 0x43,
  35080. 0x4d,
  35081. 0x33,
  35082. 0x85,
  35083. 0x45,
  35084. 0xf9,
  35085. 0x02,
  35086. 0x7f,
  35087. 0x50,
  35088. 0x3c,
  35089. 0x9f,
  35090. 0xa8,
  35091. 0x51,
  35092. 0xa3,
  35093. 0x40,
  35094. 0x8f,
  35095. 0x92,
  35096. 0x9d,
  35097. 0x38,
  35098. 0xf5,
  35099. 0xbc,
  35100. 0xb6,
  35101. 0xda,
  35102. 0x21,
  35103. 0x10,
  35104. 0xff,
  35105. 0xf3,
  35106. 0xd2,
  35107. 0xcd,
  35108. 0x0c,
  35109. 0x13,
  35110. 0xec,
  35111. 0x5f,
  35112. 0x97,
  35113. 0x44,
  35114. 0x17,
  35115. 0xc4,
  35116. 0xa7,
  35117. 0x7e,
  35118. 0x3d,
  35119. 0x64,
  35120. 0x5d,
  35121. 0x19,
  35122. 0x73,
  35123. 0x60,
  35124. 0x81,
  35125. 0x4f,
  35126. 0xdc,
  35127. 0x22,
  35128. 0x2a,
  35129. 0x90,
  35130. 0x88,
  35131. 0x46,
  35132. 0xee,
  35133. 0xb8,
  35134. 0x14,
  35135. 0xde,
  35136. 0x5e,
  35137. 0x0b,
  35138. 0xdb,
  35139. 0xe0,
  35140. 0x32,
  35141. 0x3a,
  35142. 0x0a,
  35143. 0x49,
  35144. 0x06,
  35145. 0x24,
  35146. 0x5c,
  35147. 0xc2,
  35148. 0xd3,
  35149. 0xac,
  35150. 0x62,
  35151. 0x91,
  35152. 0x95,
  35153. 0xe4,
  35154. 0x79,
  35155. 0xe7,
  35156. 0xc8,
  35157. 0x37,
  35158. 0x6d,
  35159. 0x8d,
  35160. 0xd5,
  35161. 0x4e,
  35162. 0xa9,
  35163. 0x6c,
  35164. 0x56,
  35165. 0xf4,
  35166. 0xea,
  35167. 0x65,
  35168. 0x7a,
  35169. 0xae,
  35170. 0x08,
  35171. 0xba,
  35172. 0x78,
  35173. 0x25,
  35174. 0x2e,
  35175. 0x1c,
  35176. 0xa6,
  35177. 0xb4,
  35178. 0xc6,
  35179. 0xe8,
  35180. 0xdd,
  35181. 0x74,
  35182. 0x1f,
  35183. 0x4b,
  35184. 0xbd,
  35185. 0x8b,
  35186. 0x8a,
  35187. 0x70,
  35188. 0x3e,
  35189. 0xb5,
  35190. 0x66,
  35191. 0x48,
  35192. 0x03,
  35193. 0xf6,
  35194. 0x0e,
  35195. 0x61,
  35196. 0x35,
  35197. 0x57,
  35198. 0xb9,
  35199. 0x86,
  35200. 0xc1,
  35201. 0x1d,
  35202. 0x9e,
  35203. 0xe1,
  35204. 0xf8,
  35205. 0x98,
  35206. 0x11,
  35207. 0x69,
  35208. 0xd9,
  35209. 0x8e,
  35210. 0x94,
  35211. 0x9b,
  35212. 0x1e,
  35213. 0x87,
  35214. 0xe9,
  35215. 0xce,
  35216. 0x55,
  35217. 0x28,
  35218. 0xdf,
  35219. 0x8c,
  35220. 0xa1,
  35221. 0x89,
  35222. 0x0d,
  35223. 0xbf,
  35224. 0xe6,
  35225. 0x42,
  35226. 0x68,
  35227. 0x41,
  35228. 0x99,
  35229. 0x2d,
  35230. 0x0f,
  35231. 0xb0,
  35232. 0x54,
  35233. 0xbb,
  35234. 0x16
  35235. ]);
  35236. var inv_s = new Uint8Array([
  35237. 0x52,
  35238. 0x09,
  35239. 0x6a,
  35240. 0xd5,
  35241. 0x30,
  35242. 0x36,
  35243. 0xa5,
  35244. 0x38,
  35245. 0xbf,
  35246. 0x40,
  35247. 0xa3,
  35248. 0x9e,
  35249. 0x81,
  35250. 0xf3,
  35251. 0xd7,
  35252. 0xfb,
  35253. 0x7c,
  35254. 0xe3,
  35255. 0x39,
  35256. 0x82,
  35257. 0x9b,
  35258. 0x2f,
  35259. 0xff,
  35260. 0x87,
  35261. 0x34,
  35262. 0x8e,
  35263. 0x43,
  35264. 0x44,
  35265. 0xc4,
  35266. 0xde,
  35267. 0xe9,
  35268. 0xcb,
  35269. 0x54,
  35270. 0x7b,
  35271. 0x94,
  35272. 0x32,
  35273. 0xa6,
  35274. 0xc2,
  35275. 0x23,
  35276. 0x3d,
  35277. 0xee,
  35278. 0x4c,
  35279. 0x95,
  35280. 0x0b,
  35281. 0x42,
  35282. 0xfa,
  35283. 0xc3,
  35284. 0x4e,
  35285. 0x08,
  35286. 0x2e,
  35287. 0xa1,
  35288. 0x66,
  35289. 0x28,
  35290. 0xd9,
  35291. 0x24,
  35292. 0xb2,
  35293. 0x76,
  35294. 0x5b,
  35295. 0xa2,
  35296. 0x49,
  35297. 0x6d,
  35298. 0x8b,
  35299. 0xd1,
  35300. 0x25,
  35301. 0x72,
  35302. 0xf8,
  35303. 0xf6,
  35304. 0x64,
  35305. 0x86,
  35306. 0x68,
  35307. 0x98,
  35308. 0x16,
  35309. 0xd4,
  35310. 0xa4,
  35311. 0x5c,
  35312. 0xcc,
  35313. 0x5d,
  35314. 0x65,
  35315. 0xb6,
  35316. 0x92,
  35317. 0x6c,
  35318. 0x70,
  35319. 0x48,
  35320. 0x50,
  35321. 0xfd,
  35322. 0xed,
  35323. 0xb9,
  35324. 0xda,
  35325. 0x5e,
  35326. 0x15,
  35327. 0x46,
  35328. 0x57,
  35329. 0xa7,
  35330. 0x8d,
  35331. 0x9d,
  35332. 0x84,
  35333. 0x90,
  35334. 0xd8,
  35335. 0xab,
  35336. 0x00,
  35337. 0x8c,
  35338. 0xbc,
  35339. 0xd3,
  35340. 0x0a,
  35341. 0xf7,
  35342. 0xe4,
  35343. 0x58,
  35344. 0x05,
  35345. 0xb8,
  35346. 0xb3,
  35347. 0x45,
  35348. 0x06,
  35349. 0xd0,
  35350. 0x2c,
  35351. 0x1e,
  35352. 0x8f,
  35353. 0xca,
  35354. 0x3f,
  35355. 0x0f,
  35356. 0x02,
  35357. 0xc1,
  35358. 0xaf,
  35359. 0xbd,
  35360. 0x03,
  35361. 0x01,
  35362. 0x13,
  35363. 0x8a,
  35364. 0x6b,
  35365. 0x3a,
  35366. 0x91,
  35367. 0x11,
  35368. 0x41,
  35369. 0x4f,
  35370. 0x67,
  35371. 0xdc,
  35372. 0xea,
  35373. 0x97,
  35374. 0xf2,
  35375. 0xcf,
  35376. 0xce,
  35377. 0xf0,
  35378. 0xb4,
  35379. 0xe6,
  35380. 0x73,
  35381. 0x96,
  35382. 0xac,
  35383. 0x74,
  35384. 0x22,
  35385. 0xe7,
  35386. 0xad,
  35387. 0x35,
  35388. 0x85,
  35389. 0xe2,
  35390. 0xf9,
  35391. 0x37,
  35392. 0xe8,
  35393. 0x1c,
  35394. 0x75,
  35395. 0xdf,
  35396. 0x6e,
  35397. 0x47,
  35398. 0xf1,
  35399. 0x1a,
  35400. 0x71,
  35401. 0x1d,
  35402. 0x29,
  35403. 0xc5,
  35404. 0x89,
  35405. 0x6f,
  35406. 0xb7,
  35407. 0x62,
  35408. 0x0e,
  35409. 0xaa,
  35410. 0x18,
  35411. 0xbe,
  35412. 0x1b,
  35413. 0xfc,
  35414. 0x56,
  35415. 0x3e,
  35416. 0x4b,
  35417. 0xc6,
  35418. 0xd2,
  35419. 0x79,
  35420. 0x20,
  35421. 0x9a,
  35422. 0xdb,
  35423. 0xc0,
  35424. 0xfe,
  35425. 0x78,
  35426. 0xcd,
  35427. 0x5a,
  35428. 0xf4,
  35429. 0x1f,
  35430. 0xdd,
  35431. 0xa8,
  35432. 0x33,
  35433. 0x88,
  35434. 0x07,
  35435. 0xc7,
  35436. 0x31,
  35437. 0xb1,
  35438. 0x12,
  35439. 0x10,
  35440. 0x59,
  35441. 0x27,
  35442. 0x80,
  35443. 0xec,
  35444. 0x5f,
  35445. 0x60,
  35446. 0x51,
  35447. 0x7f,
  35448. 0xa9,
  35449. 0x19,
  35450. 0xb5,
  35451. 0x4a,
  35452. 0x0d,
  35453. 0x2d,
  35454. 0xe5,
  35455. 0x7a,
  35456. 0x9f,
  35457. 0x93,
  35458. 0xc9,
  35459. 0x9c,
  35460. 0xef,
  35461. 0xa0,
  35462. 0xe0,
  35463. 0x3b,
  35464. 0x4d,
  35465. 0xae,
  35466. 0x2a,
  35467. 0xf5,
  35468. 0xb0,
  35469. 0xc8,
  35470. 0xeb,
  35471. 0xbb,
  35472. 0x3c,
  35473. 0x83,
  35474. 0x53,
  35475. 0x99,
  35476. 0x61,
  35477. 0x17,
  35478. 0x2b,
  35479. 0x04,
  35480. 0x7e,
  35481. 0xba,
  35482. 0x77,
  35483. 0xd6,
  35484. 0x26,
  35485. 0xe1,
  35486. 0x69,
  35487. 0x14,
  35488. 0x63,
  35489. 0x55,
  35490. 0x21,
  35491. 0x0c,
  35492. 0x7d
  35493. ]);
  35494. var mixCol = new Uint8Array(256);
  35495. for (var i = 0; i < 256; i++) {
  35496. if (i < 128) {
  35497. mixCol[i] = i << 1;
  35498. } else {
  35499. mixCol[i] = i << 1 ^ 0x1b;
  35500. }
  35501. }
  35502. var mix = new Uint32Array([
  35503. 0x00000000,
  35504. 0x0e090d0b,
  35505. 0x1c121a16,
  35506. 0x121b171d,
  35507. 0x3824342c,
  35508. 0x362d3927,
  35509. 0x24362e3a,
  35510. 0x2a3f2331,
  35511. 0x70486858,
  35512. 0x7e416553,
  35513. 0x6c5a724e,
  35514. 0x62537f45,
  35515. 0x486c5c74,
  35516. 0x4665517f,
  35517. 0x547e4662,
  35518. 0x5a774b69,
  35519. 0xe090d0b0,
  35520. 0xee99ddbb,
  35521. 0xfc82caa6,
  35522. 0xf28bc7ad,
  35523. 0xd8b4e49c,
  35524. 0xd6bde997,
  35525. 0xc4a6fe8a,
  35526. 0xcaaff381,
  35527. 0x90d8b8e8,
  35528. 0x9ed1b5e3,
  35529. 0x8ccaa2fe,
  35530. 0x82c3aff5,
  35531. 0xa8fc8cc4,
  35532. 0xa6f581cf,
  35533. 0xb4ee96d2,
  35534. 0xbae79bd9,
  35535. 0xdb3bbb7b,
  35536. 0xd532b670,
  35537. 0xc729a16d,
  35538. 0xc920ac66,
  35539. 0xe31f8f57,
  35540. 0xed16825c,
  35541. 0xff0d9541,
  35542. 0xf104984a,
  35543. 0xab73d323,
  35544. 0xa57ade28,
  35545. 0xb761c935,
  35546. 0xb968c43e,
  35547. 0x9357e70f,
  35548. 0x9d5eea04,
  35549. 0x8f45fd19,
  35550. 0x814cf012,
  35551. 0x3bab6bcb,
  35552. 0x35a266c0,
  35553. 0x27b971dd,
  35554. 0x29b07cd6,
  35555. 0x038f5fe7,
  35556. 0x0d8652ec,
  35557. 0x1f9d45f1,
  35558. 0x119448fa,
  35559. 0x4be30393,
  35560. 0x45ea0e98,
  35561. 0x57f11985,
  35562. 0x59f8148e,
  35563. 0x73c737bf,
  35564. 0x7dce3ab4,
  35565. 0x6fd52da9,
  35566. 0x61dc20a2,
  35567. 0xad766df6,
  35568. 0xa37f60fd,
  35569. 0xb16477e0,
  35570. 0xbf6d7aeb,
  35571. 0x955259da,
  35572. 0x9b5b54d1,
  35573. 0x894043cc,
  35574. 0x87494ec7,
  35575. 0xdd3e05ae,
  35576. 0xd33708a5,
  35577. 0xc12c1fb8,
  35578. 0xcf2512b3,
  35579. 0xe51a3182,
  35580. 0xeb133c89,
  35581. 0xf9082b94,
  35582. 0xf701269f,
  35583. 0x4de6bd46,
  35584. 0x43efb04d,
  35585. 0x51f4a750,
  35586. 0x5ffdaa5b,
  35587. 0x75c2896a,
  35588. 0x7bcb8461,
  35589. 0x69d0937c,
  35590. 0x67d99e77,
  35591. 0x3daed51e,
  35592. 0x33a7d815,
  35593. 0x21bccf08,
  35594. 0x2fb5c203,
  35595. 0x058ae132,
  35596. 0x0b83ec39,
  35597. 0x1998fb24,
  35598. 0x1791f62f,
  35599. 0x764dd68d,
  35600. 0x7844db86,
  35601. 0x6a5fcc9b,
  35602. 0x6456c190,
  35603. 0x4e69e2a1,
  35604. 0x4060efaa,
  35605. 0x527bf8b7,
  35606. 0x5c72f5bc,
  35607. 0x0605bed5,
  35608. 0x080cb3de,
  35609. 0x1a17a4c3,
  35610. 0x141ea9c8,
  35611. 0x3e218af9,
  35612. 0x302887f2,
  35613. 0x223390ef,
  35614. 0x2c3a9de4,
  35615. 0x96dd063d,
  35616. 0x98d40b36,
  35617. 0x8acf1c2b,
  35618. 0x84c61120,
  35619. 0xaef93211,
  35620. 0xa0f03f1a,
  35621. 0xb2eb2807,
  35622. 0xbce2250c,
  35623. 0xe6956e65,
  35624. 0xe89c636e,
  35625. 0xfa877473,
  35626. 0xf48e7978,
  35627. 0xdeb15a49,
  35628. 0xd0b85742,
  35629. 0xc2a3405f,
  35630. 0xccaa4d54,
  35631. 0x41ecdaf7,
  35632. 0x4fe5d7fc,
  35633. 0x5dfec0e1,
  35634. 0x53f7cdea,
  35635. 0x79c8eedb,
  35636. 0x77c1e3d0,
  35637. 0x65daf4cd,
  35638. 0x6bd3f9c6,
  35639. 0x31a4b2af,
  35640. 0x3fadbfa4,
  35641. 0x2db6a8b9,
  35642. 0x23bfa5b2,
  35643. 0x09808683,
  35644. 0x07898b88,
  35645. 0x15929c95,
  35646. 0x1b9b919e,
  35647. 0xa17c0a47,
  35648. 0xaf75074c,
  35649. 0xbd6e1051,
  35650. 0xb3671d5a,
  35651. 0x99583e6b,
  35652. 0x97513360,
  35653. 0x854a247d,
  35654. 0x8b432976,
  35655. 0xd134621f,
  35656. 0xdf3d6f14,
  35657. 0xcd267809,
  35658. 0xc32f7502,
  35659. 0xe9105633,
  35660. 0xe7195b38,
  35661. 0xf5024c25,
  35662. 0xfb0b412e,
  35663. 0x9ad7618c,
  35664. 0x94de6c87,
  35665. 0x86c57b9a,
  35666. 0x88cc7691,
  35667. 0xa2f355a0,
  35668. 0xacfa58ab,
  35669. 0xbee14fb6,
  35670. 0xb0e842bd,
  35671. 0xea9f09d4,
  35672. 0xe49604df,
  35673. 0xf68d13c2,
  35674. 0xf8841ec9,
  35675. 0xd2bb3df8,
  35676. 0xdcb230f3,
  35677. 0xcea927ee,
  35678. 0xc0a02ae5,
  35679. 0x7a47b13c,
  35680. 0x744ebc37,
  35681. 0x6655ab2a,
  35682. 0x685ca621,
  35683. 0x42638510,
  35684. 0x4c6a881b,
  35685. 0x5e719f06,
  35686. 0x5078920d,
  35687. 0x0a0fd964,
  35688. 0x0406d46f,
  35689. 0x161dc372,
  35690. 0x1814ce79,
  35691. 0x322bed48,
  35692. 0x3c22e043,
  35693. 0x2e39f75e,
  35694. 0x2030fa55,
  35695. 0xec9ab701,
  35696. 0xe293ba0a,
  35697. 0xf088ad17,
  35698. 0xfe81a01c,
  35699. 0xd4be832d,
  35700. 0xdab78e26,
  35701. 0xc8ac993b,
  35702. 0xc6a59430,
  35703. 0x9cd2df59,
  35704. 0x92dbd252,
  35705. 0x80c0c54f,
  35706. 0x8ec9c844,
  35707. 0xa4f6eb75,
  35708. 0xaaffe67e,
  35709. 0xb8e4f163,
  35710. 0xb6edfc68,
  35711. 0x0c0a67b1,
  35712. 0x02036aba,
  35713. 0x10187da7,
  35714. 0x1e1170ac,
  35715. 0x342e539d,
  35716. 0x3a275e96,
  35717. 0x283c498b,
  35718. 0x26354480,
  35719. 0x7c420fe9,
  35720. 0x724b02e2,
  35721. 0x605015ff,
  35722. 0x6e5918f4,
  35723. 0x44663bc5,
  35724. 0x4a6f36ce,
  35725. 0x587421d3,
  35726. 0x567d2cd8,
  35727. 0x37a10c7a,
  35728. 0x39a80171,
  35729. 0x2bb3166c,
  35730. 0x25ba1b67,
  35731. 0x0f853856,
  35732. 0x018c355d,
  35733. 0x13972240,
  35734. 0x1d9e2f4b,
  35735. 0x47e96422,
  35736. 0x49e06929,
  35737. 0x5bfb7e34,
  35738. 0x55f2733f,
  35739. 0x7fcd500e,
  35740. 0x71c45d05,
  35741. 0x63df4a18,
  35742. 0x6dd64713,
  35743. 0xd731dcca,
  35744. 0xd938d1c1,
  35745. 0xcb23c6dc,
  35746. 0xc52acbd7,
  35747. 0xef15e8e6,
  35748. 0xe11ce5ed,
  35749. 0xf307f2f0,
  35750. 0xfd0efffb,
  35751. 0xa779b492,
  35752. 0xa970b999,
  35753. 0xbb6bae84,
  35754. 0xb562a38f,
  35755. 0x9f5d80be,
  35756. 0x91548db5,
  35757. 0x834f9aa8,
  35758. 0x8d4697a3
  35759. ]);
  35760. function expandKey256(cipherKey) {
  35761. var b = 240, result = new Uint8Array(b);
  35762. var r = 1;
  35763. result.set(cipherKey);
  35764. for (var j = 32, i = 1; j < b; ++i) {
  35765. if (j % 32 === 16) {
  35766. t1 = s[t1];
  35767. t2 = s[t2];
  35768. t3 = s[t3];
  35769. t4 = s[t4];
  35770. } else if (j % 32 === 0) {
  35771. var t1 = result[j - 3], t2 = result[j - 2], t3 = result[j - 1], t4 = result[j - 4];
  35772. t1 = s[t1];
  35773. t2 = s[t2];
  35774. t3 = s[t3];
  35775. t4 = s[t4];
  35776. t1 = t1 ^ r;
  35777. if ((r <<= 1) >= 256) {
  35778. r = (r ^ 0x1b) & 0xFF;
  35779. }
  35780. }
  35781. for (var n = 0; n < 4; ++n) {
  35782. result[j] = t1 ^= result[j - 32];
  35783. j++;
  35784. result[j] = t2 ^= result[j - 32];
  35785. j++;
  35786. result[j] = t3 ^= result[j - 32];
  35787. j++;
  35788. result[j] = t4 ^= result[j - 32];
  35789. j++;
  35790. }
  35791. }
  35792. return result;
  35793. }
  35794. function decrypt256(input, key) {
  35795. var state = new Uint8Array(16);
  35796. state.set(input);
  35797. var i, j, k;
  35798. var t, u, v;
  35799. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35800. state[j] ^= key[k];
  35801. }
  35802. for (i = 13; i >= 1; --i) {
  35803. t = state[13];
  35804. state[13] = state[9];
  35805. state[9] = state[5];
  35806. state[5] = state[1];
  35807. state[1] = t;
  35808. t = state[14];
  35809. u = state[10];
  35810. state[14] = state[6];
  35811. state[10] = state[2];
  35812. state[6] = t;
  35813. state[2] = u;
  35814. t = state[15];
  35815. u = state[11];
  35816. v = state[7];
  35817. state[15] = state[3];
  35818. state[11] = t;
  35819. state[7] = u;
  35820. state[3] = v;
  35821. for (j = 0; j < 16; ++j) {
  35822. state[j] = inv_s[state[j]];
  35823. }
  35824. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35825. state[j] ^= key[k];
  35826. }
  35827. for (j = 0; j < 16; j += 4) {
  35828. var s0 = mix[state[j]], s1 = mix[state[j + 1]], s2 = mix[state[j + 2]], s3 = mix[state[j + 3]];
  35829. t = s0 ^ s1 >>> 8 ^ s1 << 24 ^ s2 >>> 16 ^ s2 << 16 ^ s3 >>> 24 ^ s3 << 8;
  35830. state[j] = t >>> 24 & 0xFF;
  35831. state[j + 1] = t >> 16 & 0xFF;
  35832. state[j + 2] = t >> 8 & 0xFF;
  35833. state[j + 3] = t & 0xFF;
  35834. }
  35835. }
  35836. t = state[13];
  35837. state[13] = state[9];
  35838. state[9] = state[5];
  35839. state[5] = state[1];
  35840. state[1] = t;
  35841. t = state[14];
  35842. u = state[10];
  35843. state[14] = state[6];
  35844. state[10] = state[2];
  35845. state[6] = t;
  35846. state[2] = u;
  35847. t = state[15];
  35848. u = state[11];
  35849. v = state[7];
  35850. state[15] = state[3];
  35851. state[11] = t;
  35852. state[7] = u;
  35853. state[3] = v;
  35854. for (j = 0; j < 16; ++j) {
  35855. state[j] = inv_s[state[j]];
  35856. state[j] ^= key[j];
  35857. }
  35858. return state;
  35859. }
  35860. function encrypt256(input, key) {
  35861. var t, u, v, k;
  35862. var state = new Uint8Array(16);
  35863. state.set(input);
  35864. for (j = 0; j < 16; ++j) {
  35865. state[j] ^= key[j];
  35866. }
  35867. for (i = 1; i < 14; i++) {
  35868. for (j = 0; j < 16; ++j) {
  35869. state[j] = s[state[j]];
  35870. }
  35871. v = state[1];
  35872. state[1] = state[5];
  35873. state[5] = state[9];
  35874. state[9] = state[13];
  35875. state[13] = v;
  35876. v = state[2];
  35877. u = state[6];
  35878. state[2] = state[10];
  35879. state[6] = state[14];
  35880. state[10] = v;
  35881. state[14] = u;
  35882. v = state[3];
  35883. u = state[7];
  35884. t = state[11];
  35885. state[3] = state[15];
  35886. state[7] = v;
  35887. state[11] = u;
  35888. state[15] = t;
  35889. for (var j = 0; j < 16; j += 4) {
  35890. var s0 = state[j + 0], s1 = state[j + 1];
  35891. var s2 = state[j + 2], s3 = state[j + 3];
  35892. t = s0 ^ s1 ^ s2 ^ s3;
  35893. state[j + 0] ^= t ^ mixCol[s0 ^ s1];
  35894. state[j + 1] ^= t ^ mixCol[s1 ^ s2];
  35895. state[j + 2] ^= t ^ mixCol[s2 ^ s3];
  35896. state[j + 3] ^= t ^ mixCol[s3 ^ s0];
  35897. }
  35898. for (j = 0, k = i * 16; j < 16; ++j, ++k) {
  35899. state[j] ^= key[k];
  35900. }
  35901. }
  35902. for (j = 0; j < 16; ++j) {
  35903. state[j] = s[state[j]];
  35904. }
  35905. v = state[1];
  35906. state[1] = state[5];
  35907. state[5] = state[9];
  35908. state[9] = state[13];
  35909. state[13] = v;
  35910. v = state[2];
  35911. u = state[6];
  35912. state[2] = state[10];
  35913. state[6] = state[14];
  35914. state[10] = v;
  35915. state[14] = u;
  35916. v = state[3];
  35917. u = state[7];
  35918. t = state[11];
  35919. state[3] = state[15];
  35920. state[7] = v;
  35921. state[11] = u;
  35922. state[15] = t;
  35923. for (j = 0, k = 224; j < 16; ++j, ++k) {
  35924. state[j] ^= key[k];
  35925. }
  35926. return state;
  35927. }
  35928. function AES256Cipher(key) {
  35929. this.key = expandKey256(key);
  35930. this.buffer = new Uint8Array(16);
  35931. this.bufferPosition = 0;
  35932. }
  35933. function decryptBlock2(data, finalize) {
  35934. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [], iv = this.iv;
  35935. for (i = 0; i < sourceLength; ++i) {
  35936. buffer[bufferLength] = data[i];
  35937. ++bufferLength;
  35938. if (bufferLength < 16) {
  35939. continue;
  35940. }
  35941. var plain = decrypt256(buffer, this.key);
  35942. for (j = 0; j < 16; ++j) {
  35943. plain[j] ^= iv[j];
  35944. }
  35945. iv = buffer;
  35946. result.push(plain);
  35947. buffer = new Uint8Array(16);
  35948. bufferLength = 0;
  35949. }
  35950. this.buffer = buffer;
  35951. this.bufferLength = bufferLength;
  35952. this.iv = iv;
  35953. if (result.length === 0) {
  35954. return new Uint8Array([]);
  35955. }
  35956. var outputLength = 16 * result.length;
  35957. if (finalize) {
  35958. var lastBlock = result[result.length - 1];
  35959. var psLen = lastBlock[15];
  35960. if (psLen <= 16) {
  35961. for (i = 15, ii = 16 - psLen; i >= ii; --i) {
  35962. if (lastBlock[i] !== psLen) {
  35963. psLen = 0;
  35964. break;
  35965. }
  35966. }
  35967. outputLength -= psLen;
  35968. result[result.length - 1] = lastBlock.subarray(0, 16 - psLen);
  35969. }
  35970. }
  35971. var output = new Uint8Array(outputLength);
  35972. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  35973. output.set(result[i], j);
  35974. }
  35975. return output;
  35976. }
  35977. AES256Cipher.prototype = {
  35978. decryptBlock: function AES256Cipher_decryptBlock(data, finalize, iv) {
  35979. var i, sourceLength = data.length;
  35980. var buffer = this.buffer, bufferLength = this.bufferPosition;
  35981. if (iv) {
  35982. this.iv = iv;
  35983. } else {
  35984. for (i = 0; bufferLength < 16 && i < sourceLength; ++i, ++bufferLength) {
  35985. buffer[bufferLength] = data[i];
  35986. }
  35987. if (bufferLength < 16) {
  35988. this.bufferLength = bufferLength;
  35989. return new Uint8Array([]);
  35990. }
  35991. this.iv = buffer;
  35992. data = data.subarray(16);
  35993. }
  35994. this.buffer = new Uint8Array(16);
  35995. this.bufferLength = 0;
  35996. this.decryptBlock = decryptBlock2;
  35997. return this.decryptBlock(data, finalize);
  35998. },
  35999. encrypt: function AES256Cipher_encrypt(data, iv) {
  36000. var i, j, ii, sourceLength = data.length, buffer = this.buffer, bufferLength = this.bufferPosition, result = [];
  36001. if (!iv) {
  36002. iv = new Uint8Array(16);
  36003. }
  36004. for (i = 0; i < sourceLength; ++i) {
  36005. buffer[bufferLength] = data[i];
  36006. ++bufferLength;
  36007. if (bufferLength < 16) {
  36008. continue;
  36009. }
  36010. for (j = 0; j < 16; ++j) {
  36011. buffer[j] ^= iv[j];
  36012. }
  36013. var cipher = encrypt256(buffer, this.key);
  36014. this.iv = cipher;
  36015. result.push(cipher);
  36016. buffer = new Uint8Array(16);
  36017. bufferLength = 0;
  36018. }
  36019. this.buffer = buffer;
  36020. this.bufferLength = bufferLength;
  36021. this.iv = iv;
  36022. if (result.length === 0) {
  36023. return new Uint8Array([]);
  36024. }
  36025. var outputLength = 16 * result.length;
  36026. var output = new Uint8Array(outputLength);
  36027. for (i = 0, j = 0, ii = result.length; i < ii; ++i, j += 16) {
  36028. output.set(result[i], j);
  36029. }
  36030. return output;
  36031. }
  36032. };
  36033. return AES256Cipher;
  36034. }();
  36035. var PDF17 = function PDF17Closure() {
  36036. function compareByteArrays(array1, array2) {
  36037. if (array1.length !== array2.length) {
  36038. return false;
  36039. }
  36040. for (var i = 0; i < array1.length; i++) {
  36041. if (array1[i] !== array2[i]) {
  36042. return false;
  36043. }
  36044. }
  36045. return true;
  36046. }
  36047. function PDF17() {
  36048. }
  36049. PDF17.prototype = {
  36050. checkOwnerPassword: function PDF17_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36051. var hashData = new Uint8Array(password.length + 56);
  36052. hashData.set(password, 0);
  36053. hashData.set(ownerValidationSalt, password.length);
  36054. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36055. var result = calculateSHA256(hashData, 0, hashData.length);
  36056. return compareByteArrays(result, ownerPassword);
  36057. },
  36058. checkUserPassword: function PDF17_checkUserPassword(password, userValidationSalt, userPassword) {
  36059. var hashData = new Uint8Array(password.length + 8);
  36060. hashData.set(password, 0);
  36061. hashData.set(userValidationSalt, password.length);
  36062. var result = calculateSHA256(hashData, 0, hashData.length);
  36063. return compareByteArrays(result, userPassword);
  36064. },
  36065. getOwnerKey: function PDF17_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36066. var hashData = new Uint8Array(password.length + 56);
  36067. hashData.set(password, 0);
  36068. hashData.set(ownerKeySalt, password.length);
  36069. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36070. var key = calculateSHA256(hashData, 0, hashData.length);
  36071. var cipher = new AES256Cipher(key);
  36072. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36073. },
  36074. getUserKey: function PDF17_getUserKey(password, userKeySalt, userEncryption) {
  36075. var hashData = new Uint8Array(password.length + 8);
  36076. hashData.set(password, 0);
  36077. hashData.set(userKeySalt, password.length);
  36078. var key = calculateSHA256(hashData, 0, hashData.length);
  36079. var cipher = new AES256Cipher(key);
  36080. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36081. }
  36082. };
  36083. return PDF17;
  36084. }();
  36085. var PDF20 = function PDF20Closure() {
  36086. function concatArrays(array1, array2) {
  36087. var t = new Uint8Array(array1.length + array2.length);
  36088. t.set(array1, 0);
  36089. t.set(array2, array1.length);
  36090. return t;
  36091. }
  36092. function calculatePDF20Hash(password, input, userBytes) {
  36093. var k = calculateSHA256(input, 0, input.length).subarray(0, 32);
  36094. var e = [0];
  36095. var i = 0;
  36096. while (i < 64 || e[e.length - 1] > i - 32) {
  36097. var arrayLength = password.length + k.length + userBytes.length;
  36098. var k1 = new Uint8Array(arrayLength * 64);
  36099. var array = concatArrays(password, k);
  36100. array = concatArrays(array, userBytes);
  36101. for (var j = 0, pos = 0; j < 64; j++, pos += arrayLength) {
  36102. k1.set(array, pos);
  36103. }
  36104. var cipher = new AES128Cipher(k.subarray(0, 16));
  36105. e = cipher.encrypt(k1, k.subarray(16, 32));
  36106. var remainder = 0;
  36107. for (var z = 0; z < 16; z++) {
  36108. remainder *= 256 % 3;
  36109. remainder %= 3;
  36110. remainder += (e[z] >>> 0) % 3;
  36111. remainder %= 3;
  36112. }
  36113. if (remainder === 0) {
  36114. k = calculateSHA256(e, 0, e.length);
  36115. } else if (remainder === 1) {
  36116. k = calculateSHA384(e, 0, e.length);
  36117. } else if (remainder === 2) {
  36118. k = calculateSHA512(e, 0, e.length);
  36119. }
  36120. i++;
  36121. }
  36122. return k.subarray(0, 32);
  36123. }
  36124. function PDF20() {
  36125. }
  36126. function compareByteArrays(array1, array2) {
  36127. if (array1.length !== array2.length) {
  36128. return false;
  36129. }
  36130. for (var i = 0; i < array1.length; i++) {
  36131. if (array1[i] !== array2[i]) {
  36132. return false;
  36133. }
  36134. }
  36135. return true;
  36136. }
  36137. PDF20.prototype = {
  36138. hash: function PDF20_hash(password, concatBytes, userBytes) {
  36139. return calculatePDF20Hash(password, concatBytes, userBytes);
  36140. },
  36141. checkOwnerPassword: function PDF20_checkOwnerPassword(password, ownerValidationSalt, userBytes, ownerPassword) {
  36142. var hashData = new Uint8Array(password.length + 56);
  36143. hashData.set(password, 0);
  36144. hashData.set(ownerValidationSalt, password.length);
  36145. hashData.set(userBytes, password.length + ownerValidationSalt.length);
  36146. var result = calculatePDF20Hash(password, hashData, userBytes);
  36147. return compareByteArrays(result, ownerPassword);
  36148. },
  36149. checkUserPassword: function PDF20_checkUserPassword(password, userValidationSalt, userPassword) {
  36150. var hashData = new Uint8Array(password.length + 8);
  36151. hashData.set(password, 0);
  36152. hashData.set(userValidationSalt, password.length);
  36153. var result = calculatePDF20Hash(password, hashData, []);
  36154. return compareByteArrays(result, userPassword);
  36155. },
  36156. getOwnerKey: function PDF20_getOwnerKey(password, ownerKeySalt, userBytes, ownerEncryption) {
  36157. var hashData = new Uint8Array(password.length + 56);
  36158. hashData.set(password, 0);
  36159. hashData.set(ownerKeySalt, password.length);
  36160. hashData.set(userBytes, password.length + ownerKeySalt.length);
  36161. var key = calculatePDF20Hash(password, hashData, userBytes);
  36162. var cipher = new AES256Cipher(key);
  36163. return cipher.decryptBlock(ownerEncryption, false, new Uint8Array(16));
  36164. },
  36165. getUserKey: function PDF20_getUserKey(password, userKeySalt, userEncryption) {
  36166. var hashData = new Uint8Array(password.length + 8);
  36167. hashData.set(password, 0);
  36168. hashData.set(userKeySalt, password.length);
  36169. var key = calculatePDF20Hash(password, hashData, []);
  36170. var cipher = new AES256Cipher(key);
  36171. return cipher.decryptBlock(userEncryption, false, new Uint8Array(16));
  36172. }
  36173. };
  36174. return PDF20;
  36175. }();
  36176. var CipherTransform = function CipherTransformClosure() {
  36177. function CipherTransform(stringCipherConstructor, streamCipherConstructor) {
  36178. this.stringCipherConstructor = stringCipherConstructor;
  36179. this.streamCipherConstructor = streamCipherConstructor;
  36180. }
  36181. CipherTransform.prototype = {
  36182. createStream: function CipherTransform_createStream(stream, length) {
  36183. var cipher = new this.streamCipherConstructor();
  36184. return new DecryptStream(stream, length, function cipherTransformDecryptStream(data, finalize) {
  36185. return cipher.decryptBlock(data, finalize);
  36186. });
  36187. },
  36188. decryptString: function CipherTransform_decryptString(s) {
  36189. var cipher = new this.stringCipherConstructor();
  36190. var data = stringToBytes(s);
  36191. data = cipher.decryptBlock(data, true);
  36192. return bytesToString(data);
  36193. }
  36194. };
  36195. return CipherTransform;
  36196. }();
  36197. var CipherTransformFactory = function CipherTransformFactoryClosure() {
  36198. var defaultPasswordBytes = new Uint8Array([
  36199. 0x28,
  36200. 0xBF,
  36201. 0x4E,
  36202. 0x5E,
  36203. 0x4E,
  36204. 0x75,
  36205. 0x8A,
  36206. 0x41,
  36207. 0x64,
  36208. 0x00,
  36209. 0x4E,
  36210. 0x56,
  36211. 0xFF,
  36212. 0xFA,
  36213. 0x01,
  36214. 0x08,
  36215. 0x2E,
  36216. 0x2E,
  36217. 0x00,
  36218. 0xB6,
  36219. 0xD0,
  36220. 0x68,
  36221. 0x3E,
  36222. 0x80,
  36223. 0x2F,
  36224. 0x0C,
  36225. 0xA9,
  36226. 0xFE,
  36227. 0x64,
  36228. 0x53,
  36229. 0x69,
  36230. 0x7A
  36231. ]);
  36232. function createEncryptionKey20(revision, password, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms) {
  36233. if (password) {
  36234. var passwordLength = Math.min(127, password.length);
  36235. password = password.subarray(0, passwordLength);
  36236. } else {
  36237. password = [];
  36238. }
  36239. var pdfAlgorithm;
  36240. if (revision === 6) {
  36241. pdfAlgorithm = new PDF20();
  36242. } else {
  36243. pdfAlgorithm = new PDF17();
  36244. }
  36245. if (pdfAlgorithm.checkUserPassword(password, userValidationSalt, userPassword)) {
  36246. return pdfAlgorithm.getUserKey(password, userKeySalt, userEncryption);
  36247. } else if (password.length && pdfAlgorithm.checkOwnerPassword(password, ownerValidationSalt, uBytes, ownerPassword)) {
  36248. return pdfAlgorithm.getOwnerKey(password, ownerKeySalt, uBytes, ownerEncryption);
  36249. }
  36250. return null;
  36251. }
  36252. function prepareKeyData(fileId, password, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata) {
  36253. var hashDataSize = 40 + ownerPassword.length + fileId.length;
  36254. var hashData = new Uint8Array(hashDataSize), i = 0, j, n;
  36255. if (password) {
  36256. n = Math.min(32, password.length);
  36257. for (; i < n; ++i) {
  36258. hashData[i] = password[i];
  36259. }
  36260. }
  36261. j = 0;
  36262. while (i < 32) {
  36263. hashData[i++] = defaultPasswordBytes[j++];
  36264. }
  36265. for (j = 0, n = ownerPassword.length; j < n; ++j) {
  36266. hashData[i++] = ownerPassword[j];
  36267. }
  36268. hashData[i++] = flags & 0xFF;
  36269. hashData[i++] = flags >> 8 & 0xFF;
  36270. hashData[i++] = flags >> 16 & 0xFF;
  36271. hashData[i++] = flags >>> 24 & 0xFF;
  36272. for (j = 0, n = fileId.length; j < n; ++j) {
  36273. hashData[i++] = fileId[j];
  36274. }
  36275. if (revision >= 4 && !encryptMetadata) {
  36276. hashData[i++] = 0xFF;
  36277. hashData[i++] = 0xFF;
  36278. hashData[i++] = 0xFF;
  36279. hashData[i++] = 0xFF;
  36280. }
  36281. var hash = calculateMD5(hashData, 0, i);
  36282. var keyLengthInBytes = keyLength >> 3;
  36283. if (revision >= 3) {
  36284. for (j = 0; j < 50; ++j) {
  36285. hash = calculateMD5(hash, 0, keyLengthInBytes);
  36286. }
  36287. }
  36288. var encryptionKey = hash.subarray(0, keyLengthInBytes);
  36289. var cipher, checkData;
  36290. if (revision >= 3) {
  36291. for (i = 0; i < 32; ++i) {
  36292. hashData[i] = defaultPasswordBytes[i];
  36293. }
  36294. for (j = 0, n = fileId.length; j < n; ++j) {
  36295. hashData[i++] = fileId[j];
  36296. }
  36297. cipher = new ARCFourCipher(encryptionKey);
  36298. checkData = cipher.encryptBlock(calculateMD5(hashData, 0, i));
  36299. n = encryptionKey.length;
  36300. var derivedKey = new Uint8Array(n), k;
  36301. for (j = 1; j <= 19; ++j) {
  36302. for (k = 0; k < n; ++k) {
  36303. derivedKey[k] = encryptionKey[k] ^ j;
  36304. }
  36305. cipher = new ARCFourCipher(derivedKey);
  36306. checkData = cipher.encryptBlock(checkData);
  36307. }
  36308. for (j = 0, n = checkData.length; j < n; ++j) {
  36309. if (userPassword[j] !== checkData[j]) {
  36310. return null;
  36311. }
  36312. }
  36313. } else {
  36314. cipher = new ARCFourCipher(encryptionKey);
  36315. checkData = cipher.encryptBlock(defaultPasswordBytes);
  36316. for (j = 0, n = checkData.length; j < n; ++j) {
  36317. if (userPassword[j] !== checkData[j]) {
  36318. return null;
  36319. }
  36320. }
  36321. }
  36322. return encryptionKey;
  36323. }
  36324. function decodeUserPassword(password, ownerPassword, revision, keyLength) {
  36325. var hashData = new Uint8Array(32), i = 0, j, n;
  36326. n = Math.min(32, password.length);
  36327. for (; i < n; ++i) {
  36328. hashData[i] = password[i];
  36329. }
  36330. j = 0;
  36331. while (i < 32) {
  36332. hashData[i++] = defaultPasswordBytes[j++];
  36333. }
  36334. var hash = calculateMD5(hashData, 0, i);
  36335. var keyLengthInBytes = keyLength >> 3;
  36336. if (revision >= 3) {
  36337. for (j = 0; j < 50; ++j) {
  36338. hash = calculateMD5(hash, 0, hash.length);
  36339. }
  36340. }
  36341. var cipher, userPassword;
  36342. if (revision >= 3) {
  36343. userPassword = ownerPassword;
  36344. var derivedKey = new Uint8Array(keyLengthInBytes), k;
  36345. for (j = 19; j >= 0; j--) {
  36346. for (k = 0; k < keyLengthInBytes; ++k) {
  36347. derivedKey[k] = hash[k] ^ j;
  36348. }
  36349. cipher = new ARCFourCipher(derivedKey);
  36350. userPassword = cipher.encryptBlock(userPassword);
  36351. }
  36352. } else {
  36353. cipher = new ARCFourCipher(hash.subarray(0, keyLengthInBytes));
  36354. userPassword = cipher.encryptBlock(ownerPassword);
  36355. }
  36356. return userPassword;
  36357. }
  36358. var identityName = Name.get('Identity');
  36359. function CipherTransformFactory(dict, fileId, password) {
  36360. var filter = dict.get('Filter');
  36361. if (!isName(filter, 'Standard')) {
  36362. error('unknown encryption method');
  36363. }
  36364. this.dict = dict;
  36365. var algorithm = dict.get('V');
  36366. if (!isInt(algorithm) || algorithm !== 1 && algorithm !== 2 && algorithm !== 4 && algorithm !== 5) {
  36367. error('unsupported encryption algorithm');
  36368. }
  36369. this.algorithm = algorithm;
  36370. var keyLength = dict.get('Length');
  36371. if (!keyLength) {
  36372. if (algorithm <= 3) {
  36373. keyLength = 40;
  36374. } else {
  36375. var cfDict = dict.get('CF');
  36376. var streamCryptoName = dict.get('StmF');
  36377. if (isDict(cfDict) && isName(streamCryptoName)) {
  36378. cfDict.suppressEncryption = true;
  36379. var handlerDict = cfDict.get(streamCryptoName.name);
  36380. keyLength = handlerDict && handlerDict.get('Length') || 128;
  36381. if (keyLength < 40) {
  36382. keyLength <<= 3;
  36383. }
  36384. }
  36385. }
  36386. }
  36387. if (!isInt(keyLength) || keyLength < 40 || keyLength % 8 !== 0) {
  36388. error('invalid key length');
  36389. }
  36390. var ownerPassword = stringToBytes(dict.get('O')).subarray(0, 32);
  36391. var userPassword = stringToBytes(dict.get('U')).subarray(0, 32);
  36392. var flags = dict.get('P');
  36393. var revision = dict.get('R');
  36394. var encryptMetadata = (algorithm === 4 || algorithm === 5) && dict.get('EncryptMetadata') !== false;
  36395. this.encryptMetadata = encryptMetadata;
  36396. var fileIdBytes = stringToBytes(fileId);
  36397. var passwordBytes;
  36398. if (password) {
  36399. if (revision === 6) {
  36400. try {
  36401. password = utf8StringToString(password);
  36402. } catch (ex) {
  36403. warn('CipherTransformFactory: ' + 'Unable to convert UTF8 encoded password.');
  36404. }
  36405. }
  36406. passwordBytes = stringToBytes(password);
  36407. }
  36408. var encryptionKey;
  36409. if (algorithm !== 5) {
  36410. encryptionKey = prepareKeyData(fileIdBytes, passwordBytes, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36411. } else {
  36412. var ownerValidationSalt = stringToBytes(dict.get('O')).subarray(32, 40);
  36413. var ownerKeySalt = stringToBytes(dict.get('O')).subarray(40, 48);
  36414. var uBytes = stringToBytes(dict.get('U')).subarray(0, 48);
  36415. var userValidationSalt = stringToBytes(dict.get('U')).subarray(32, 40);
  36416. var userKeySalt = stringToBytes(dict.get('U')).subarray(40, 48);
  36417. var ownerEncryption = stringToBytes(dict.get('OE'));
  36418. var userEncryption = stringToBytes(dict.get('UE'));
  36419. var perms = stringToBytes(dict.get('Perms'));
  36420. encryptionKey = createEncryptionKey20(revision, passwordBytes, ownerPassword, ownerValidationSalt, ownerKeySalt, uBytes, userPassword, userValidationSalt, userKeySalt, ownerEncryption, userEncryption, perms);
  36421. }
  36422. if (!encryptionKey && !password) {
  36423. throw new PasswordException('No password given', PasswordResponses.NEED_PASSWORD);
  36424. } else if (!encryptionKey && password) {
  36425. var decodedPassword = decodeUserPassword(passwordBytes, ownerPassword, revision, keyLength);
  36426. encryptionKey = prepareKeyData(fileIdBytes, decodedPassword, ownerPassword, userPassword, flags, revision, keyLength, encryptMetadata);
  36427. }
  36428. if (!encryptionKey) {
  36429. throw new PasswordException('Incorrect Password', PasswordResponses.INCORRECT_PASSWORD);
  36430. }
  36431. this.encryptionKey = encryptionKey;
  36432. if (algorithm >= 4) {
  36433. var cf = dict.get('CF');
  36434. if (isDict(cf)) {
  36435. cf.suppressEncryption = true;
  36436. }
  36437. this.cf = cf;
  36438. this.stmf = dict.get('StmF') || identityName;
  36439. this.strf = dict.get('StrF') || identityName;
  36440. this.eff = dict.get('EFF') || this.stmf;
  36441. }
  36442. }
  36443. function buildObjectKey(num, gen, encryptionKey, isAes) {
  36444. var key = new Uint8Array(encryptionKey.length + 9), i, n;
  36445. for (i = 0, n = encryptionKey.length; i < n; ++i) {
  36446. key[i] = encryptionKey[i];
  36447. }
  36448. key[i++] = num & 0xFF;
  36449. key[i++] = num >> 8 & 0xFF;
  36450. key[i++] = num >> 16 & 0xFF;
  36451. key[i++] = gen & 0xFF;
  36452. key[i++] = gen >> 8 & 0xFF;
  36453. if (isAes) {
  36454. key[i++] = 0x73;
  36455. key[i++] = 0x41;
  36456. key[i++] = 0x6C;
  36457. key[i++] = 0x54;
  36458. }
  36459. var hash = calculateMD5(key, 0, i);
  36460. return hash.subarray(0, Math.min(encryptionKey.length + 5, 16));
  36461. }
  36462. function buildCipherConstructor(cf, name, num, gen, key) {
  36463. assert(isName(name), 'Invalid crypt filter name.');
  36464. var cryptFilter = cf.get(name.name);
  36465. var cfm;
  36466. if (cryptFilter !== null && cryptFilter !== undefined) {
  36467. cfm = cryptFilter.get('CFM');
  36468. }
  36469. if (!cfm || cfm.name === 'None') {
  36470. return function cipherTransformFactoryBuildCipherConstructorNone() {
  36471. return new NullCipher();
  36472. };
  36473. }
  36474. if ('V2' === cfm.name) {
  36475. return function cipherTransformFactoryBuildCipherConstructorV2() {
  36476. return new ARCFourCipher(buildObjectKey(num, gen, key, false));
  36477. };
  36478. }
  36479. if ('AESV2' === cfm.name) {
  36480. return function cipherTransformFactoryBuildCipherConstructorAESV2() {
  36481. return new AES128Cipher(buildObjectKey(num, gen, key, true));
  36482. };
  36483. }
  36484. if ('AESV3' === cfm.name) {
  36485. return function cipherTransformFactoryBuildCipherConstructorAESV3() {
  36486. return new AES256Cipher(key);
  36487. };
  36488. }
  36489. error('Unknown crypto method');
  36490. }
  36491. CipherTransformFactory.prototype = {
  36492. createCipherTransform: function CipherTransformFactory_createCipherTransform(num, gen) {
  36493. if (this.algorithm === 4 || this.algorithm === 5) {
  36494. return new CipherTransform(buildCipherConstructor(this.cf, this.stmf, num, gen, this.encryptionKey), buildCipherConstructor(this.cf, this.strf, num, gen, this.encryptionKey));
  36495. }
  36496. var key = buildObjectKey(num, gen, this.encryptionKey, false);
  36497. var cipherConstructor = function buildCipherCipherConstructor() {
  36498. return new ARCFourCipher(key);
  36499. };
  36500. return new CipherTransform(cipherConstructor, cipherConstructor);
  36501. }
  36502. };
  36503. return CipherTransformFactory;
  36504. }();
  36505. exports.AES128Cipher = AES128Cipher;
  36506. exports.AES256Cipher = AES256Cipher;
  36507. exports.ARCFourCipher = ARCFourCipher;
  36508. exports.CipherTransformFactory = CipherTransformFactory;
  36509. exports.PDF17 = PDF17;
  36510. exports.PDF20 = PDF20;
  36511. exports.calculateMD5 = calculateMD5;
  36512. exports.calculateSHA256 = calculateSHA256;
  36513. exports.calculateSHA384 = calculateSHA384;
  36514. exports.calculateSHA512 = calculateSHA512;
  36515. }));
  36516. (function (root, factory) {
  36517. factory(root.pdfjsCoreFontRenderer = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreEncodings, root.pdfjsCoreCFFParser);
  36518. }(this, function (exports, sharedUtil, coreStream, coreGlyphList, coreEncodings, coreCFFParser) {
  36519. var Util = sharedUtil.Util;
  36520. var bytesToString = sharedUtil.bytesToString;
  36521. var error = sharedUtil.error;
  36522. var Stream = coreStream.Stream;
  36523. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  36524. var StandardEncoding = coreEncodings.StandardEncoding;
  36525. var CFFParser = coreCFFParser.CFFParser;
  36526. var FontRendererFactory = function FontRendererFactoryClosure() {
  36527. function getLong(data, offset) {
  36528. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36529. }
  36530. function getUshort(data, offset) {
  36531. return data[offset] << 8 | data[offset + 1];
  36532. }
  36533. function parseCmap(data, start, end) {
  36534. var offset = getUshort(data, start + 2) === 1 ? getLong(data, start + 8) : getLong(data, start + 16);
  36535. var format = getUshort(data, start + offset);
  36536. var length, ranges, p, i;
  36537. if (format === 4) {
  36538. length = getUshort(data, start + offset + 2);
  36539. var segCount = getUshort(data, start + offset + 6) >> 1;
  36540. p = start + offset + 14;
  36541. ranges = [];
  36542. for (i = 0; i < segCount; i++, p += 2) {
  36543. ranges[i] = { end: getUshort(data, p) };
  36544. }
  36545. p += 2;
  36546. for (i = 0; i < segCount; i++, p += 2) {
  36547. ranges[i].start = getUshort(data, p);
  36548. }
  36549. for (i = 0; i < segCount; i++, p += 2) {
  36550. ranges[i].idDelta = getUshort(data, p);
  36551. }
  36552. for (i = 0; i < segCount; i++, p += 2) {
  36553. var idOffset = getUshort(data, p);
  36554. if (idOffset === 0) {
  36555. continue;
  36556. }
  36557. ranges[i].ids = [];
  36558. for (var j = 0, jj = ranges[i].end - ranges[i].start + 1; j < jj; j++) {
  36559. ranges[i].ids[j] = getUshort(data, p + idOffset);
  36560. idOffset += 2;
  36561. }
  36562. }
  36563. return ranges;
  36564. } else if (format === 12) {
  36565. length = getLong(data, start + offset + 4);
  36566. var groups = getLong(data, start + offset + 12);
  36567. p = start + offset + 16;
  36568. ranges = [];
  36569. for (i = 0; i < groups; i++) {
  36570. ranges.push({
  36571. start: getLong(data, p),
  36572. end: getLong(data, p + 4),
  36573. idDelta: getLong(data, p + 8) - getLong(data, p)
  36574. });
  36575. p += 12;
  36576. }
  36577. return ranges;
  36578. }
  36579. error('not supported cmap: ' + format);
  36580. }
  36581. function parseCff(data, start, end, seacAnalysisEnabled) {
  36582. var properties = {};
  36583. var parser = new CFFParser(new Stream(data, start, end - start), properties, seacAnalysisEnabled);
  36584. var cff = parser.parse();
  36585. return {
  36586. glyphs: cff.charStrings.objects,
  36587. subrs: cff.topDict.privateDict && cff.topDict.privateDict.subrsIndex && cff.topDict.privateDict.subrsIndex.objects,
  36588. gsubrs: cff.globalSubrIndex && cff.globalSubrIndex.objects
  36589. };
  36590. }
  36591. function parseGlyfTable(glyf, loca, isGlyphLocationsLong) {
  36592. var itemSize, itemDecode;
  36593. if (isGlyphLocationsLong) {
  36594. itemSize = 4;
  36595. itemDecode = function fontItemDecodeLong(data, offset) {
  36596. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  36597. };
  36598. } else {
  36599. itemSize = 2;
  36600. itemDecode = function fontItemDecode(data, offset) {
  36601. return data[offset] << 9 | data[offset + 1] << 1;
  36602. };
  36603. }
  36604. var glyphs = [];
  36605. var startOffset = itemDecode(loca, 0);
  36606. for (var j = itemSize; j < loca.length; j += itemSize) {
  36607. var endOffset = itemDecode(loca, j);
  36608. glyphs.push(glyf.subarray(startOffset, endOffset));
  36609. startOffset = endOffset;
  36610. }
  36611. return glyphs;
  36612. }
  36613. function lookupCmap(ranges, unicode) {
  36614. var code = unicode.charCodeAt(0), gid = 0;
  36615. var l = 0, r = ranges.length - 1;
  36616. while (l < r) {
  36617. var c = l + r + 1 >> 1;
  36618. if (code < ranges[c].start) {
  36619. r = c - 1;
  36620. } else {
  36621. l = c;
  36622. }
  36623. }
  36624. if (ranges[l].start <= code && code <= ranges[l].end) {
  36625. gid = ranges[l].idDelta + (ranges[l].ids ? ranges[l].ids[code - ranges[l].start] : code) & 0xFFFF;
  36626. }
  36627. return {
  36628. charCode: code,
  36629. glyphId: gid
  36630. };
  36631. }
  36632. function compileGlyf(code, cmds, font) {
  36633. function moveTo(x, y) {
  36634. cmds.push({
  36635. cmd: 'moveTo',
  36636. args: [
  36637. x,
  36638. y
  36639. ]
  36640. });
  36641. }
  36642. function lineTo(x, y) {
  36643. cmds.push({
  36644. cmd: 'lineTo',
  36645. args: [
  36646. x,
  36647. y
  36648. ]
  36649. });
  36650. }
  36651. function quadraticCurveTo(xa, ya, x, y) {
  36652. cmds.push({
  36653. cmd: 'quadraticCurveTo',
  36654. args: [
  36655. xa,
  36656. ya,
  36657. x,
  36658. y
  36659. ]
  36660. });
  36661. }
  36662. var i = 0;
  36663. var numberOfContours = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36664. var flags;
  36665. var x = 0, y = 0;
  36666. i += 10;
  36667. if (numberOfContours < 0) {
  36668. do {
  36669. flags = code[i] << 8 | code[i + 1];
  36670. var glyphIndex = code[i + 2] << 8 | code[i + 3];
  36671. i += 4;
  36672. var arg1, arg2;
  36673. if (flags & 0x01) {
  36674. arg1 = (code[i] << 24 | code[i + 1] << 16) >> 16;
  36675. arg2 = (code[i + 2] << 24 | code[i + 3] << 16) >> 16;
  36676. i += 4;
  36677. } else {
  36678. arg1 = code[i++];
  36679. arg2 = code[i++];
  36680. }
  36681. if (flags & 0x02) {
  36682. x = arg1;
  36683. y = arg2;
  36684. } else {
  36685. x = 0;
  36686. y = 0;
  36687. }
  36688. var scaleX = 1, scaleY = 1, scale01 = 0, scale10 = 0;
  36689. if (flags & 0x08) {
  36690. scaleX = scaleY = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36691. i += 2;
  36692. } else if (flags & 0x40) {
  36693. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36694. scaleY = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36695. i += 4;
  36696. } else if (flags & 0x80) {
  36697. scaleX = (code[i] << 24 | code[i + 1] << 16) / 1073741824;
  36698. scale01 = (code[i + 2] << 24 | code[i + 3] << 16) / 1073741824;
  36699. scale10 = (code[i + 4] << 24 | code[i + 5] << 16) / 1073741824;
  36700. scaleY = (code[i + 6] << 24 | code[i + 7] << 16) / 1073741824;
  36701. i += 8;
  36702. }
  36703. var subglyph = font.glyphs[glyphIndex];
  36704. if (subglyph) {
  36705. cmds.push({ cmd: 'save' });
  36706. cmds.push({
  36707. cmd: 'transform',
  36708. args: [
  36709. scaleX,
  36710. scale01,
  36711. scale10,
  36712. scaleY,
  36713. x,
  36714. y
  36715. ]
  36716. });
  36717. compileGlyf(subglyph, cmds, font);
  36718. cmds.push({ cmd: 'restore' });
  36719. }
  36720. } while (flags & 0x20);
  36721. } else {
  36722. var endPtsOfContours = [];
  36723. var j, jj;
  36724. for (j = 0; j < numberOfContours; j++) {
  36725. endPtsOfContours.push(code[i] << 8 | code[i + 1]);
  36726. i += 2;
  36727. }
  36728. var instructionLength = code[i] << 8 | code[i + 1];
  36729. i += 2 + instructionLength;
  36730. var numberOfPoints = endPtsOfContours[endPtsOfContours.length - 1] + 1;
  36731. var points = [];
  36732. while (points.length < numberOfPoints) {
  36733. flags = code[i++];
  36734. var repeat = 1;
  36735. if (flags & 0x08) {
  36736. repeat += code[i++];
  36737. }
  36738. while (repeat-- > 0) {
  36739. points.push({ flags: flags });
  36740. }
  36741. }
  36742. for (j = 0; j < numberOfPoints; j++) {
  36743. switch (points[j].flags & 0x12) {
  36744. case 0x00:
  36745. x += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36746. i += 2;
  36747. break;
  36748. case 0x02:
  36749. x -= code[i++];
  36750. break;
  36751. case 0x12:
  36752. x += code[i++];
  36753. break;
  36754. }
  36755. points[j].x = x;
  36756. }
  36757. for (j = 0; j < numberOfPoints; j++) {
  36758. switch (points[j].flags & 0x24) {
  36759. case 0x00:
  36760. y += (code[i] << 24 | code[i + 1] << 16) >> 16;
  36761. i += 2;
  36762. break;
  36763. case 0x04:
  36764. y -= code[i++];
  36765. break;
  36766. case 0x24:
  36767. y += code[i++];
  36768. break;
  36769. }
  36770. points[j].y = y;
  36771. }
  36772. var startPoint = 0;
  36773. for (i = 0; i < numberOfContours; i++) {
  36774. var endPoint = endPtsOfContours[i];
  36775. var contour = points.slice(startPoint, endPoint + 1);
  36776. if (contour[0].flags & 1) {
  36777. contour.push(contour[0]);
  36778. } else if (contour[contour.length - 1].flags & 1) {
  36779. contour.unshift(contour[contour.length - 1]);
  36780. } else {
  36781. var p = {
  36782. flags: 1,
  36783. x: (contour[0].x + contour[contour.length - 1].x) / 2,
  36784. y: (contour[0].y + contour[contour.length - 1].y) / 2
  36785. };
  36786. contour.unshift(p);
  36787. contour.push(p);
  36788. }
  36789. moveTo(contour[0].x, contour[0].y);
  36790. for (j = 1, jj = contour.length; j < jj; j++) {
  36791. if (contour[j].flags & 1) {
  36792. lineTo(contour[j].x, contour[j].y);
  36793. } else if (contour[j + 1].flags & 1) {
  36794. quadraticCurveTo(contour[j].x, contour[j].y, contour[j + 1].x, contour[j + 1].y);
  36795. j++;
  36796. } else {
  36797. quadraticCurveTo(contour[j].x, contour[j].y, (contour[j].x + contour[j + 1].x) / 2, (contour[j].y + contour[j + 1].y) / 2);
  36798. }
  36799. }
  36800. startPoint = endPoint + 1;
  36801. }
  36802. }
  36803. }
  36804. function compileCharString(code, cmds, font) {
  36805. var stack = [];
  36806. var x = 0, y = 0;
  36807. var stems = 0;
  36808. function moveTo(x, y) {
  36809. cmds.push({
  36810. cmd: 'moveTo',
  36811. args: [
  36812. x,
  36813. y
  36814. ]
  36815. });
  36816. }
  36817. function lineTo(x, y) {
  36818. cmds.push({
  36819. cmd: 'lineTo',
  36820. args: [
  36821. x,
  36822. y
  36823. ]
  36824. });
  36825. }
  36826. function bezierCurveTo(x1, y1, x2, y2, x, y) {
  36827. cmds.push({
  36828. cmd: 'bezierCurveTo',
  36829. args: [
  36830. x1,
  36831. y1,
  36832. x2,
  36833. y2,
  36834. x,
  36835. y
  36836. ]
  36837. });
  36838. }
  36839. function parse(code) {
  36840. var i = 0;
  36841. while (i < code.length) {
  36842. var stackClean = false;
  36843. var v = code[i++];
  36844. var xa, xb, ya, yb, y1, y2, y3, n, subrCode;
  36845. switch (v) {
  36846. case 1:
  36847. stems += stack.length >> 1;
  36848. stackClean = true;
  36849. break;
  36850. case 3:
  36851. stems += stack.length >> 1;
  36852. stackClean = true;
  36853. break;
  36854. case 4:
  36855. y += stack.pop();
  36856. moveTo(x, y);
  36857. stackClean = true;
  36858. break;
  36859. case 5:
  36860. while (stack.length > 0) {
  36861. x += stack.shift();
  36862. y += stack.shift();
  36863. lineTo(x, y);
  36864. }
  36865. break;
  36866. case 6:
  36867. while (stack.length > 0) {
  36868. x += stack.shift();
  36869. lineTo(x, y);
  36870. if (stack.length === 0) {
  36871. break;
  36872. }
  36873. y += stack.shift();
  36874. lineTo(x, y);
  36875. }
  36876. break;
  36877. case 7:
  36878. while (stack.length > 0) {
  36879. y += stack.shift();
  36880. lineTo(x, y);
  36881. if (stack.length === 0) {
  36882. break;
  36883. }
  36884. x += stack.shift();
  36885. lineTo(x, y);
  36886. }
  36887. break;
  36888. case 8:
  36889. while (stack.length > 0) {
  36890. xa = x + stack.shift();
  36891. ya = y + stack.shift();
  36892. xb = xa + stack.shift();
  36893. yb = ya + stack.shift();
  36894. x = xb + stack.shift();
  36895. y = yb + stack.shift();
  36896. bezierCurveTo(xa, ya, xb, yb, x, y);
  36897. }
  36898. break;
  36899. case 10:
  36900. n = stack.pop() + font.subrsBias;
  36901. subrCode = font.subrs[n];
  36902. if (subrCode) {
  36903. parse(subrCode);
  36904. }
  36905. break;
  36906. case 11:
  36907. return;
  36908. case 12:
  36909. v = code[i++];
  36910. switch (v) {
  36911. case 34:
  36912. xa = x + stack.shift();
  36913. xb = xa + stack.shift();
  36914. y1 = y + stack.shift();
  36915. x = xb + stack.shift();
  36916. bezierCurveTo(xa, y, xb, y1, x, y1);
  36917. xa = x + stack.shift();
  36918. xb = xa + stack.shift();
  36919. x = xb + stack.shift();
  36920. bezierCurveTo(xa, y1, xb, y, x, y);
  36921. break;
  36922. case 35:
  36923. xa = x + stack.shift();
  36924. ya = y + stack.shift();
  36925. xb = xa + stack.shift();
  36926. yb = ya + stack.shift();
  36927. x = xb + stack.shift();
  36928. y = yb + stack.shift();
  36929. bezierCurveTo(xa, ya, xb, yb, x, y);
  36930. xa = x + stack.shift();
  36931. ya = y + stack.shift();
  36932. xb = xa + stack.shift();
  36933. yb = ya + stack.shift();
  36934. x = xb + stack.shift();
  36935. y = yb + stack.shift();
  36936. bezierCurveTo(xa, ya, xb, yb, x, y);
  36937. stack.pop();
  36938. break;
  36939. case 36:
  36940. xa = x + stack.shift();
  36941. y1 = y + stack.shift();
  36942. xb = xa + stack.shift();
  36943. y2 = y1 + stack.shift();
  36944. x = xb + stack.shift();
  36945. bezierCurveTo(xa, y1, xb, y2, x, y2);
  36946. xa = x + stack.shift();
  36947. xb = xa + stack.shift();
  36948. y3 = y2 + stack.shift();
  36949. x = xb + stack.shift();
  36950. bezierCurveTo(xa, y2, xb, y3, x, y);
  36951. break;
  36952. case 37:
  36953. var x0 = x, y0 = y;
  36954. xa = x + stack.shift();
  36955. ya = y + stack.shift();
  36956. xb = xa + stack.shift();
  36957. yb = ya + stack.shift();
  36958. x = xb + stack.shift();
  36959. y = yb + stack.shift();
  36960. bezierCurveTo(xa, ya, xb, yb, x, y);
  36961. xa = x + stack.shift();
  36962. ya = y + stack.shift();
  36963. xb = xa + stack.shift();
  36964. yb = ya + stack.shift();
  36965. x = xb;
  36966. y = yb;
  36967. if (Math.abs(x - x0) > Math.abs(y - y0)) {
  36968. x += stack.shift();
  36969. } else {
  36970. y += stack.shift();
  36971. }
  36972. bezierCurveTo(xa, ya, xb, yb, x, y);
  36973. break;
  36974. default:
  36975. error('unknown operator: 12 ' + v);
  36976. }
  36977. break;
  36978. case 14:
  36979. if (stack.length >= 4) {
  36980. var achar = stack.pop();
  36981. var bchar = stack.pop();
  36982. y = stack.pop();
  36983. x = stack.pop();
  36984. cmds.push({ cmd: 'save' });
  36985. cmds.push({
  36986. cmd: 'translate',
  36987. args: [
  36988. x,
  36989. y
  36990. ]
  36991. });
  36992. var cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[achar]]));
  36993. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  36994. cmds.push({ cmd: 'restore' });
  36995. cmap = lookupCmap(font.cmap, String.fromCharCode(font.glyphNameMap[StandardEncoding[bchar]]));
  36996. compileCharString(font.glyphs[cmap.glyphId], cmds, font);
  36997. }
  36998. return;
  36999. case 18:
  37000. stems += stack.length >> 1;
  37001. stackClean = true;
  37002. break;
  37003. case 19:
  37004. stems += stack.length >> 1;
  37005. i += stems + 7 >> 3;
  37006. stackClean = true;
  37007. break;
  37008. case 20:
  37009. stems += stack.length >> 1;
  37010. i += stems + 7 >> 3;
  37011. stackClean = true;
  37012. break;
  37013. case 21:
  37014. y += stack.pop();
  37015. x += stack.pop();
  37016. moveTo(x, y);
  37017. stackClean = true;
  37018. break;
  37019. case 22:
  37020. x += stack.pop();
  37021. moveTo(x, y);
  37022. stackClean = true;
  37023. break;
  37024. case 23:
  37025. stems += stack.length >> 1;
  37026. stackClean = true;
  37027. break;
  37028. case 24:
  37029. while (stack.length > 2) {
  37030. xa = x + stack.shift();
  37031. ya = y + stack.shift();
  37032. xb = xa + stack.shift();
  37033. yb = ya + stack.shift();
  37034. x = xb + stack.shift();
  37035. y = yb + stack.shift();
  37036. bezierCurveTo(xa, ya, xb, yb, x, y);
  37037. }
  37038. x += stack.shift();
  37039. y += stack.shift();
  37040. lineTo(x, y);
  37041. break;
  37042. case 25:
  37043. while (stack.length > 6) {
  37044. x += stack.shift();
  37045. y += stack.shift();
  37046. lineTo(x, y);
  37047. }
  37048. xa = x + stack.shift();
  37049. ya = y + stack.shift();
  37050. xb = xa + stack.shift();
  37051. yb = ya + stack.shift();
  37052. x = xb + stack.shift();
  37053. y = yb + stack.shift();
  37054. bezierCurveTo(xa, ya, xb, yb, x, y);
  37055. break;
  37056. case 26:
  37057. if (stack.length % 2) {
  37058. x += stack.shift();
  37059. }
  37060. while (stack.length > 0) {
  37061. xa = x;
  37062. ya = y + stack.shift();
  37063. xb = xa + stack.shift();
  37064. yb = ya + stack.shift();
  37065. x = xb;
  37066. y = yb + stack.shift();
  37067. bezierCurveTo(xa, ya, xb, yb, x, y);
  37068. }
  37069. break;
  37070. case 27:
  37071. if (stack.length % 2) {
  37072. y += stack.shift();
  37073. }
  37074. while (stack.length > 0) {
  37075. xa = x + stack.shift();
  37076. ya = y;
  37077. xb = xa + stack.shift();
  37078. yb = ya + stack.shift();
  37079. x = xb + stack.shift();
  37080. y = yb;
  37081. bezierCurveTo(xa, ya, xb, yb, x, y);
  37082. }
  37083. break;
  37084. case 28:
  37085. stack.push((code[i] << 24 | code[i + 1] << 16) >> 16);
  37086. i += 2;
  37087. break;
  37088. case 29:
  37089. n = stack.pop() + font.gsubrsBias;
  37090. subrCode = font.gsubrs[n];
  37091. if (subrCode) {
  37092. parse(subrCode);
  37093. }
  37094. break;
  37095. case 30:
  37096. while (stack.length > 0) {
  37097. xa = x;
  37098. ya = y + stack.shift();
  37099. xb = xa + stack.shift();
  37100. yb = ya + stack.shift();
  37101. x = xb + stack.shift();
  37102. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37103. bezierCurveTo(xa, ya, xb, yb, x, y);
  37104. if (stack.length === 0) {
  37105. break;
  37106. }
  37107. xa = x + stack.shift();
  37108. ya = y;
  37109. xb = xa + stack.shift();
  37110. yb = ya + stack.shift();
  37111. y = yb + stack.shift();
  37112. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37113. bezierCurveTo(xa, ya, xb, yb, x, y);
  37114. }
  37115. break;
  37116. case 31:
  37117. while (stack.length > 0) {
  37118. xa = x + stack.shift();
  37119. ya = y;
  37120. xb = xa + stack.shift();
  37121. yb = ya + stack.shift();
  37122. y = yb + stack.shift();
  37123. x = xb + (stack.length === 1 ? stack.shift() : 0);
  37124. bezierCurveTo(xa, ya, xb, yb, x, y);
  37125. if (stack.length === 0) {
  37126. break;
  37127. }
  37128. xa = x;
  37129. ya = y + stack.shift();
  37130. xb = xa + stack.shift();
  37131. yb = ya + stack.shift();
  37132. x = xb + stack.shift();
  37133. y = yb + (stack.length === 1 ? stack.shift() : 0);
  37134. bezierCurveTo(xa, ya, xb, yb, x, y);
  37135. }
  37136. break;
  37137. default:
  37138. if (v < 32) {
  37139. error('unknown operator: ' + v);
  37140. }
  37141. if (v < 247) {
  37142. stack.push(v - 139);
  37143. } else if (v < 251) {
  37144. stack.push((v - 247) * 256 + code[i++] + 108);
  37145. } else if (v < 255) {
  37146. stack.push(-(v - 251) * 256 - code[i++] - 108);
  37147. } else {
  37148. stack.push((code[i] << 24 | code[i + 1] << 16 | code[i + 2] << 8 | code[i + 3]) / 65536);
  37149. i += 4;
  37150. }
  37151. break;
  37152. }
  37153. if (stackClean) {
  37154. stack.length = 0;
  37155. }
  37156. }
  37157. }
  37158. parse(code);
  37159. }
  37160. var noop = '';
  37161. function CompiledFont(fontMatrix) {
  37162. this.compiledGlyphs = Object.create(null);
  37163. this.compiledCharCodeToGlyphId = Object.create(null);
  37164. this.fontMatrix = fontMatrix;
  37165. }
  37166. CompiledFont.prototype = {
  37167. getPathJs: function (unicode) {
  37168. var cmap = lookupCmap(this.cmap, unicode);
  37169. var fn = this.compiledGlyphs[cmap.glyphId];
  37170. if (!fn) {
  37171. fn = this.compileGlyph(this.glyphs[cmap.glyphId]);
  37172. this.compiledGlyphs[cmap.glyphId] = fn;
  37173. }
  37174. if (this.compiledCharCodeToGlyphId[cmap.charCode] === undefined) {
  37175. this.compiledCharCodeToGlyphId[cmap.charCode] = cmap.glyphId;
  37176. }
  37177. return fn;
  37178. },
  37179. compileGlyph: function (code) {
  37180. if (!code || code.length === 0 || code[0] === 14) {
  37181. return noop;
  37182. }
  37183. var cmds = [];
  37184. cmds.push({ cmd: 'save' });
  37185. cmds.push({
  37186. cmd: 'transform',
  37187. args: this.fontMatrix.slice()
  37188. });
  37189. cmds.push({
  37190. cmd: 'scale',
  37191. args: [
  37192. 'size',
  37193. '-size'
  37194. ]
  37195. });
  37196. this.compileGlyphImpl(code, cmds);
  37197. cmds.push({ cmd: 'restore' });
  37198. return cmds;
  37199. },
  37200. compileGlyphImpl: function () {
  37201. error('Children classes should implement this.');
  37202. },
  37203. hasBuiltPath: function (unicode) {
  37204. var cmap = lookupCmap(this.cmap, unicode);
  37205. return this.compiledGlyphs[cmap.glyphId] !== undefined && this.compiledCharCodeToGlyphId[cmap.charCode] !== undefined;
  37206. }
  37207. };
  37208. function TrueTypeCompiled(glyphs, cmap, fontMatrix) {
  37209. fontMatrix = fontMatrix || [
  37210. 0.000488,
  37211. 0,
  37212. 0,
  37213. 0.000488,
  37214. 0,
  37215. 0
  37216. ];
  37217. CompiledFont.call(this, fontMatrix);
  37218. this.glyphs = glyphs;
  37219. this.cmap = cmap;
  37220. }
  37221. Util.inherit(TrueTypeCompiled, CompiledFont, {
  37222. compileGlyphImpl: function (code, cmds) {
  37223. compileGlyf(code, cmds, this);
  37224. }
  37225. });
  37226. function Type2Compiled(cffInfo, cmap, fontMatrix, glyphNameMap) {
  37227. fontMatrix = fontMatrix || [
  37228. 0.001,
  37229. 0,
  37230. 0,
  37231. 0.001,
  37232. 0,
  37233. 0
  37234. ];
  37235. CompiledFont.call(this, fontMatrix);
  37236. this.glyphs = cffInfo.glyphs;
  37237. this.gsubrs = cffInfo.gsubrs || [];
  37238. this.subrs = cffInfo.subrs || [];
  37239. this.cmap = cmap;
  37240. this.glyphNameMap = glyphNameMap || getGlyphsUnicode();
  37241. this.gsubrsBias = this.gsubrs.length < 1240 ? 107 : this.gsubrs.length < 33900 ? 1131 : 32768;
  37242. this.subrsBias = this.subrs.length < 1240 ? 107 : this.subrs.length < 33900 ? 1131 : 32768;
  37243. }
  37244. Util.inherit(Type2Compiled, CompiledFont, {
  37245. compileGlyphImpl: function (code, cmds) {
  37246. compileCharString(code, cmds, this);
  37247. }
  37248. });
  37249. return {
  37250. create: function FontRendererFactory_create(font, seacAnalysisEnabled) {
  37251. var data = new Uint8Array(font.data);
  37252. var cmap, glyf, loca, cff, indexToLocFormat, unitsPerEm;
  37253. var numTables = getUshort(data, 4);
  37254. for (var i = 0, p = 12; i < numTables; i++, p += 16) {
  37255. var tag = bytesToString(data.subarray(p, p + 4));
  37256. var offset = getLong(data, p + 8);
  37257. var length = getLong(data, p + 12);
  37258. switch (tag) {
  37259. case 'cmap':
  37260. cmap = parseCmap(data, offset, offset + length);
  37261. break;
  37262. case 'glyf':
  37263. glyf = data.subarray(offset, offset + length);
  37264. break;
  37265. case 'loca':
  37266. loca = data.subarray(offset, offset + length);
  37267. break;
  37268. case 'head':
  37269. unitsPerEm = getUshort(data, offset + 18);
  37270. indexToLocFormat = getUshort(data, offset + 50);
  37271. break;
  37272. case 'CFF ':
  37273. cff = parseCff(data, offset, offset + length, seacAnalysisEnabled);
  37274. break;
  37275. }
  37276. }
  37277. if (glyf) {
  37278. var fontMatrix = !unitsPerEm ? font.fontMatrix : [
  37279. 1 / unitsPerEm,
  37280. 0,
  37281. 0,
  37282. 1 / unitsPerEm,
  37283. 0,
  37284. 0
  37285. ];
  37286. return new TrueTypeCompiled(parseGlyfTable(glyf, loca, indexToLocFormat), cmap, fontMatrix);
  37287. } else {
  37288. return new Type2Compiled(cff, cmap, font.fontMatrix, font.glyphNameMap);
  37289. }
  37290. }
  37291. };
  37292. }();
  37293. exports.FontRendererFactory = FontRendererFactory;
  37294. }));
  37295. (function (root, factory) {
  37296. factory(root.pdfjsCoreParser = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream);
  37297. }(this, function (exports, sharedUtil, corePrimitives, coreStream) {
  37298. var MissingDataException = sharedUtil.MissingDataException;
  37299. var StreamType = sharedUtil.StreamType;
  37300. var assert = sharedUtil.assert;
  37301. var error = sharedUtil.error;
  37302. var info = sharedUtil.info;
  37303. var isArray = sharedUtil.isArray;
  37304. var isInt = sharedUtil.isInt;
  37305. var isNum = sharedUtil.isNum;
  37306. var isString = sharedUtil.isString;
  37307. var warn = sharedUtil.warn;
  37308. var Cmd = corePrimitives.Cmd;
  37309. var Dict = corePrimitives.Dict;
  37310. var Name = corePrimitives.Name;
  37311. var Ref = corePrimitives.Ref;
  37312. var isCmd = corePrimitives.isCmd;
  37313. var isDict = corePrimitives.isDict;
  37314. var isName = corePrimitives.isName;
  37315. var Ascii85Stream = coreStream.Ascii85Stream;
  37316. var AsciiHexStream = coreStream.AsciiHexStream;
  37317. var CCITTFaxStream = coreStream.CCITTFaxStream;
  37318. var FlateStream = coreStream.FlateStream;
  37319. var Jbig2Stream = coreStream.Jbig2Stream;
  37320. var JpegStream = coreStream.JpegStream;
  37321. var JpxStream = coreStream.JpxStream;
  37322. var LZWStream = coreStream.LZWStream;
  37323. var NullStream = coreStream.NullStream;
  37324. var PredictorStream = coreStream.PredictorStream;
  37325. var RunLengthStream = coreStream.RunLengthStream;
  37326. var EOF = {};
  37327. function isEOF(v) {
  37328. return v === EOF;
  37329. }
  37330. var MAX_LENGTH_TO_CACHE = 1000;
  37331. var Parser = function ParserClosure() {
  37332. function Parser(lexer, allowStreams, xref, recoveryMode) {
  37333. this.lexer = lexer;
  37334. this.allowStreams = allowStreams;
  37335. this.xref = xref;
  37336. this.recoveryMode = recoveryMode || false;
  37337. this.imageCache = Object.create(null);
  37338. this.refill();
  37339. }
  37340. Parser.prototype = {
  37341. refill: function Parser_refill() {
  37342. this.buf1 = this.lexer.getObj();
  37343. this.buf2 = this.lexer.getObj();
  37344. },
  37345. shift: function Parser_shift() {
  37346. if (isCmd(this.buf2, 'ID')) {
  37347. this.buf1 = this.buf2;
  37348. this.buf2 = null;
  37349. } else {
  37350. this.buf1 = this.buf2;
  37351. this.buf2 = this.lexer.getObj();
  37352. }
  37353. },
  37354. tryShift: function Parser_tryShift() {
  37355. try {
  37356. this.shift();
  37357. return true;
  37358. } catch (e) {
  37359. if (e instanceof MissingDataException) {
  37360. throw e;
  37361. }
  37362. return false;
  37363. }
  37364. },
  37365. getObj: function Parser_getObj(cipherTransform) {
  37366. var buf1 = this.buf1;
  37367. this.shift();
  37368. if (buf1 instanceof Cmd) {
  37369. switch (buf1.cmd) {
  37370. case 'BI':
  37371. return this.makeInlineImage(cipherTransform);
  37372. case '[':
  37373. var array = [];
  37374. while (!isCmd(this.buf1, ']') && !isEOF(this.buf1)) {
  37375. array.push(this.getObj(cipherTransform));
  37376. }
  37377. if (isEOF(this.buf1)) {
  37378. if (!this.recoveryMode) {
  37379. error('End of file inside array');
  37380. }
  37381. return array;
  37382. }
  37383. this.shift();
  37384. return array;
  37385. case '<<':
  37386. var dict = new Dict(this.xref);
  37387. while (!isCmd(this.buf1, '>>') && !isEOF(this.buf1)) {
  37388. if (!isName(this.buf1)) {
  37389. info('Malformed dictionary: key must be a name object');
  37390. this.shift();
  37391. continue;
  37392. }
  37393. var key = this.buf1.name;
  37394. this.shift();
  37395. if (isEOF(this.buf1)) {
  37396. break;
  37397. }
  37398. dict.set(key, this.getObj(cipherTransform));
  37399. }
  37400. if (isEOF(this.buf1)) {
  37401. if (!this.recoveryMode) {
  37402. error('End of file inside dictionary');
  37403. }
  37404. return dict;
  37405. }
  37406. if (isCmd(this.buf2, 'stream')) {
  37407. return this.allowStreams ? this.makeStream(dict, cipherTransform) : dict;
  37408. }
  37409. this.shift();
  37410. return dict;
  37411. default:
  37412. return buf1;
  37413. }
  37414. }
  37415. if (isInt(buf1)) {
  37416. var num = buf1;
  37417. if (isInt(this.buf1) && isCmd(this.buf2, 'R')) {
  37418. var ref = new Ref(num, this.buf1);
  37419. this.shift();
  37420. this.shift();
  37421. return ref;
  37422. }
  37423. return num;
  37424. }
  37425. if (isString(buf1)) {
  37426. var str = buf1;
  37427. if (cipherTransform) {
  37428. str = cipherTransform.decryptString(str);
  37429. }
  37430. return str;
  37431. }
  37432. return buf1;
  37433. },
  37434. findDefaultInlineStreamEnd: function Parser_findDefaultInlineStreamEnd(stream) {
  37435. var E = 0x45, I = 0x49, SPACE = 0x20, LF = 0xA, CR = 0xD;
  37436. var startPos = stream.pos, state = 0, ch, i, n, followingBytes;
  37437. while ((ch = stream.getByte()) !== -1) {
  37438. if (state === 0) {
  37439. state = ch === E ? 1 : 0;
  37440. } else if (state === 1) {
  37441. state = ch === I ? 2 : 0;
  37442. } else {
  37443. assert(state === 2);
  37444. if (ch === SPACE || ch === LF || ch === CR) {
  37445. n = 5;
  37446. followingBytes = stream.peekBytes(n);
  37447. for (i = 0; i < n; i++) {
  37448. ch = followingBytes[i];
  37449. if (ch !== LF && ch !== CR && (ch < SPACE || ch > 0x7F)) {
  37450. state = 0;
  37451. break;
  37452. }
  37453. }
  37454. if (state === 2) {
  37455. break;
  37456. }
  37457. } else
  37458. {
  37459. state = 0;
  37460. }
  37461. }
  37462. }
  37463. return stream.pos - 4 - startPos;
  37464. },
  37465. findDCTDecodeInlineStreamEnd: function Parser_findDCTDecodeInlineStreamEnd(stream) {
  37466. var startPos = stream.pos, foundEOI = false, b, markerLength, length;
  37467. while ((b = stream.getByte()) !== -1) {
  37468. if (b !== 0xFF) {
  37469. continue;
  37470. }
  37471. switch (stream.getByte()) {
  37472. case 0x00:
  37473. break;
  37474. case 0xFF:
  37475. stream.skip(-1);
  37476. break;
  37477. case 0xD9:
  37478. foundEOI = true;
  37479. break;
  37480. case 0xC0:
  37481. case 0xC1:
  37482. case 0xC2:
  37483. case 0xC3:
  37484. case 0xC5:
  37485. case 0xC6:
  37486. case 0xC7:
  37487. case 0xC9:
  37488. case 0xCA:
  37489. case 0xCB:
  37490. case 0xCD:
  37491. case 0xCE:
  37492. case 0xCF:
  37493. case 0xC4:
  37494. case 0xCC:
  37495. case 0xDA:
  37496. case 0xDB:
  37497. case 0xDC:
  37498. case 0xDD:
  37499. case 0xDE:
  37500. case 0xDF:
  37501. case 0xE0:
  37502. case 0xE1:
  37503. case 0xE2:
  37504. case 0xE3:
  37505. case 0xE4:
  37506. case 0xE5:
  37507. case 0xE6:
  37508. case 0xE7:
  37509. case 0xE8:
  37510. case 0xE9:
  37511. case 0xEA:
  37512. case 0xEB:
  37513. case 0xEC:
  37514. case 0xED:
  37515. case 0xEE:
  37516. case 0xEF:
  37517. case 0xFE:
  37518. markerLength = stream.getUint16();
  37519. if (markerLength > 2) {
  37520. stream.skip(markerLength - 2);
  37521. } else
  37522. {
  37523. stream.skip(-2);
  37524. }
  37525. break;
  37526. }
  37527. if (foundEOI) {
  37528. break;
  37529. }
  37530. }
  37531. length = stream.pos - startPos;
  37532. if (b === -1) {
  37533. warn('Inline DCTDecode image stream: ' + 'EOI marker not found, searching for /EI/ instead.');
  37534. stream.skip(-length);
  37535. return this.findDefaultInlineStreamEnd(stream);
  37536. }
  37537. this.inlineStreamSkipEI(stream);
  37538. return length;
  37539. },
  37540. findASCII85DecodeInlineStreamEnd: function Parser_findASCII85DecodeInlineStreamEnd(stream) {
  37541. var TILDE = 0x7E, GT = 0x3E;
  37542. var startPos = stream.pos, ch, length;
  37543. while ((ch = stream.getByte()) !== -1) {
  37544. if (ch === TILDE && stream.peekByte() === GT) {
  37545. stream.skip();
  37546. break;
  37547. }
  37548. }
  37549. length = stream.pos - startPos;
  37550. if (ch === -1) {
  37551. warn('Inline ASCII85Decode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37552. stream.skip(-length);
  37553. return this.findDefaultInlineStreamEnd(stream);
  37554. }
  37555. this.inlineStreamSkipEI(stream);
  37556. return length;
  37557. },
  37558. findASCIIHexDecodeInlineStreamEnd: function Parser_findASCIIHexDecodeInlineStreamEnd(stream) {
  37559. var GT = 0x3E;
  37560. var startPos = stream.pos, ch, length;
  37561. while ((ch = stream.getByte()) !== -1) {
  37562. if (ch === GT) {
  37563. break;
  37564. }
  37565. }
  37566. length = stream.pos - startPos;
  37567. if (ch === -1) {
  37568. warn('Inline ASCIIHexDecode image stream: ' + 'EOD marker not found, searching for /EI/ instead.');
  37569. stream.skip(-length);
  37570. return this.findDefaultInlineStreamEnd(stream);
  37571. }
  37572. this.inlineStreamSkipEI(stream);
  37573. return length;
  37574. },
  37575. inlineStreamSkipEI: function Parser_inlineStreamSkipEI(stream) {
  37576. var E = 0x45, I = 0x49;
  37577. var state = 0, ch;
  37578. while ((ch = stream.getByte()) !== -1) {
  37579. if (state === 0) {
  37580. state = ch === E ? 1 : 0;
  37581. } else if (state === 1) {
  37582. state = ch === I ? 2 : 0;
  37583. } else if (state === 2) {
  37584. break;
  37585. }
  37586. }
  37587. },
  37588. makeInlineImage: function Parser_makeInlineImage(cipherTransform) {
  37589. var lexer = this.lexer;
  37590. var stream = lexer.stream;
  37591. var dict = new Dict(this.xref);
  37592. while (!isCmd(this.buf1, 'ID') && !isEOF(this.buf1)) {
  37593. if (!isName(this.buf1)) {
  37594. error('Dictionary key must be a name object');
  37595. }
  37596. var key = this.buf1.name;
  37597. this.shift();
  37598. if (isEOF(this.buf1)) {
  37599. break;
  37600. }
  37601. dict.set(key, this.getObj(cipherTransform));
  37602. }
  37603. var filter = dict.get('Filter', 'F'), filterName;
  37604. if (isName(filter)) {
  37605. filterName = filter.name;
  37606. } else if (isArray(filter)) {
  37607. var filterZero = this.xref.fetchIfRef(filter[0]);
  37608. if (isName(filterZero)) {
  37609. filterName = filterZero.name;
  37610. }
  37611. }
  37612. var startPos = stream.pos, length, i, ii;
  37613. if (filterName === 'DCTDecode' || filterName === 'DCT') {
  37614. length = this.findDCTDecodeInlineStreamEnd(stream);
  37615. } else if (filterName === 'ASCII85Decide' || filterName === 'A85') {
  37616. length = this.findASCII85DecodeInlineStreamEnd(stream);
  37617. } else if (filterName === 'ASCIIHexDecode' || filterName === 'AHx') {
  37618. length = this.findASCIIHexDecodeInlineStreamEnd(stream);
  37619. } else {
  37620. length = this.findDefaultInlineStreamEnd(stream);
  37621. }
  37622. var imageStream = stream.makeSubStream(startPos, length, dict);
  37623. var adler32;
  37624. if (length < MAX_LENGTH_TO_CACHE) {
  37625. var imageBytes = imageStream.getBytes();
  37626. imageStream.reset();
  37627. var a = 1;
  37628. var b = 0;
  37629. for (i = 0, ii = imageBytes.length; i < ii; ++i) {
  37630. a += imageBytes[i] & 0xff;
  37631. b += a;
  37632. }
  37633. adler32 = b % 65521 << 16 | a % 65521;
  37634. if (this.imageCache.adler32 === adler32) {
  37635. this.buf2 = Cmd.get('EI');
  37636. this.shift();
  37637. this.imageCache[adler32].reset();
  37638. return this.imageCache[adler32];
  37639. }
  37640. }
  37641. if (cipherTransform) {
  37642. imageStream = cipherTransform.createStream(imageStream, length);
  37643. }
  37644. imageStream = this.filter(imageStream, dict, length);
  37645. imageStream.dict = dict;
  37646. if (adler32 !== undefined) {
  37647. imageStream.cacheKey = 'inline_' + length + '_' + adler32;
  37648. this.imageCache[adler32] = imageStream;
  37649. }
  37650. this.buf2 = Cmd.get('EI');
  37651. this.shift();
  37652. return imageStream;
  37653. },
  37654. makeStream: function Parser_makeStream(dict, cipherTransform) {
  37655. var lexer = this.lexer;
  37656. var stream = lexer.stream;
  37657. lexer.skipToNextLine();
  37658. var pos = stream.pos - 1;
  37659. var length = dict.get('Length');
  37660. if (!isInt(length)) {
  37661. info('Bad ' + length + ' attribute in stream');
  37662. length = 0;
  37663. }
  37664. stream.pos = pos + length;
  37665. lexer.nextChar();
  37666. if (this.tryShift() && isCmd(this.buf2, 'endstream')) {
  37667. this.shift();
  37668. } else
  37669. {
  37670. stream.pos = pos;
  37671. var SCAN_BLOCK_SIZE = 2048;
  37672. var ENDSTREAM_SIGNATURE_LENGTH = 9;
  37673. var ENDSTREAM_SIGNATURE = [
  37674. 0x65,
  37675. 0x6E,
  37676. 0x64,
  37677. 0x73,
  37678. 0x74,
  37679. 0x72,
  37680. 0x65,
  37681. 0x61,
  37682. 0x6D
  37683. ];
  37684. var skipped = 0, found = false, i, j;
  37685. while (stream.pos < stream.end) {
  37686. var scanBytes = stream.peekBytes(SCAN_BLOCK_SIZE);
  37687. var scanLength = scanBytes.length - ENDSTREAM_SIGNATURE_LENGTH;
  37688. if (scanLength <= 0) {
  37689. break;
  37690. }
  37691. found = false;
  37692. i = 0;
  37693. while (i < scanLength) {
  37694. j = 0;
  37695. while (j < ENDSTREAM_SIGNATURE_LENGTH && scanBytes[i + j] === ENDSTREAM_SIGNATURE[j]) {
  37696. j++;
  37697. }
  37698. if (j >= ENDSTREAM_SIGNATURE_LENGTH) {
  37699. found = true;
  37700. break;
  37701. }
  37702. i++;
  37703. }
  37704. if (found) {
  37705. skipped += i;
  37706. stream.pos += i;
  37707. break;
  37708. }
  37709. skipped += scanLength;
  37710. stream.pos += scanLength;
  37711. }
  37712. if (!found) {
  37713. error('Missing endstream');
  37714. }
  37715. length = skipped;
  37716. lexer.nextChar();
  37717. this.shift();
  37718. this.shift();
  37719. }
  37720. this.shift();
  37721. stream = stream.makeSubStream(pos, length, dict);
  37722. if (cipherTransform) {
  37723. stream = cipherTransform.createStream(stream, length);
  37724. }
  37725. stream = this.filter(stream, dict, length);
  37726. stream.dict = dict;
  37727. return stream;
  37728. },
  37729. filter: function Parser_filter(stream, dict, length) {
  37730. var filter = dict.get('Filter', 'F');
  37731. var params = dict.get('DecodeParms', 'DP');
  37732. if (isName(filter)) {
  37733. if (isArray(params)) {
  37734. params = this.xref.fetchIfRef(params[0]);
  37735. }
  37736. return this.makeFilter(stream, filter.name, length, params);
  37737. }
  37738. var maybeLength = length;
  37739. if (isArray(filter)) {
  37740. var filterArray = filter;
  37741. var paramsArray = params;
  37742. for (var i = 0, ii = filterArray.length; i < ii; ++i) {
  37743. filter = this.xref.fetchIfRef(filterArray[i]);
  37744. if (!isName(filter)) {
  37745. error('Bad filter name: ' + filter);
  37746. }
  37747. params = null;
  37748. if (isArray(paramsArray) && i in paramsArray) {
  37749. params = this.xref.fetchIfRef(paramsArray[i]);
  37750. }
  37751. stream = this.makeFilter(stream, filter.name, maybeLength, params);
  37752. maybeLength = null;
  37753. }
  37754. }
  37755. return stream;
  37756. },
  37757. makeFilter: function Parser_makeFilter(stream, name, maybeLength, params) {
  37758. if (maybeLength === 0) {
  37759. warn('Empty "' + name + '" stream.');
  37760. return new NullStream(stream);
  37761. }
  37762. try {
  37763. var xrefStreamStats = this.xref.stats.streamTypes;
  37764. if (name === 'FlateDecode' || name === 'Fl') {
  37765. xrefStreamStats[StreamType.FLATE] = true;
  37766. if (params) {
  37767. return new PredictorStream(new FlateStream(stream, maybeLength), maybeLength, params);
  37768. }
  37769. return new FlateStream(stream, maybeLength);
  37770. }
  37771. if (name === 'LZWDecode' || name === 'LZW') {
  37772. xrefStreamStats[StreamType.LZW] = true;
  37773. var earlyChange = 1;
  37774. if (params) {
  37775. if (params.has('EarlyChange')) {
  37776. earlyChange = params.get('EarlyChange');
  37777. }
  37778. return new PredictorStream(new LZWStream(stream, maybeLength, earlyChange), maybeLength, params);
  37779. }
  37780. return new LZWStream(stream, maybeLength, earlyChange);
  37781. }
  37782. if (name === 'DCTDecode' || name === 'DCT') {
  37783. xrefStreamStats[StreamType.DCT] = true;
  37784. return new JpegStream(stream, maybeLength, stream.dict, params);
  37785. }
  37786. if (name === 'JPXDecode' || name === 'JPX') {
  37787. xrefStreamStats[StreamType.JPX] = true;
  37788. return new JpxStream(stream, maybeLength, stream.dict, params);
  37789. }
  37790. if (name === 'ASCII85Decode' || name === 'A85') {
  37791. xrefStreamStats[StreamType.A85] = true;
  37792. return new Ascii85Stream(stream, maybeLength);
  37793. }
  37794. if (name === 'ASCIIHexDecode' || name === 'AHx') {
  37795. xrefStreamStats[StreamType.AHX] = true;
  37796. return new AsciiHexStream(stream, maybeLength);
  37797. }
  37798. if (name === 'CCITTFaxDecode' || name === 'CCF') {
  37799. xrefStreamStats[StreamType.CCF] = true;
  37800. return new CCITTFaxStream(stream, maybeLength, params);
  37801. }
  37802. if (name === 'RunLengthDecode' || name === 'RL') {
  37803. xrefStreamStats[StreamType.RL] = true;
  37804. return new RunLengthStream(stream, maybeLength);
  37805. }
  37806. if (name === 'JBIG2Decode') {
  37807. xrefStreamStats[StreamType.JBIG] = true;
  37808. return new Jbig2Stream(stream, maybeLength, stream.dict, params);
  37809. }
  37810. warn('filter "' + name + '" not supported yet');
  37811. return stream;
  37812. } catch (ex) {
  37813. if (ex instanceof MissingDataException) {
  37814. throw ex;
  37815. }
  37816. warn('Invalid stream: \"' + ex + '\"');
  37817. return new NullStream(stream);
  37818. }
  37819. }
  37820. };
  37821. return Parser;
  37822. }();
  37823. var Lexer = function LexerClosure() {
  37824. function Lexer(stream, knownCommands) {
  37825. this.stream = stream;
  37826. this.nextChar();
  37827. this.strBuf = [];
  37828. this.knownCommands = knownCommands;
  37829. }
  37830. var specialChars = [
  37831. 1,
  37832. 0,
  37833. 0,
  37834. 0,
  37835. 0,
  37836. 0,
  37837. 0,
  37838. 0,
  37839. 0,
  37840. 1,
  37841. 1,
  37842. 0,
  37843. 1,
  37844. 1,
  37845. 0,
  37846. 0,
  37847. 0,
  37848. 0,
  37849. 0,
  37850. 0,
  37851. 0,
  37852. 0,
  37853. 0,
  37854. 0,
  37855. 0,
  37856. 0,
  37857. 0,
  37858. 0,
  37859. 0,
  37860. 0,
  37861. 0,
  37862. 0,
  37863. 1,
  37864. 0,
  37865. 0,
  37866. 0,
  37867. 0,
  37868. 2,
  37869. 0,
  37870. 0,
  37871. 2,
  37872. 2,
  37873. 0,
  37874. 0,
  37875. 0,
  37876. 0,
  37877. 0,
  37878. 2,
  37879. 0,
  37880. 0,
  37881. 0,
  37882. 0,
  37883. 0,
  37884. 0,
  37885. 0,
  37886. 0,
  37887. 0,
  37888. 0,
  37889. 0,
  37890. 0,
  37891. 2,
  37892. 0,
  37893. 2,
  37894. 0,
  37895. 0,
  37896. 0,
  37897. 0,
  37898. 0,
  37899. 0,
  37900. 0,
  37901. 0,
  37902. 0,
  37903. 0,
  37904. 0,
  37905. 0,
  37906. 0,
  37907. 0,
  37908. 0,
  37909. 0,
  37910. 0,
  37911. 0,
  37912. 0,
  37913. 0,
  37914. 0,
  37915. 0,
  37916. 0,
  37917. 0,
  37918. 0,
  37919. 0,
  37920. 0,
  37921. 0,
  37922. 2,
  37923. 0,
  37924. 2,
  37925. 0,
  37926. 0,
  37927. 0,
  37928. 0,
  37929. 0,
  37930. 0,
  37931. 0,
  37932. 0,
  37933. 0,
  37934. 0,
  37935. 0,
  37936. 0,
  37937. 0,
  37938. 0,
  37939. 0,
  37940. 0,
  37941. 0,
  37942. 0,
  37943. 0,
  37944. 0,
  37945. 0,
  37946. 0,
  37947. 0,
  37948. 0,
  37949. 0,
  37950. 0,
  37951. 0,
  37952. 0,
  37953. 0,
  37954. 2,
  37955. 0,
  37956. 2,
  37957. 0,
  37958. 0,
  37959. 0,
  37960. 0,
  37961. 0,
  37962. 0,
  37963. 0,
  37964. 0,
  37965. 0,
  37966. 0,
  37967. 0,
  37968. 0,
  37969. 0,
  37970. 0,
  37971. 0,
  37972. 0,
  37973. 0,
  37974. 0,
  37975. 0,
  37976. 0,
  37977. 0,
  37978. 0,
  37979. 0,
  37980. 0,
  37981. 0,
  37982. 0,
  37983. 0,
  37984. 0,
  37985. 0,
  37986. 0,
  37987. 0,
  37988. 0,
  37989. 0,
  37990. 0,
  37991. 0,
  37992. 0,
  37993. 0,
  37994. 0,
  37995. 0,
  37996. 0,
  37997. 0,
  37998. 0,
  37999. 0,
  38000. 0,
  38001. 0,
  38002. 0,
  38003. 0,
  38004. 0,
  38005. 0,
  38006. 0,
  38007. 0,
  38008. 0,
  38009. 0,
  38010. 0,
  38011. 0,
  38012. 0,
  38013. 0,
  38014. 0,
  38015. 0,
  38016. 0,
  38017. 0,
  38018. 0,
  38019. 0,
  38020. 0,
  38021. 0,
  38022. 0,
  38023. 0,
  38024. 0,
  38025. 0,
  38026. 0,
  38027. 0,
  38028. 0,
  38029. 0,
  38030. 0,
  38031. 0,
  38032. 0,
  38033. 0,
  38034. 0,
  38035. 0,
  38036. 0,
  38037. 0,
  38038. 0,
  38039. 0,
  38040. 0,
  38041. 0,
  38042. 0,
  38043. 0,
  38044. 0,
  38045. 0,
  38046. 0,
  38047. 0,
  38048. 0,
  38049. 0,
  38050. 0,
  38051. 0,
  38052. 0,
  38053. 0,
  38054. 0,
  38055. 0,
  38056. 0,
  38057. 0,
  38058. 0,
  38059. 0,
  38060. 0,
  38061. 0,
  38062. 0,
  38063. 0,
  38064. 0,
  38065. 0,
  38066. 0,
  38067. 0,
  38068. 0,
  38069. 0,
  38070. 0,
  38071. 0,
  38072. 0,
  38073. 0,
  38074. 0,
  38075. 0,
  38076. 0,
  38077. 0,
  38078. 0,
  38079. 0,
  38080. 0,
  38081. 0,
  38082. 0,
  38083. 0,
  38084. 0,
  38085. 0,
  38086. 0
  38087. ];
  38088. function toHexDigit(ch) {
  38089. if (ch >= 0x30 && ch <= 0x39) {
  38090. return ch & 0x0F;
  38091. }
  38092. if (ch >= 0x41 && ch <= 0x46 || ch >= 0x61 && ch <= 0x66) {
  38093. return (ch & 0x0F) + 9;
  38094. }
  38095. return -1;
  38096. }
  38097. Lexer.prototype = {
  38098. nextChar: function Lexer_nextChar() {
  38099. return this.currentChar = this.stream.getByte();
  38100. },
  38101. peekChar: function Lexer_peekChar() {
  38102. return this.stream.peekByte();
  38103. },
  38104. getNumber: function Lexer_getNumber() {
  38105. var ch = this.currentChar;
  38106. var eNotation = false;
  38107. var divideBy = 0;
  38108. var sign = 1;
  38109. if (ch === 0x2D) {
  38110. sign = -1;
  38111. ch = this.nextChar();
  38112. if (ch === 0x2D) {
  38113. ch = this.nextChar();
  38114. }
  38115. } else if (ch === 0x2B) {
  38116. ch = this.nextChar();
  38117. }
  38118. if (ch === 0x2E) {
  38119. divideBy = 10;
  38120. ch = this.nextChar();
  38121. }
  38122. if (ch < 0x30 || ch > 0x39) {
  38123. error('Invalid number: ' + String.fromCharCode(ch));
  38124. return 0;
  38125. }
  38126. var baseValue = ch - 0x30;
  38127. var powerValue = 0;
  38128. var powerValueSign = 1;
  38129. while ((ch = this.nextChar()) >= 0) {
  38130. if (0x30 <= ch && ch <= 0x39) {
  38131. var currentDigit = ch - 0x30;
  38132. if (eNotation) {
  38133. powerValue = powerValue * 10 + currentDigit;
  38134. } else {
  38135. if (divideBy !== 0) {
  38136. divideBy *= 10;
  38137. }
  38138. baseValue = baseValue * 10 + currentDigit;
  38139. }
  38140. } else if (ch === 0x2E) {
  38141. if (divideBy === 0) {
  38142. divideBy = 1;
  38143. } else {
  38144. break;
  38145. }
  38146. } else if (ch === 0x2D) {
  38147. warn('Badly formatted number');
  38148. } else if (ch === 0x45 || ch === 0x65) {
  38149. ch = this.peekChar();
  38150. if (ch === 0x2B || ch === 0x2D) {
  38151. powerValueSign = ch === 0x2D ? -1 : 1;
  38152. this.nextChar();
  38153. } else if (ch < 0x30 || ch > 0x39) {
  38154. break;
  38155. }
  38156. eNotation = true;
  38157. } else {
  38158. break;
  38159. }
  38160. }
  38161. if (divideBy !== 0) {
  38162. baseValue /= divideBy;
  38163. }
  38164. if (eNotation) {
  38165. baseValue *= Math.pow(10, powerValueSign * powerValue);
  38166. }
  38167. return sign * baseValue;
  38168. },
  38169. getString: function Lexer_getString() {
  38170. var numParen = 1;
  38171. var done = false;
  38172. var strBuf = this.strBuf;
  38173. strBuf.length = 0;
  38174. var ch = this.nextChar();
  38175. while (true) {
  38176. var charBuffered = false;
  38177. switch (ch | 0) {
  38178. case -1:
  38179. warn('Unterminated string');
  38180. done = true;
  38181. break;
  38182. case 0x28:
  38183. ++numParen;
  38184. strBuf.push('(');
  38185. break;
  38186. case 0x29:
  38187. if (--numParen === 0) {
  38188. this.nextChar();
  38189. done = true;
  38190. } else {
  38191. strBuf.push(')');
  38192. }
  38193. break;
  38194. case 0x5C:
  38195. ch = this.nextChar();
  38196. switch (ch) {
  38197. case -1:
  38198. warn('Unterminated string');
  38199. done = true;
  38200. break;
  38201. case 0x6E:
  38202. strBuf.push('\n');
  38203. break;
  38204. case 0x72:
  38205. strBuf.push('\r');
  38206. break;
  38207. case 0x74:
  38208. strBuf.push('\t');
  38209. break;
  38210. case 0x62:
  38211. strBuf.push('\b');
  38212. break;
  38213. case 0x66:
  38214. strBuf.push('\f');
  38215. break;
  38216. case 0x5C:
  38217. case 0x28:
  38218. case 0x29:
  38219. strBuf.push(String.fromCharCode(ch));
  38220. break;
  38221. case 0x30:
  38222. case 0x31:
  38223. case 0x32:
  38224. case 0x33:
  38225. case 0x34:
  38226. case 0x35:
  38227. case 0x36:
  38228. case 0x37:
  38229. var x = ch & 0x0F;
  38230. ch = this.nextChar();
  38231. charBuffered = true;
  38232. if (ch >= 0x30 && ch <= 0x37) {
  38233. x = (x << 3) + (ch & 0x0F);
  38234. ch = this.nextChar();
  38235. if (ch >= 0x30 && ch <= 0x37) {
  38236. charBuffered = false;
  38237. x = (x << 3) + (ch & 0x0F);
  38238. }
  38239. }
  38240. strBuf.push(String.fromCharCode(x));
  38241. break;
  38242. case 0x0D:
  38243. if (this.peekChar() === 0x0A) {
  38244. this.nextChar();
  38245. }
  38246. break;
  38247. case 0x0A:
  38248. break;
  38249. default:
  38250. strBuf.push(String.fromCharCode(ch));
  38251. break;
  38252. }
  38253. break;
  38254. default:
  38255. strBuf.push(String.fromCharCode(ch));
  38256. break;
  38257. }
  38258. if (done) {
  38259. break;
  38260. }
  38261. if (!charBuffered) {
  38262. ch = this.nextChar();
  38263. }
  38264. }
  38265. return strBuf.join('');
  38266. },
  38267. getName: function Lexer_getName() {
  38268. var ch, previousCh;
  38269. var strBuf = this.strBuf;
  38270. strBuf.length = 0;
  38271. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38272. if (ch === 0x23) {
  38273. ch = this.nextChar();
  38274. if (specialChars[ch]) {
  38275. warn('Lexer_getName: ' + 'NUMBER SIGN (#) should be followed by a hexadecimal number.');
  38276. strBuf.push('#');
  38277. break;
  38278. }
  38279. var x = toHexDigit(ch);
  38280. if (x !== -1) {
  38281. previousCh = ch;
  38282. ch = this.nextChar();
  38283. var x2 = toHexDigit(ch);
  38284. if (x2 === -1) {
  38285. warn('Lexer_getName: Illegal digit (' + String.fromCharCode(ch) + ') in hexadecimal number.');
  38286. strBuf.push('#', String.fromCharCode(previousCh));
  38287. if (specialChars[ch]) {
  38288. break;
  38289. }
  38290. strBuf.push(String.fromCharCode(ch));
  38291. continue;
  38292. }
  38293. strBuf.push(String.fromCharCode(x << 4 | x2));
  38294. } else {
  38295. strBuf.push('#', String.fromCharCode(ch));
  38296. }
  38297. } else {
  38298. strBuf.push(String.fromCharCode(ch));
  38299. }
  38300. }
  38301. if (strBuf.length > 127) {
  38302. warn('name token is longer than allowed by the spec: ' + strBuf.length);
  38303. }
  38304. return Name.get(strBuf.join(''));
  38305. },
  38306. getHexString: function Lexer_getHexString() {
  38307. var strBuf = this.strBuf;
  38308. strBuf.length = 0;
  38309. var ch = this.currentChar;
  38310. var isFirstHex = true;
  38311. var firstDigit;
  38312. var secondDigit;
  38313. while (true) {
  38314. if (ch < 0) {
  38315. warn('Unterminated hex string');
  38316. break;
  38317. } else if (ch === 0x3E) {
  38318. this.nextChar();
  38319. break;
  38320. } else if (specialChars[ch] === 1) {
  38321. ch = this.nextChar();
  38322. continue;
  38323. } else {
  38324. if (isFirstHex) {
  38325. firstDigit = toHexDigit(ch);
  38326. if (firstDigit === -1) {
  38327. warn('Ignoring invalid character "' + ch + '" in hex string');
  38328. ch = this.nextChar();
  38329. continue;
  38330. }
  38331. } else {
  38332. secondDigit = toHexDigit(ch);
  38333. if (secondDigit === -1) {
  38334. warn('Ignoring invalid character "' + ch + '" in hex string');
  38335. ch = this.nextChar();
  38336. continue;
  38337. }
  38338. strBuf.push(String.fromCharCode(firstDigit << 4 | secondDigit));
  38339. }
  38340. isFirstHex = !isFirstHex;
  38341. ch = this.nextChar();
  38342. }
  38343. }
  38344. return strBuf.join('');
  38345. },
  38346. getObj: function Lexer_getObj() {
  38347. var comment = false;
  38348. var ch = this.currentChar;
  38349. while (true) {
  38350. if (ch < 0) {
  38351. return EOF;
  38352. }
  38353. if (comment) {
  38354. if (ch === 0x0A || ch === 0x0D) {
  38355. comment = false;
  38356. }
  38357. } else if (ch === 0x25) {
  38358. comment = true;
  38359. } else if (specialChars[ch] !== 1) {
  38360. break;
  38361. }
  38362. ch = this.nextChar();
  38363. }
  38364. switch (ch | 0) {
  38365. case 0x30:
  38366. case 0x31:
  38367. case 0x32:
  38368. case 0x33:
  38369. case 0x34:
  38370. case 0x35:
  38371. case 0x36:
  38372. case 0x37:
  38373. case 0x38:
  38374. case 0x39:
  38375. case 0x2B:
  38376. case 0x2D:
  38377. case 0x2E:
  38378. return this.getNumber();
  38379. case 0x28:
  38380. return this.getString();
  38381. case 0x2F:
  38382. return this.getName();
  38383. case 0x5B:
  38384. this.nextChar();
  38385. return Cmd.get('[');
  38386. case 0x5D:
  38387. this.nextChar();
  38388. return Cmd.get(']');
  38389. case 0x3C:
  38390. ch = this.nextChar();
  38391. if (ch === 0x3C) {
  38392. this.nextChar();
  38393. return Cmd.get('<<');
  38394. }
  38395. return this.getHexString();
  38396. case 0x3E:
  38397. ch = this.nextChar();
  38398. if (ch === 0x3E) {
  38399. this.nextChar();
  38400. return Cmd.get('>>');
  38401. }
  38402. return Cmd.get('>');
  38403. case 0x7B:
  38404. this.nextChar();
  38405. return Cmd.get('{');
  38406. case 0x7D:
  38407. this.nextChar();
  38408. return Cmd.get('}');
  38409. case 0x29:
  38410. error('Illegal character: ' + ch);
  38411. break;
  38412. }
  38413. var str = String.fromCharCode(ch);
  38414. var knownCommands = this.knownCommands;
  38415. var knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38416. while ((ch = this.nextChar()) >= 0 && !specialChars[ch]) {
  38417. var possibleCommand = str + String.fromCharCode(ch);
  38418. if (knownCommandFound && knownCommands[possibleCommand] === undefined) {
  38419. break;
  38420. }
  38421. if (str.length === 128) {
  38422. error('Command token too long: ' + str.length);
  38423. }
  38424. str = possibleCommand;
  38425. knownCommandFound = knownCommands && knownCommands[str] !== undefined;
  38426. }
  38427. if (str === 'true') {
  38428. return true;
  38429. }
  38430. if (str === 'false') {
  38431. return false;
  38432. }
  38433. if (str === 'null') {
  38434. return null;
  38435. }
  38436. return Cmd.get(str);
  38437. },
  38438. skipToNextLine: function Lexer_skipToNextLine() {
  38439. var ch = this.currentChar;
  38440. while (ch >= 0) {
  38441. if (ch === 0x0D) {
  38442. ch = this.nextChar();
  38443. if (ch === 0x0A) {
  38444. this.nextChar();
  38445. }
  38446. break;
  38447. } else if (ch === 0x0A) {
  38448. this.nextChar();
  38449. break;
  38450. }
  38451. ch = this.nextChar();
  38452. }
  38453. }
  38454. };
  38455. return Lexer;
  38456. }();
  38457. var Linearization = {
  38458. create: function LinearizationCreate(stream) {
  38459. function getInt(name, allowZeroValue) {
  38460. var obj = linDict.get(name);
  38461. if (isInt(obj) && (allowZeroValue ? obj >= 0 : obj > 0)) {
  38462. return obj;
  38463. }
  38464. throw new Error('The "' + name + '" parameter in the linearization ' + 'dictionary is invalid.');
  38465. }
  38466. function getHints() {
  38467. var hints = linDict.get('H'), hintsLength, item;
  38468. if (isArray(hints) && ((hintsLength = hints.length) === 2 || hintsLength === 4)) {
  38469. for (var index = 0; index < hintsLength; index++) {
  38470. if (!(isInt(item = hints[index]) && item > 0)) {
  38471. throw new Error('Hint (' + index + ') in the linearization dictionary is invalid.');
  38472. }
  38473. }
  38474. return hints;
  38475. }
  38476. throw new Error('Hint array in the linearization dictionary is invalid.');
  38477. }
  38478. var parser = new Parser(new Lexer(stream), false, null);
  38479. var obj1 = parser.getObj();
  38480. var obj2 = parser.getObj();
  38481. var obj3 = parser.getObj();
  38482. var linDict = parser.getObj();
  38483. var obj, length;
  38484. if (!(isInt(obj1) && isInt(obj2) && isCmd(obj3, 'obj') && isDict(linDict) && isNum(obj = linDict.get('Linearized')) && obj > 0)) {
  38485. return null;
  38486. } else if ((length = getInt('L')) !== stream.length) {
  38487. throw new Error('The "L" parameter in the linearization dictionary ' + 'does not equal the stream length.');
  38488. }
  38489. return {
  38490. length: length,
  38491. hints: getHints(),
  38492. objectNumberFirst: getInt('O'),
  38493. endFirst: getInt('E'),
  38494. numPages: getInt('N'),
  38495. mainXRefEntriesOffset: getInt('T'),
  38496. pageFirst: linDict.has('P') ? getInt('P', true) : 0
  38497. };
  38498. }
  38499. };
  38500. exports.EOF = EOF;
  38501. exports.Lexer = Lexer;
  38502. exports.Linearization = Linearization;
  38503. exports.Parser = Parser;
  38504. exports.isEOF = isEOF;
  38505. }));
  38506. (function (root, factory) {
  38507. factory(root.pdfjsCoreType1Parser = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreEncodings);
  38508. }(this, function (exports, sharedUtil, coreStream, coreEncodings) {
  38509. var warn = sharedUtil.warn;
  38510. var isSpace = sharedUtil.isSpace;
  38511. var Stream = coreStream.Stream;
  38512. var getEncoding = coreEncodings.getEncoding;
  38513. var HINTING_ENABLED = false;
  38514. var Type1CharString = function Type1CharStringClosure() {
  38515. var COMMAND_MAP = {
  38516. 'hstem': [1],
  38517. 'vstem': [3],
  38518. 'vmoveto': [4],
  38519. 'rlineto': [5],
  38520. 'hlineto': [6],
  38521. 'vlineto': [7],
  38522. 'rrcurveto': [8],
  38523. 'callsubr': [10],
  38524. 'flex': [
  38525. 12,
  38526. 35
  38527. ],
  38528. 'drop': [
  38529. 12,
  38530. 18
  38531. ],
  38532. 'endchar': [14],
  38533. 'rmoveto': [21],
  38534. 'hmoveto': [22],
  38535. 'vhcurveto': [30],
  38536. 'hvcurveto': [31]
  38537. };
  38538. function Type1CharString() {
  38539. this.width = 0;
  38540. this.lsb = 0;
  38541. this.flexing = false;
  38542. this.output = [];
  38543. this.stack = [];
  38544. }
  38545. Type1CharString.prototype = {
  38546. convert: function Type1CharString_convert(encoded, subrs, seacAnalysisEnabled) {
  38547. var count = encoded.length;
  38548. var error = false;
  38549. var wx, sbx, subrNumber;
  38550. for (var i = 0; i < count; i++) {
  38551. var value = encoded[i];
  38552. if (value < 32) {
  38553. if (value === 12) {
  38554. value = (value << 8) + encoded[++i];
  38555. }
  38556. switch (value) {
  38557. case 1:
  38558. if (!HINTING_ENABLED) {
  38559. this.stack = [];
  38560. break;
  38561. }
  38562. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38563. break;
  38564. case 3:
  38565. if (!HINTING_ENABLED) {
  38566. this.stack = [];
  38567. break;
  38568. }
  38569. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38570. break;
  38571. case 4:
  38572. if (this.flexing) {
  38573. if (this.stack.length < 1) {
  38574. error = true;
  38575. break;
  38576. }
  38577. var dy = this.stack.pop();
  38578. this.stack.push(0, dy);
  38579. break;
  38580. }
  38581. error = this.executeCommand(1, COMMAND_MAP.vmoveto);
  38582. break;
  38583. case 5:
  38584. error = this.executeCommand(2, COMMAND_MAP.rlineto);
  38585. break;
  38586. case 6:
  38587. error = this.executeCommand(1, COMMAND_MAP.hlineto);
  38588. break;
  38589. case 7:
  38590. error = this.executeCommand(1, COMMAND_MAP.vlineto);
  38591. break;
  38592. case 8:
  38593. error = this.executeCommand(6, COMMAND_MAP.rrcurveto);
  38594. break;
  38595. case 9:
  38596. this.stack = [];
  38597. break;
  38598. case 10:
  38599. if (this.stack.length < 1) {
  38600. error = true;
  38601. break;
  38602. }
  38603. subrNumber = this.stack.pop();
  38604. error = this.convert(subrs[subrNumber], subrs, seacAnalysisEnabled);
  38605. break;
  38606. case 11:
  38607. return error;
  38608. case 13:
  38609. if (this.stack.length < 2) {
  38610. error = true;
  38611. break;
  38612. }
  38613. wx = this.stack.pop();
  38614. sbx = this.stack.pop();
  38615. this.lsb = sbx;
  38616. this.width = wx;
  38617. this.stack.push(wx, sbx);
  38618. error = this.executeCommand(2, COMMAND_MAP.hmoveto);
  38619. break;
  38620. case 14:
  38621. this.output.push(COMMAND_MAP.endchar[0]);
  38622. break;
  38623. case 21:
  38624. if (this.flexing) {
  38625. break;
  38626. }
  38627. error = this.executeCommand(2, COMMAND_MAP.rmoveto);
  38628. break;
  38629. case 22:
  38630. if (this.flexing) {
  38631. this.stack.push(0);
  38632. break;
  38633. }
  38634. error = this.executeCommand(1, COMMAND_MAP.hmoveto);
  38635. break;
  38636. case 30:
  38637. error = this.executeCommand(4, COMMAND_MAP.vhcurveto);
  38638. break;
  38639. case 31:
  38640. error = this.executeCommand(4, COMMAND_MAP.hvcurveto);
  38641. break;
  38642. case (12 << 8) + 0:
  38643. this.stack = [];
  38644. break;
  38645. case (12 << 8) + 1:
  38646. if (!HINTING_ENABLED) {
  38647. this.stack = [];
  38648. break;
  38649. }
  38650. error = this.executeCommand(2, COMMAND_MAP.vstem);
  38651. break;
  38652. case (12 << 8) + 2:
  38653. if (!HINTING_ENABLED) {
  38654. this.stack = [];
  38655. break;
  38656. }
  38657. error = this.executeCommand(2, COMMAND_MAP.hstem);
  38658. break;
  38659. case (12 << 8) + 6:
  38660. if (seacAnalysisEnabled) {
  38661. this.seac = this.stack.splice(-4, 4);
  38662. error = this.executeCommand(0, COMMAND_MAP.endchar);
  38663. } else {
  38664. error = this.executeCommand(4, COMMAND_MAP.endchar);
  38665. }
  38666. break;
  38667. case (12 << 8) + 7:
  38668. if (this.stack.length < 4) {
  38669. error = true;
  38670. break;
  38671. }
  38672. var wy = this.stack.pop();
  38673. wx = this.stack.pop();
  38674. var sby = this.stack.pop();
  38675. sbx = this.stack.pop();
  38676. this.lsb = sbx;
  38677. this.width = wx;
  38678. this.stack.push(wx, sbx, sby);
  38679. error = this.executeCommand(3, COMMAND_MAP.rmoveto);
  38680. break;
  38681. case (12 << 8) + 12:
  38682. if (this.stack.length < 2) {
  38683. error = true;
  38684. break;
  38685. }
  38686. var num2 = this.stack.pop();
  38687. var num1 = this.stack.pop();
  38688. this.stack.push(num1 / num2);
  38689. break;
  38690. case (12 << 8) + 16:
  38691. if (this.stack.length < 2) {
  38692. error = true;
  38693. break;
  38694. }
  38695. subrNumber = this.stack.pop();
  38696. var numArgs = this.stack.pop();
  38697. if (subrNumber === 0 && numArgs === 3) {
  38698. var flexArgs = this.stack.splice(this.stack.length - 17, 17);
  38699. 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]);
  38700. error = this.executeCommand(13, COMMAND_MAP.flex, true);
  38701. this.flexing = false;
  38702. this.stack.push(flexArgs[15], flexArgs[16]);
  38703. } else if (subrNumber === 1 && numArgs === 0) {
  38704. this.flexing = true;
  38705. }
  38706. break;
  38707. case (12 << 8) + 17:
  38708. break;
  38709. case (12 << 8) + 33:
  38710. this.stack = [];
  38711. break;
  38712. default:
  38713. warn('Unknown type 1 charstring command of "' + value + '"');
  38714. break;
  38715. }
  38716. if (error) {
  38717. break;
  38718. }
  38719. continue;
  38720. } else if (value <= 246) {
  38721. value = value - 139;
  38722. } else if (value <= 250) {
  38723. value = (value - 247) * 256 + encoded[++i] + 108;
  38724. } else if (value <= 254) {
  38725. value = -((value - 251) * 256) - encoded[++i] - 108;
  38726. } else {
  38727. value = (encoded[++i] & 0xff) << 24 | (encoded[++i] & 0xff) << 16 | (encoded[++i] & 0xff) << 8 | (encoded[++i] & 0xff) << 0;
  38728. }
  38729. this.stack.push(value);
  38730. }
  38731. return error;
  38732. },
  38733. executeCommand: function (howManyArgs, command, keepStack) {
  38734. var stackLength = this.stack.length;
  38735. if (howManyArgs > stackLength) {
  38736. return true;
  38737. }
  38738. var start = stackLength - howManyArgs;
  38739. for (var i = start; i < stackLength; i++) {
  38740. var value = this.stack[i];
  38741. if (value === (value | 0)) {
  38742. this.output.push(28, value >> 8 & 0xff, value & 0xff);
  38743. } else {
  38744. value = 65536 * value | 0;
  38745. this.output.push(255, value >> 24 & 0xFF, value >> 16 & 0xFF, value >> 8 & 0xFF, value & 0xFF);
  38746. }
  38747. }
  38748. this.output.push.apply(this.output, command);
  38749. if (keepStack) {
  38750. this.stack.splice(start, howManyArgs);
  38751. } else {
  38752. this.stack.length = 0;
  38753. }
  38754. return false;
  38755. }
  38756. };
  38757. return Type1CharString;
  38758. }();
  38759. var Type1Parser = function Type1ParserClosure() {
  38760. var EEXEC_ENCRYPT_KEY = 55665;
  38761. var CHAR_STRS_ENCRYPT_KEY = 4330;
  38762. function isHexDigit(code) {
  38763. return code >= 48 && code <= 57 || code >= 65 && code <= 70 || code >= 97 && code <= 102;
  38764. }
  38765. function decrypt(data, key, discardNumber) {
  38766. if (discardNumber >= data.length) {
  38767. return new Uint8Array(0);
  38768. }
  38769. var r = key | 0, c1 = 52845, c2 = 22719, i, j;
  38770. for (i = 0; i < discardNumber; i++) {
  38771. r = (data[i] + r) * c1 + c2 & (1 << 16) - 1;
  38772. }
  38773. var count = data.length - discardNumber;
  38774. var decrypted = new Uint8Array(count);
  38775. for (i = discardNumber, j = 0; j < count; i++, j++) {
  38776. var value = data[i];
  38777. decrypted[j] = value ^ r >> 8;
  38778. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38779. }
  38780. return decrypted;
  38781. }
  38782. function decryptAscii(data, key, discardNumber) {
  38783. var r = key | 0, c1 = 52845, c2 = 22719;
  38784. var count = data.length, maybeLength = count >>> 1;
  38785. var decrypted = new Uint8Array(maybeLength);
  38786. var i, j;
  38787. for (i = 0, j = 0; i < count; i++) {
  38788. var digit1 = data[i];
  38789. if (!isHexDigit(digit1)) {
  38790. continue;
  38791. }
  38792. i++;
  38793. var digit2;
  38794. while (i < count && !isHexDigit(digit2 = data[i])) {
  38795. i++;
  38796. }
  38797. if (i < count) {
  38798. var value = parseInt(String.fromCharCode(digit1, digit2), 16);
  38799. decrypted[j++] = value ^ r >> 8;
  38800. r = (value + r) * c1 + c2 & (1 << 16) - 1;
  38801. }
  38802. }
  38803. return Array.prototype.slice.call(decrypted, discardNumber, j);
  38804. }
  38805. function isSpecial(c) {
  38806. return c === 0x2F || c === 0x5B || c === 0x5D || c === 0x7B || c === 0x7D || c === 0x28 || c === 0x29;
  38807. }
  38808. function Type1Parser(stream, encrypted, seacAnalysisEnabled) {
  38809. if (encrypted) {
  38810. var data = stream.getBytes();
  38811. var isBinary = !(isHexDigit(data[0]) && isHexDigit(data[1]) && isHexDigit(data[2]) && isHexDigit(data[3]));
  38812. stream = new Stream(isBinary ? decrypt(data, EEXEC_ENCRYPT_KEY, 4) : decryptAscii(data, EEXEC_ENCRYPT_KEY, 4));
  38813. }
  38814. this.seacAnalysisEnabled = !!seacAnalysisEnabled;
  38815. this.stream = stream;
  38816. this.nextChar();
  38817. }
  38818. Type1Parser.prototype = {
  38819. readNumberArray: function Type1Parser_readNumberArray() {
  38820. this.getToken();
  38821. var array = [];
  38822. while (true) {
  38823. var token = this.getToken();
  38824. if (token === null || token === ']' || token === '}') {
  38825. break;
  38826. }
  38827. array.push(parseFloat(token || 0));
  38828. }
  38829. return array;
  38830. },
  38831. readNumber: function Type1Parser_readNumber() {
  38832. var token = this.getToken();
  38833. return parseFloat(token || 0);
  38834. },
  38835. readInt: function Type1Parser_readInt() {
  38836. var token = this.getToken();
  38837. return parseInt(token || 0, 10) | 0;
  38838. },
  38839. readBoolean: function Type1Parser_readBoolean() {
  38840. var token = this.getToken();
  38841. return token === 'true' ? 1 : 0;
  38842. },
  38843. nextChar: function Type1_nextChar() {
  38844. return this.currentChar = this.stream.getByte();
  38845. },
  38846. getToken: function Type1Parser_getToken() {
  38847. var comment = false;
  38848. var ch = this.currentChar;
  38849. while (true) {
  38850. if (ch === -1) {
  38851. return null;
  38852. }
  38853. if (comment) {
  38854. if (ch === 0x0A || ch === 0x0D) {
  38855. comment = false;
  38856. }
  38857. } else if (ch === 0x25) {
  38858. comment = true;
  38859. } else if (!isSpace(ch)) {
  38860. break;
  38861. }
  38862. ch = this.nextChar();
  38863. }
  38864. if (isSpecial(ch)) {
  38865. this.nextChar();
  38866. return String.fromCharCode(ch);
  38867. }
  38868. var token = '';
  38869. do {
  38870. token += String.fromCharCode(ch);
  38871. ch = this.nextChar();
  38872. } while (ch >= 0 && !isSpace(ch) && !isSpecial(ch));
  38873. return token;
  38874. },
  38875. extractFontProgram: function Type1Parser_extractFontProgram() {
  38876. var stream = this.stream;
  38877. var subrs = [], charstrings = [];
  38878. var privateData = Object.create(null);
  38879. privateData['lenIV'] = 4;
  38880. var program = {
  38881. subrs: [],
  38882. charstrings: [],
  38883. properties: { 'privateData': privateData }
  38884. };
  38885. var token, length, data, lenIV, encoded;
  38886. while ((token = this.getToken()) !== null) {
  38887. if (token !== '/') {
  38888. continue;
  38889. }
  38890. token = this.getToken();
  38891. switch (token) {
  38892. case 'CharStrings':
  38893. this.getToken();
  38894. this.getToken();
  38895. this.getToken();
  38896. this.getToken();
  38897. while (true) {
  38898. token = this.getToken();
  38899. if (token === null || token === 'end') {
  38900. break;
  38901. }
  38902. if (token !== '/') {
  38903. continue;
  38904. }
  38905. var glyph = this.getToken();
  38906. length = this.readInt();
  38907. this.getToken();
  38908. data = stream.makeSubStream(stream.pos, length);
  38909. lenIV = program.properties.privateData['lenIV'];
  38910. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  38911. stream.skip(length);
  38912. this.nextChar();
  38913. token = this.getToken();
  38914. if (token === 'noaccess') {
  38915. this.getToken();
  38916. }
  38917. charstrings.push({
  38918. glyph: glyph,
  38919. encoded: encoded
  38920. });
  38921. }
  38922. break;
  38923. case 'Subrs':
  38924. var num = this.readInt();
  38925. this.getToken();
  38926. while ((token = this.getToken()) === 'dup') {
  38927. var index = this.readInt();
  38928. length = this.readInt();
  38929. this.getToken();
  38930. data = stream.makeSubStream(stream.pos, length);
  38931. lenIV = program.properties.privateData['lenIV'];
  38932. encoded = decrypt(data.getBytes(), CHAR_STRS_ENCRYPT_KEY, lenIV);
  38933. stream.skip(length);
  38934. this.nextChar();
  38935. token = this.getToken();
  38936. if (token === 'noaccess') {
  38937. this.getToken();
  38938. }
  38939. subrs[index] = encoded;
  38940. }
  38941. break;
  38942. case 'BlueValues':
  38943. case 'OtherBlues':
  38944. case 'FamilyBlues':
  38945. case 'FamilyOtherBlues':
  38946. var blueArray = this.readNumberArray();
  38947. if (blueArray.length > 0 && blueArray.length % 2 === 0 && HINTING_ENABLED) {
  38948. program.properties.privateData[token] = blueArray;
  38949. }
  38950. break;
  38951. case 'StemSnapH':
  38952. case 'StemSnapV':
  38953. program.properties.privateData[token] = this.readNumberArray();
  38954. break;
  38955. case 'StdHW':
  38956. case 'StdVW':
  38957. program.properties.privateData[token] = this.readNumberArray()[0];
  38958. break;
  38959. case 'BlueShift':
  38960. case 'lenIV':
  38961. case 'BlueFuzz':
  38962. case 'BlueScale':
  38963. case 'LanguageGroup':
  38964. case 'ExpansionFactor':
  38965. program.properties.privateData[token] = this.readNumber();
  38966. break;
  38967. case 'ForceBold':
  38968. program.properties.privateData[token] = this.readBoolean();
  38969. break;
  38970. }
  38971. }
  38972. for (var i = 0; i < charstrings.length; i++) {
  38973. glyph = charstrings[i].glyph;
  38974. encoded = charstrings[i].encoded;
  38975. var charString = new Type1CharString();
  38976. var error = charString.convert(encoded, subrs, this.seacAnalysisEnabled);
  38977. var output = charString.output;
  38978. if (error) {
  38979. output = [14];
  38980. }
  38981. program.charstrings.push({
  38982. glyphName: glyph,
  38983. charstring: output,
  38984. width: charString.width,
  38985. lsb: charString.lsb,
  38986. seac: charString.seac
  38987. });
  38988. }
  38989. return program;
  38990. },
  38991. extractFontHeader: function Type1Parser_extractFontHeader(properties) {
  38992. var token;
  38993. while ((token = this.getToken()) !== null) {
  38994. if (token !== '/') {
  38995. continue;
  38996. }
  38997. token = this.getToken();
  38998. switch (token) {
  38999. case 'FontMatrix':
  39000. var matrix = this.readNumberArray();
  39001. properties.fontMatrix = matrix;
  39002. break;
  39003. case 'Encoding':
  39004. var encodingArg = this.getToken();
  39005. var encoding;
  39006. if (!/^\d+$/.test(encodingArg)) {
  39007. encoding = getEncoding(encodingArg);
  39008. } else {
  39009. encoding = [];
  39010. var size = parseInt(encodingArg, 10) | 0;
  39011. this.getToken();
  39012. for (var j = 0; j < size; j++) {
  39013. token = this.getToken();
  39014. while (token !== 'dup' && token !== 'def') {
  39015. token = this.getToken();
  39016. if (token === null) {
  39017. return;
  39018. }
  39019. }
  39020. if (token === 'def') {
  39021. break;
  39022. }
  39023. var index = this.readInt();
  39024. this.getToken();
  39025. var glyph = this.getToken();
  39026. encoding[index] = glyph;
  39027. this.getToken();
  39028. }
  39029. }
  39030. properties.builtInEncoding = encoding;
  39031. break;
  39032. case 'FontBBox':
  39033. var fontBBox = this.readNumberArray();
  39034. properties.ascent = fontBBox[3];
  39035. properties.descent = fontBBox[1];
  39036. properties.ascentScaled = true;
  39037. break;
  39038. }
  39039. }
  39040. }
  39041. };
  39042. return Type1Parser;
  39043. }();
  39044. exports.Type1Parser = Type1Parser;
  39045. }));
  39046. (function (root, factory) {
  39047. factory(root.pdfjsDisplayPatternHelper = {}, root.pdfjsSharedUtil, root.pdfjsDisplayWebGL);
  39048. }(this, function (exports, sharedUtil, displayWebGL) {
  39049. var Util = sharedUtil.Util;
  39050. var info = sharedUtil.info;
  39051. var isArray = sharedUtil.isArray;
  39052. var error = sharedUtil.error;
  39053. var WebGLUtils = displayWebGL.WebGLUtils;
  39054. var ShadingIRs = {};
  39055. ShadingIRs.RadialAxial = {
  39056. fromIR: function RadialAxial_fromIR(raw) {
  39057. var type = raw[1];
  39058. var colorStops = raw[2];
  39059. var p0 = raw[3];
  39060. var p1 = raw[4];
  39061. var r0 = raw[5];
  39062. var r1 = raw[6];
  39063. return {
  39064. type: 'Pattern',
  39065. getPattern: function RadialAxial_getPattern(ctx) {
  39066. var grad;
  39067. if (type === 'axial') {
  39068. grad = ctx.createLinearGradient(p0[0], p0[1], p1[0], p1[1]);
  39069. } else if (type === 'radial') {
  39070. grad = ctx.createRadialGradient(p0[0], p0[1], r0, p1[0], p1[1], r1);
  39071. }
  39072. for (var i = 0, ii = colorStops.length; i < ii; ++i) {
  39073. var c = colorStops[i];
  39074. grad.addColorStop(c[0], c[1]);
  39075. }
  39076. return grad;
  39077. }
  39078. };
  39079. }
  39080. };
  39081. var createMeshCanvas = function createMeshCanvasClosure() {
  39082. function drawTriangle(data, context, p1, p2, p3, c1, c2, c3) {
  39083. var coords = context.coords, colors = context.colors;
  39084. var bytes = data.data, rowSize = data.width * 4;
  39085. var tmp;
  39086. if (coords[p1 + 1] > coords[p2 + 1]) {
  39087. tmp = p1;
  39088. p1 = p2;
  39089. p2 = tmp;
  39090. tmp = c1;
  39091. c1 = c2;
  39092. c2 = tmp;
  39093. }
  39094. if (coords[p2 + 1] > coords[p3 + 1]) {
  39095. tmp = p2;
  39096. p2 = p3;
  39097. p3 = tmp;
  39098. tmp = c2;
  39099. c2 = c3;
  39100. c3 = tmp;
  39101. }
  39102. if (coords[p1 + 1] > coords[p2 + 1]) {
  39103. tmp = p1;
  39104. p1 = p2;
  39105. p2 = tmp;
  39106. tmp = c1;
  39107. c1 = c2;
  39108. c2 = tmp;
  39109. }
  39110. var x1 = (coords[p1] + context.offsetX) * context.scaleX;
  39111. var y1 = (coords[p1 + 1] + context.offsetY) * context.scaleY;
  39112. var x2 = (coords[p2] + context.offsetX) * context.scaleX;
  39113. var y2 = (coords[p2 + 1] + context.offsetY) * context.scaleY;
  39114. var x3 = (coords[p3] + context.offsetX) * context.scaleX;
  39115. var y3 = (coords[p3 + 1] + context.offsetY) * context.scaleY;
  39116. if (y1 >= y3) {
  39117. return;
  39118. }
  39119. var c1r = colors[c1], c1g = colors[c1 + 1], c1b = colors[c1 + 2];
  39120. var c2r = colors[c2], c2g = colors[c2 + 1], c2b = colors[c2 + 2];
  39121. var c3r = colors[c3], c3g = colors[c3 + 1], c3b = colors[c3 + 2];
  39122. var minY = Math.round(y1), maxY = Math.round(y3);
  39123. var xa, car, cag, cab;
  39124. var xb, cbr, cbg, cbb;
  39125. var k;
  39126. for (var y = minY; y <= maxY; y++) {
  39127. if (y < y2) {
  39128. k = y < y1 ? 0 : y1 === y2 ? 1 : (y1 - y) / (y1 - y2);
  39129. xa = x1 - (x1 - x2) * k;
  39130. car = c1r - (c1r - c2r) * k;
  39131. cag = c1g - (c1g - c2g) * k;
  39132. cab = c1b - (c1b - c2b) * k;
  39133. } else {
  39134. k = y > y3 ? 1 : y2 === y3 ? 0 : (y2 - y) / (y2 - y3);
  39135. xa = x2 - (x2 - x3) * k;
  39136. car = c2r - (c2r - c3r) * k;
  39137. cag = c2g - (c2g - c3g) * k;
  39138. cab = c2b - (c2b - c3b) * k;
  39139. }
  39140. k = y < y1 ? 0 : y > y3 ? 1 : (y1 - y) / (y1 - y3);
  39141. xb = x1 - (x1 - x3) * k;
  39142. cbr = c1r - (c1r - c3r) * k;
  39143. cbg = c1g - (c1g - c3g) * k;
  39144. cbb = c1b - (c1b - c3b) * k;
  39145. var x1_ = Math.round(Math.min(xa, xb));
  39146. var x2_ = Math.round(Math.max(xa, xb));
  39147. var j = rowSize * y + x1_ * 4;
  39148. for (var x = x1_; x <= x2_; x++) {
  39149. k = (xa - x) / (xa - xb);
  39150. k = k < 0 ? 0 : k > 1 ? 1 : k;
  39151. bytes[j++] = car - (car - cbr) * k | 0;
  39152. bytes[j++] = cag - (cag - cbg) * k | 0;
  39153. bytes[j++] = cab - (cab - cbb) * k | 0;
  39154. bytes[j++] = 255;
  39155. }
  39156. }
  39157. }
  39158. function drawFigure(data, figure, context) {
  39159. var ps = figure.coords;
  39160. var cs = figure.colors;
  39161. var i, ii;
  39162. switch (figure.type) {
  39163. case 'lattice':
  39164. var verticesPerRow = figure.verticesPerRow;
  39165. var rows = Math.floor(ps.length / verticesPerRow) - 1;
  39166. var cols = verticesPerRow - 1;
  39167. for (i = 0; i < rows; i++) {
  39168. var q = i * verticesPerRow;
  39169. for (var j = 0; j < cols; j++, q++) {
  39170. drawTriangle(data, context, ps[q], ps[q + 1], ps[q + verticesPerRow], cs[q], cs[q + 1], cs[q + verticesPerRow]);
  39171. drawTriangle(data, context, ps[q + verticesPerRow + 1], ps[q + 1], ps[q + verticesPerRow], cs[q + verticesPerRow + 1], cs[q + 1], cs[q + verticesPerRow]);
  39172. }
  39173. }
  39174. break;
  39175. case 'triangles':
  39176. for (i = 0, ii = ps.length; i < ii; i += 3) {
  39177. drawTriangle(data, context, ps[i], ps[i + 1], ps[i + 2], cs[i], cs[i + 1], cs[i + 2]);
  39178. }
  39179. break;
  39180. default:
  39181. error('illigal figure');
  39182. break;
  39183. }
  39184. }
  39185. function createMeshCanvas(bounds, combinesScale, coords, colors, figures, backgroundColor, cachedCanvases) {
  39186. var EXPECTED_SCALE = 1.1;
  39187. var MAX_PATTERN_SIZE = 3000;
  39188. var BORDER_SIZE = 2;
  39189. var offsetX = Math.floor(bounds[0]);
  39190. var offsetY = Math.floor(bounds[1]);
  39191. var boundsWidth = Math.ceil(bounds[2]) - offsetX;
  39192. var boundsHeight = Math.ceil(bounds[3]) - offsetY;
  39193. var width = Math.min(Math.ceil(Math.abs(boundsWidth * combinesScale[0] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39194. var height = Math.min(Math.ceil(Math.abs(boundsHeight * combinesScale[1] * EXPECTED_SCALE)), MAX_PATTERN_SIZE);
  39195. var scaleX = boundsWidth / width;
  39196. var scaleY = boundsHeight / height;
  39197. var context = {
  39198. coords: coords,
  39199. colors: colors,
  39200. offsetX: -offsetX,
  39201. offsetY: -offsetY,
  39202. scaleX: 1 / scaleX,
  39203. scaleY: 1 / scaleY
  39204. };
  39205. var paddedWidth = width + BORDER_SIZE * 2;
  39206. var paddedHeight = height + BORDER_SIZE * 2;
  39207. var canvas, tmpCanvas, i, ii;
  39208. if (WebGLUtils.isEnabled) {
  39209. canvas = WebGLUtils.drawFigures(width, height, backgroundColor, figures, context);
  39210. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39211. tmpCanvas.context.drawImage(canvas, BORDER_SIZE, BORDER_SIZE);
  39212. canvas = tmpCanvas.canvas;
  39213. } else {
  39214. tmpCanvas = cachedCanvases.getCanvas('mesh', paddedWidth, paddedHeight, false);
  39215. var tmpCtx = tmpCanvas.context;
  39216. var data = tmpCtx.createImageData(width, height);
  39217. if (backgroundColor) {
  39218. var bytes = data.data;
  39219. for (i = 0, ii = bytes.length; i < ii; i += 4) {
  39220. bytes[i] = backgroundColor[0];
  39221. bytes[i + 1] = backgroundColor[1];
  39222. bytes[i + 2] = backgroundColor[2];
  39223. bytes[i + 3] = 255;
  39224. }
  39225. }
  39226. for (i = 0; i < figures.length; i++) {
  39227. drawFigure(data, figures[i], context);
  39228. }
  39229. tmpCtx.putImageData(data, BORDER_SIZE, BORDER_SIZE);
  39230. canvas = tmpCanvas.canvas;
  39231. }
  39232. return {
  39233. canvas: canvas,
  39234. offsetX: offsetX - BORDER_SIZE * scaleX,
  39235. offsetY: offsetY - BORDER_SIZE * scaleY,
  39236. scaleX: scaleX,
  39237. scaleY: scaleY
  39238. };
  39239. }
  39240. return createMeshCanvas;
  39241. }();
  39242. ShadingIRs.Mesh = {
  39243. fromIR: function Mesh_fromIR(raw) {
  39244. var coords = raw[2];
  39245. var colors = raw[3];
  39246. var figures = raw[4];
  39247. var bounds = raw[5];
  39248. var matrix = raw[6];
  39249. var background = raw[8];
  39250. return {
  39251. type: 'Pattern',
  39252. getPattern: function Mesh_getPattern(ctx, owner, shadingFill) {
  39253. var scale;
  39254. if (shadingFill) {
  39255. scale = Util.singularValueDecompose2dScale(ctx.mozCurrentTransform);
  39256. } else {
  39257. scale = Util.singularValueDecompose2dScale(owner.baseTransform);
  39258. if (matrix) {
  39259. var matrixScale = Util.singularValueDecompose2dScale(matrix);
  39260. scale = [
  39261. scale[0] * matrixScale[0],
  39262. scale[1] * matrixScale[1]
  39263. ];
  39264. }
  39265. }
  39266. var temporaryPatternCanvas = createMeshCanvas(bounds, scale, coords, colors, figures, shadingFill ? null : background, owner.cachedCanvases);
  39267. if (!shadingFill) {
  39268. ctx.setTransform.apply(ctx, owner.baseTransform);
  39269. if (matrix) {
  39270. ctx.transform.apply(ctx, matrix);
  39271. }
  39272. }
  39273. ctx.translate(temporaryPatternCanvas.offsetX, temporaryPatternCanvas.offsetY);
  39274. ctx.scale(temporaryPatternCanvas.scaleX, temporaryPatternCanvas.scaleY);
  39275. return ctx.createPattern(temporaryPatternCanvas.canvas, 'no-repeat');
  39276. }
  39277. };
  39278. }
  39279. };
  39280. ShadingIRs.Dummy = {
  39281. fromIR: function Dummy_fromIR() {
  39282. return {
  39283. type: 'Pattern',
  39284. getPattern: function Dummy_fromIR_getPattern() {
  39285. return 'hotpink';
  39286. }
  39287. };
  39288. }
  39289. };
  39290. function getShadingPatternFromIR(raw) {
  39291. var shadingIR = ShadingIRs[raw[0]];
  39292. if (!shadingIR) {
  39293. error('Unknown IR type: ' + raw[0]);
  39294. }
  39295. return shadingIR.fromIR(raw);
  39296. }
  39297. var TilingPattern = function TilingPatternClosure() {
  39298. var PaintType = {
  39299. COLORED: 1,
  39300. UNCOLORED: 2
  39301. };
  39302. var MAX_PATTERN_SIZE = 3000;
  39303. function TilingPattern(IR, color, ctx, canvasGraphicsFactory, baseTransform) {
  39304. this.operatorList = IR[2];
  39305. this.matrix = IR[3] || [
  39306. 1,
  39307. 0,
  39308. 0,
  39309. 1,
  39310. 0,
  39311. 0
  39312. ];
  39313. this.bbox = IR[4];
  39314. this.xstep = IR[5];
  39315. this.ystep = IR[6];
  39316. this.paintType = IR[7];
  39317. this.tilingType = IR[8];
  39318. this.color = color;
  39319. this.canvasGraphicsFactory = canvasGraphicsFactory;
  39320. this.baseTransform = baseTransform;
  39321. this.type = 'Pattern';
  39322. this.ctx = ctx;
  39323. }
  39324. TilingPattern.prototype = {
  39325. createPatternCanvas: function TilinPattern_createPatternCanvas(owner) {
  39326. var operatorList = this.operatorList;
  39327. var bbox = this.bbox;
  39328. var xstep = this.xstep;
  39329. var ystep = this.ystep;
  39330. var paintType = this.paintType;
  39331. var tilingType = this.tilingType;
  39332. var color = this.color;
  39333. var canvasGraphicsFactory = this.canvasGraphicsFactory;
  39334. info('TilingType: ' + tilingType);
  39335. var x0 = bbox[0], y0 = bbox[1], x1 = bbox[2], y1 = bbox[3];
  39336. var topLeft = [
  39337. x0,
  39338. y0
  39339. ];
  39340. var botRight = [
  39341. x0 + xstep,
  39342. y0 + ystep
  39343. ];
  39344. var width = botRight[0] - topLeft[0];
  39345. var height = botRight[1] - topLeft[1];
  39346. var matrixScale = Util.singularValueDecompose2dScale(this.matrix);
  39347. var curMatrixScale = Util.singularValueDecompose2dScale(this.baseTransform);
  39348. var combinedScale = [
  39349. matrixScale[0] * curMatrixScale[0],
  39350. matrixScale[1] * curMatrixScale[1]
  39351. ];
  39352. width = Math.min(Math.ceil(Math.abs(width * combinedScale[0])), MAX_PATTERN_SIZE);
  39353. height = Math.min(Math.ceil(Math.abs(height * combinedScale[1])), MAX_PATTERN_SIZE);
  39354. var tmpCanvas = owner.cachedCanvases.getCanvas('pattern', width, height, true);
  39355. var tmpCtx = tmpCanvas.context;
  39356. var graphics = canvasGraphicsFactory.createCanvasGraphics(tmpCtx);
  39357. graphics.groupLevel = owner.groupLevel;
  39358. this.setFillAndStrokeStyleToContext(tmpCtx, paintType, color);
  39359. this.setScale(width, height, xstep, ystep);
  39360. this.transformToScale(graphics);
  39361. var tmpTranslate = [
  39362. 1,
  39363. 0,
  39364. 0,
  39365. 1,
  39366. -topLeft[0],
  39367. -topLeft[1]
  39368. ];
  39369. graphics.transform.apply(graphics, tmpTranslate);
  39370. this.clipBbox(graphics, bbox, x0, y0, x1, y1);
  39371. graphics.executeOperatorList(operatorList);
  39372. return tmpCanvas.canvas;
  39373. },
  39374. setScale: function TilingPattern_setScale(width, height, xstep, ystep) {
  39375. this.scale = [
  39376. width / xstep,
  39377. height / ystep
  39378. ];
  39379. },
  39380. transformToScale: function TilingPattern_transformToScale(graphics) {
  39381. var scale = this.scale;
  39382. var tmpScale = [
  39383. scale[0],
  39384. 0,
  39385. 0,
  39386. scale[1],
  39387. 0,
  39388. 0
  39389. ];
  39390. graphics.transform.apply(graphics, tmpScale);
  39391. },
  39392. scaleToContext: function TilingPattern_scaleToContext() {
  39393. var scale = this.scale;
  39394. this.ctx.scale(1 / scale[0], 1 / scale[1]);
  39395. },
  39396. clipBbox: function clipBbox(graphics, bbox, x0, y0, x1, y1) {
  39397. if (bbox && isArray(bbox) && bbox.length === 4) {
  39398. var bboxWidth = x1 - x0;
  39399. var bboxHeight = y1 - y0;
  39400. graphics.ctx.rect(x0, y0, bboxWidth, bboxHeight);
  39401. graphics.clip();
  39402. graphics.endPath();
  39403. }
  39404. },
  39405. setFillAndStrokeStyleToContext: function setFillAndStrokeStyleToContext(context, paintType, color) {
  39406. switch (paintType) {
  39407. case PaintType.COLORED:
  39408. var ctx = this.ctx;
  39409. context.fillStyle = ctx.fillStyle;
  39410. context.strokeStyle = ctx.strokeStyle;
  39411. break;
  39412. case PaintType.UNCOLORED:
  39413. var cssColor = Util.makeCssRgb(color[0], color[1], color[2]);
  39414. context.fillStyle = cssColor;
  39415. context.strokeStyle = cssColor;
  39416. break;
  39417. default:
  39418. error('Unsupported paint type: ' + paintType);
  39419. }
  39420. },
  39421. getPattern: function TilingPattern_getPattern(ctx, owner) {
  39422. var temporaryPatternCanvas = this.createPatternCanvas(owner);
  39423. ctx = this.ctx;
  39424. ctx.setTransform.apply(ctx, this.baseTransform);
  39425. ctx.transform.apply(ctx, this.matrix);
  39426. this.scaleToContext();
  39427. return ctx.createPattern(temporaryPatternCanvas, 'repeat');
  39428. }
  39429. };
  39430. return TilingPattern;
  39431. }();
  39432. exports.getShadingPatternFromIR = getShadingPatternFromIR;
  39433. exports.TilingPattern = TilingPattern;
  39434. }));
  39435. (function (root, factory) {
  39436. factory(root.pdfjsCoreCMap = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreParser);
  39437. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser) {
  39438. var Util = sharedUtil.Util;
  39439. var assert = sharedUtil.assert;
  39440. var warn = sharedUtil.warn;
  39441. var error = sharedUtil.error;
  39442. var isInt = sharedUtil.isInt;
  39443. var isString = sharedUtil.isString;
  39444. var MissingDataException = sharedUtil.MissingDataException;
  39445. var isName = corePrimitives.isName;
  39446. var isCmd = corePrimitives.isCmd;
  39447. var isStream = corePrimitives.isStream;
  39448. var StringStream = coreStream.StringStream;
  39449. var Lexer = coreParser.Lexer;
  39450. var isEOF = coreParser.isEOF;
  39451. var BUILT_IN_CMAPS = [
  39452. 'Adobe-GB1-UCS2',
  39453. 'Adobe-CNS1-UCS2',
  39454. 'Adobe-Japan1-UCS2',
  39455. 'Adobe-Korea1-UCS2',
  39456. '78-EUC-H',
  39457. '78-EUC-V',
  39458. '78-H',
  39459. '78-RKSJ-H',
  39460. '78-RKSJ-V',
  39461. '78-V',
  39462. '78ms-RKSJ-H',
  39463. '78ms-RKSJ-V',
  39464. '83pv-RKSJ-H',
  39465. '90ms-RKSJ-H',
  39466. '90ms-RKSJ-V',
  39467. '90msp-RKSJ-H',
  39468. '90msp-RKSJ-V',
  39469. '90pv-RKSJ-H',
  39470. '90pv-RKSJ-V',
  39471. 'Add-H',
  39472. 'Add-RKSJ-H',
  39473. 'Add-RKSJ-V',
  39474. 'Add-V',
  39475. 'Adobe-CNS1-0',
  39476. 'Adobe-CNS1-1',
  39477. 'Adobe-CNS1-2',
  39478. 'Adobe-CNS1-3',
  39479. 'Adobe-CNS1-4',
  39480. 'Adobe-CNS1-5',
  39481. 'Adobe-CNS1-6',
  39482. 'Adobe-GB1-0',
  39483. 'Adobe-GB1-1',
  39484. 'Adobe-GB1-2',
  39485. 'Adobe-GB1-3',
  39486. 'Adobe-GB1-4',
  39487. 'Adobe-GB1-5',
  39488. 'Adobe-Japan1-0',
  39489. 'Adobe-Japan1-1',
  39490. 'Adobe-Japan1-2',
  39491. 'Adobe-Japan1-3',
  39492. 'Adobe-Japan1-4',
  39493. 'Adobe-Japan1-5',
  39494. 'Adobe-Japan1-6',
  39495. 'Adobe-Korea1-0',
  39496. 'Adobe-Korea1-1',
  39497. 'Adobe-Korea1-2',
  39498. 'B5-H',
  39499. 'B5-V',
  39500. 'B5pc-H',
  39501. 'B5pc-V',
  39502. 'CNS-EUC-H',
  39503. 'CNS-EUC-V',
  39504. 'CNS1-H',
  39505. 'CNS1-V',
  39506. 'CNS2-H',
  39507. 'CNS2-V',
  39508. 'ETHK-B5-H',
  39509. 'ETHK-B5-V',
  39510. 'ETen-B5-H',
  39511. 'ETen-B5-V',
  39512. 'ETenms-B5-H',
  39513. 'ETenms-B5-V',
  39514. 'EUC-H',
  39515. 'EUC-V',
  39516. 'Ext-H',
  39517. 'Ext-RKSJ-H',
  39518. 'Ext-RKSJ-V',
  39519. 'Ext-V',
  39520. 'GB-EUC-H',
  39521. 'GB-EUC-V',
  39522. 'GB-H',
  39523. 'GB-V',
  39524. 'GBK-EUC-H',
  39525. 'GBK-EUC-V',
  39526. 'GBK2K-H',
  39527. 'GBK2K-V',
  39528. 'GBKp-EUC-H',
  39529. 'GBKp-EUC-V',
  39530. 'GBT-EUC-H',
  39531. 'GBT-EUC-V',
  39532. 'GBT-H',
  39533. 'GBT-V',
  39534. 'GBTpc-EUC-H',
  39535. 'GBTpc-EUC-V',
  39536. 'GBpc-EUC-H',
  39537. 'GBpc-EUC-V',
  39538. 'H',
  39539. 'HKdla-B5-H',
  39540. 'HKdla-B5-V',
  39541. 'HKdlb-B5-H',
  39542. 'HKdlb-B5-V',
  39543. 'HKgccs-B5-H',
  39544. 'HKgccs-B5-V',
  39545. 'HKm314-B5-H',
  39546. 'HKm314-B5-V',
  39547. 'HKm471-B5-H',
  39548. 'HKm471-B5-V',
  39549. 'HKscs-B5-H',
  39550. 'HKscs-B5-V',
  39551. 'Hankaku',
  39552. 'Hiragana',
  39553. 'KSC-EUC-H',
  39554. 'KSC-EUC-V',
  39555. 'KSC-H',
  39556. 'KSC-Johab-H',
  39557. 'KSC-Johab-V',
  39558. 'KSC-V',
  39559. 'KSCms-UHC-H',
  39560. 'KSCms-UHC-HW-H',
  39561. 'KSCms-UHC-HW-V',
  39562. 'KSCms-UHC-V',
  39563. 'KSCpc-EUC-H',
  39564. 'KSCpc-EUC-V',
  39565. 'Katakana',
  39566. 'NWP-H',
  39567. 'NWP-V',
  39568. 'RKSJ-H',
  39569. 'RKSJ-V',
  39570. 'Roman',
  39571. 'UniCNS-UCS2-H',
  39572. 'UniCNS-UCS2-V',
  39573. 'UniCNS-UTF16-H',
  39574. 'UniCNS-UTF16-V',
  39575. 'UniCNS-UTF32-H',
  39576. 'UniCNS-UTF32-V',
  39577. 'UniCNS-UTF8-H',
  39578. 'UniCNS-UTF8-V',
  39579. 'UniGB-UCS2-H',
  39580. 'UniGB-UCS2-V',
  39581. 'UniGB-UTF16-H',
  39582. 'UniGB-UTF16-V',
  39583. 'UniGB-UTF32-H',
  39584. 'UniGB-UTF32-V',
  39585. 'UniGB-UTF8-H',
  39586. 'UniGB-UTF8-V',
  39587. 'UniJIS-UCS2-H',
  39588. 'UniJIS-UCS2-HW-H',
  39589. 'UniJIS-UCS2-HW-V',
  39590. 'UniJIS-UCS2-V',
  39591. 'UniJIS-UTF16-H',
  39592. 'UniJIS-UTF16-V',
  39593. 'UniJIS-UTF32-H',
  39594. 'UniJIS-UTF32-V',
  39595. 'UniJIS-UTF8-H',
  39596. 'UniJIS-UTF8-V',
  39597. 'UniJIS2004-UTF16-H',
  39598. 'UniJIS2004-UTF16-V',
  39599. 'UniJIS2004-UTF32-H',
  39600. 'UniJIS2004-UTF32-V',
  39601. 'UniJIS2004-UTF8-H',
  39602. 'UniJIS2004-UTF8-V',
  39603. 'UniJISPro-UCS2-HW-V',
  39604. 'UniJISPro-UCS2-V',
  39605. 'UniJISPro-UTF8-V',
  39606. 'UniJISX0213-UTF32-H',
  39607. 'UniJISX0213-UTF32-V',
  39608. 'UniJISX02132004-UTF32-H',
  39609. 'UniJISX02132004-UTF32-V',
  39610. 'UniKS-UCS2-H',
  39611. 'UniKS-UCS2-V',
  39612. 'UniKS-UTF16-H',
  39613. 'UniKS-UTF16-V',
  39614. 'UniKS-UTF32-H',
  39615. 'UniKS-UTF32-V',
  39616. 'UniKS-UTF8-H',
  39617. 'UniKS-UTF8-V',
  39618. 'V',
  39619. 'WP-Symbol'
  39620. ];
  39621. var CMap = function CMapClosure() {
  39622. function CMap(builtInCMap) {
  39623. this.codespaceRanges = [
  39624. [],
  39625. [],
  39626. [],
  39627. []
  39628. ];
  39629. this.numCodespaceRanges = 0;
  39630. this._map = [];
  39631. this.name = '';
  39632. this.vertical = false;
  39633. this.useCMap = null;
  39634. this.builtInCMap = builtInCMap;
  39635. }
  39636. CMap.prototype = {
  39637. addCodespaceRange: function (n, low, high) {
  39638. this.codespaceRanges[n - 1].push(low, high);
  39639. this.numCodespaceRanges++;
  39640. },
  39641. mapCidRange: function (low, high, dstLow) {
  39642. while (low <= high) {
  39643. this._map[low++] = dstLow++;
  39644. }
  39645. },
  39646. mapBfRange: function (low, high, dstLow) {
  39647. var lastByte = dstLow.length - 1;
  39648. while (low <= high) {
  39649. this._map[low++] = dstLow;
  39650. dstLow = dstLow.substr(0, lastByte) + String.fromCharCode(dstLow.charCodeAt(lastByte) + 1);
  39651. }
  39652. },
  39653. mapBfRangeToArray: function (low, high, array) {
  39654. var i = 0, ii = array.length;
  39655. while (low <= high && i < ii) {
  39656. this._map[low] = array[i++];
  39657. ++low;
  39658. }
  39659. },
  39660. mapOne: function (src, dst) {
  39661. this._map[src] = dst;
  39662. },
  39663. lookup: function (code) {
  39664. return this._map[code];
  39665. },
  39666. contains: function (code) {
  39667. return this._map[code] !== undefined;
  39668. },
  39669. forEach: function (callback) {
  39670. var map = this._map;
  39671. var length = map.length;
  39672. var i;
  39673. if (length <= 0x10000) {
  39674. for (i = 0; i < length; i++) {
  39675. if (map[i] !== undefined) {
  39676. callback(i, map[i]);
  39677. }
  39678. }
  39679. } else {
  39680. for (i in this._map) {
  39681. callback(i, map[i]);
  39682. }
  39683. }
  39684. },
  39685. charCodeOf: function (value) {
  39686. return this._map.indexOf(value);
  39687. },
  39688. getMap: function () {
  39689. return this._map;
  39690. },
  39691. readCharCode: function (str, offset, out) {
  39692. var c = 0;
  39693. var codespaceRanges = this.codespaceRanges;
  39694. var codespaceRangesLen = this.codespaceRanges.length;
  39695. for (var n = 0; n < codespaceRangesLen; n++) {
  39696. c = (c << 8 | str.charCodeAt(offset + n)) >>> 0;
  39697. var codespaceRange = codespaceRanges[n];
  39698. for (var k = 0, kk = codespaceRange.length; k < kk;) {
  39699. var low = codespaceRange[k++];
  39700. var high = codespaceRange[k++];
  39701. if (c >= low && c <= high) {
  39702. out.charcode = c;
  39703. out.length = n + 1;
  39704. return;
  39705. }
  39706. }
  39707. }
  39708. out.charcode = 0;
  39709. out.length = 1;
  39710. },
  39711. get length() {
  39712. return this._map.length;
  39713. },
  39714. get isIdentityCMap() {
  39715. if (!(this.name === 'Identity-H' || this.name === 'Identity-V')) {
  39716. return false;
  39717. }
  39718. if (this._map.length !== 0x10000) {
  39719. return false;
  39720. }
  39721. for (var i = 0; i < 0x10000; i++) {
  39722. if (this._map[i] !== i) {
  39723. return false;
  39724. }
  39725. }
  39726. return true;
  39727. }
  39728. };
  39729. return CMap;
  39730. }();
  39731. var IdentityCMap = function IdentityCMapClosure() {
  39732. function IdentityCMap(vertical, n) {
  39733. CMap.call(this);
  39734. this.vertical = vertical;
  39735. this.addCodespaceRange(n, 0, 0xffff);
  39736. }
  39737. Util.inherit(IdentityCMap, CMap, {});
  39738. IdentityCMap.prototype = {
  39739. addCodespaceRange: CMap.prototype.addCodespaceRange,
  39740. mapCidRange: function (low, high, dstLow) {
  39741. error('should not call mapCidRange');
  39742. },
  39743. mapBfRange: function (low, high, dstLow) {
  39744. error('should not call mapBfRange');
  39745. },
  39746. mapBfRangeToArray: function (low, high, array) {
  39747. error('should not call mapBfRangeToArray');
  39748. },
  39749. mapOne: function (src, dst) {
  39750. error('should not call mapCidOne');
  39751. },
  39752. lookup: function (code) {
  39753. return isInt(code) && code <= 0xffff ? code : undefined;
  39754. },
  39755. contains: function (code) {
  39756. return isInt(code) && code <= 0xffff;
  39757. },
  39758. forEach: function (callback) {
  39759. for (var i = 0; i <= 0xffff; i++) {
  39760. callback(i, i);
  39761. }
  39762. },
  39763. charCodeOf: function (value) {
  39764. return isInt(value) && value <= 0xffff ? value : -1;
  39765. },
  39766. getMap: function () {
  39767. var map = new Array(0x10000);
  39768. for (var i = 0; i <= 0xffff; i++) {
  39769. map[i] = i;
  39770. }
  39771. return map;
  39772. },
  39773. readCharCode: CMap.prototype.readCharCode,
  39774. get length() {
  39775. return 0x10000;
  39776. },
  39777. get isIdentityCMap() {
  39778. error('should not access .isIdentityCMap');
  39779. }
  39780. };
  39781. return IdentityCMap;
  39782. }();
  39783. var BinaryCMapReader = function BinaryCMapReaderClosure() {
  39784. function fetchBinaryData(url) {
  39785. return new Promise(function (resolve, reject) {
  39786. var request = new XMLHttpRequest();
  39787. request.open('GET', url, true);
  39788. request.responseType = 'arraybuffer';
  39789. request.onreadystatechange = function () {
  39790. if (request.readyState === XMLHttpRequest.DONE) {
  39791. if (!request.response || request.status !== 200 && request.status !== 0) {
  39792. reject(new Error('Unable to get binary cMap at: ' + url));
  39793. } else {
  39794. resolve(new Uint8Array(request.response));
  39795. }
  39796. }
  39797. };
  39798. request.send(null);
  39799. });
  39800. }
  39801. function hexToInt(a, size) {
  39802. var n = 0;
  39803. for (var i = 0; i <= size; i++) {
  39804. n = n << 8 | a[i];
  39805. }
  39806. return n >>> 0;
  39807. }
  39808. function hexToStr(a, size) {
  39809. if (size === 1) {
  39810. return String.fromCharCode(a[0], a[1]);
  39811. }
  39812. if (size === 3) {
  39813. return String.fromCharCode(a[0], a[1], a[2], a[3]);
  39814. }
  39815. return String.fromCharCode.apply(null, a.subarray(0, size + 1));
  39816. }
  39817. function addHex(a, b, size) {
  39818. var c = 0;
  39819. for (var i = size; i >= 0; i--) {
  39820. c += a[i] + b[i];
  39821. a[i] = c & 255;
  39822. c >>= 8;
  39823. }
  39824. }
  39825. function incHex(a, size) {
  39826. var c = 1;
  39827. for (var i = size; i >= 0 && c > 0; i--) {
  39828. c += a[i];
  39829. a[i] = c & 255;
  39830. c >>= 8;
  39831. }
  39832. }
  39833. var MAX_NUM_SIZE = 16;
  39834. var MAX_ENCODED_NUM_SIZE = 19;
  39835. function BinaryCMapStream(data) {
  39836. this.buffer = data;
  39837. this.pos = 0;
  39838. this.end = data.length;
  39839. this.tmpBuf = new Uint8Array(MAX_ENCODED_NUM_SIZE);
  39840. }
  39841. BinaryCMapStream.prototype = {
  39842. readByte: function () {
  39843. if (this.pos >= this.end) {
  39844. return -1;
  39845. }
  39846. return this.buffer[this.pos++];
  39847. },
  39848. readNumber: function () {
  39849. var n = 0;
  39850. var last;
  39851. do {
  39852. var b = this.readByte();
  39853. if (b < 0) {
  39854. error('unexpected EOF in bcmap');
  39855. }
  39856. last = !(b & 0x80);
  39857. n = n << 7 | b & 0x7F;
  39858. } while (!last);
  39859. return n;
  39860. },
  39861. readSigned: function () {
  39862. var n = this.readNumber();
  39863. return n & 1 ? ~(n >>> 1) : n >>> 1;
  39864. },
  39865. readHex: function (num, size) {
  39866. num.set(this.buffer.subarray(this.pos, this.pos + size + 1));
  39867. this.pos += size + 1;
  39868. },
  39869. readHexNumber: function (num, size) {
  39870. var last;
  39871. var stack = this.tmpBuf, sp = 0;
  39872. do {
  39873. var b = this.readByte();
  39874. if (b < 0) {
  39875. error('unexpected EOF in bcmap');
  39876. }
  39877. last = !(b & 0x80);
  39878. stack[sp++] = b & 0x7F;
  39879. } while (!last);
  39880. var i = size, buffer = 0, bufferSize = 0;
  39881. while (i >= 0) {
  39882. while (bufferSize < 8 && stack.length > 0) {
  39883. buffer = stack[--sp] << bufferSize | buffer;
  39884. bufferSize += 7;
  39885. }
  39886. num[i] = buffer & 255;
  39887. i--;
  39888. buffer >>= 8;
  39889. bufferSize -= 8;
  39890. }
  39891. },
  39892. readHexSigned: function (num, size) {
  39893. this.readHexNumber(num, size);
  39894. var sign = num[size] & 1 ? 255 : 0;
  39895. var c = 0;
  39896. for (var i = 0; i <= size; i++) {
  39897. c = (c & 1) << 8 | num[i];
  39898. num[i] = c >> 1 ^ sign;
  39899. }
  39900. },
  39901. readString: function () {
  39902. var len = this.readNumber();
  39903. var s = '';
  39904. for (var i = 0; i < len; i++) {
  39905. s += String.fromCharCode(this.readNumber());
  39906. }
  39907. return s;
  39908. }
  39909. };
  39910. function processBinaryCMap(url, cMap, extend) {
  39911. return fetchBinaryData(url).then(function (data) {
  39912. var stream = new BinaryCMapStream(data);
  39913. var header = stream.readByte();
  39914. cMap.vertical = !!(header & 1);
  39915. var useCMap = null;
  39916. var start = new Uint8Array(MAX_NUM_SIZE);
  39917. var end = new Uint8Array(MAX_NUM_SIZE);
  39918. var char = new Uint8Array(MAX_NUM_SIZE);
  39919. var charCode = new Uint8Array(MAX_NUM_SIZE);
  39920. var tmp = new Uint8Array(MAX_NUM_SIZE);
  39921. var code;
  39922. var b;
  39923. while ((b = stream.readByte()) >= 0) {
  39924. var type = b >> 5;
  39925. if (type === 7) {
  39926. switch (b & 0x1F) {
  39927. case 0:
  39928. stream.readString();
  39929. break;
  39930. case 1:
  39931. useCMap = stream.readString();
  39932. break;
  39933. }
  39934. continue;
  39935. }
  39936. var sequence = !!(b & 0x10);
  39937. var dataSize = b & 15;
  39938. assert(dataSize + 1 <= MAX_NUM_SIZE);
  39939. var ucs2DataSize = 1;
  39940. var subitemsCount = stream.readNumber();
  39941. var i;
  39942. switch (type) {
  39943. case 0:
  39944. stream.readHex(start, dataSize);
  39945. stream.readHexNumber(end, dataSize);
  39946. addHex(end, start, dataSize);
  39947. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  39948. for (i = 1; i < subitemsCount; i++) {
  39949. incHex(end, dataSize);
  39950. stream.readHexNumber(start, dataSize);
  39951. addHex(start, end, dataSize);
  39952. stream.readHexNumber(end, dataSize);
  39953. addHex(end, start, dataSize);
  39954. cMap.addCodespaceRange(dataSize + 1, hexToInt(start, dataSize), hexToInt(end, dataSize));
  39955. }
  39956. break;
  39957. case 1:
  39958. stream.readHex(start, dataSize);
  39959. stream.readHexNumber(end, dataSize);
  39960. addHex(end, start, dataSize);
  39961. code = stream.readNumber();
  39962. for (i = 1; i < subitemsCount; i++) {
  39963. incHex(end, dataSize);
  39964. stream.readHexNumber(start, dataSize);
  39965. addHex(start, end, dataSize);
  39966. stream.readHexNumber(end, dataSize);
  39967. addHex(end, start, dataSize);
  39968. code = stream.readNumber();
  39969. }
  39970. break;
  39971. case 2:
  39972. stream.readHex(char, dataSize);
  39973. code = stream.readNumber();
  39974. cMap.mapOne(hexToInt(char, dataSize), code);
  39975. for (i = 1; i < subitemsCount; i++) {
  39976. incHex(char, dataSize);
  39977. if (!sequence) {
  39978. stream.readHexNumber(tmp, dataSize);
  39979. addHex(char, tmp, dataSize);
  39980. }
  39981. code = stream.readSigned() + (code + 1);
  39982. cMap.mapOne(hexToInt(char, dataSize), code);
  39983. }
  39984. break;
  39985. case 3:
  39986. stream.readHex(start, dataSize);
  39987. stream.readHexNumber(end, dataSize);
  39988. addHex(end, start, dataSize);
  39989. code = stream.readNumber();
  39990. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  39991. for (i = 1; i < subitemsCount; i++) {
  39992. incHex(end, dataSize);
  39993. if (!sequence) {
  39994. stream.readHexNumber(start, dataSize);
  39995. addHex(start, end, dataSize);
  39996. } else {
  39997. start.set(end);
  39998. }
  39999. stream.readHexNumber(end, dataSize);
  40000. addHex(end, start, dataSize);
  40001. code = stream.readNumber();
  40002. cMap.mapCidRange(hexToInt(start, dataSize), hexToInt(end, dataSize), code);
  40003. }
  40004. break;
  40005. case 4:
  40006. stream.readHex(char, ucs2DataSize);
  40007. stream.readHex(charCode, dataSize);
  40008. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40009. for (i = 1; i < subitemsCount; i++) {
  40010. incHex(char, ucs2DataSize);
  40011. if (!sequence) {
  40012. stream.readHexNumber(tmp, ucs2DataSize);
  40013. addHex(char, tmp, ucs2DataSize);
  40014. }
  40015. incHex(charCode, dataSize);
  40016. stream.readHexSigned(tmp, dataSize);
  40017. addHex(charCode, tmp, dataSize);
  40018. cMap.mapOne(hexToInt(char, ucs2DataSize), hexToStr(charCode, dataSize));
  40019. }
  40020. break;
  40021. case 5:
  40022. stream.readHex(start, ucs2DataSize);
  40023. stream.readHexNumber(end, ucs2DataSize);
  40024. addHex(end, start, ucs2DataSize);
  40025. stream.readHex(charCode, dataSize);
  40026. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40027. for (i = 1; i < subitemsCount; i++) {
  40028. incHex(end, ucs2DataSize);
  40029. if (!sequence) {
  40030. stream.readHexNumber(start, ucs2DataSize);
  40031. addHex(start, end, ucs2DataSize);
  40032. } else {
  40033. start.set(end);
  40034. }
  40035. stream.readHexNumber(end, ucs2DataSize);
  40036. addHex(end, start, ucs2DataSize);
  40037. stream.readHex(charCode, dataSize);
  40038. cMap.mapBfRange(hexToInt(start, ucs2DataSize), hexToInt(end, ucs2DataSize), hexToStr(charCode, dataSize));
  40039. }
  40040. break;
  40041. default:
  40042. error('Unknown type: ' + type);
  40043. break;
  40044. }
  40045. }
  40046. if (useCMap) {
  40047. return extend(useCMap);
  40048. }
  40049. return cMap;
  40050. });
  40051. }
  40052. function BinaryCMapReader() {
  40053. }
  40054. BinaryCMapReader.prototype = { read: processBinaryCMap };
  40055. return BinaryCMapReader;
  40056. }();
  40057. var CMapFactory = function CMapFactoryClosure() {
  40058. function strToInt(str) {
  40059. var a = 0;
  40060. for (var i = 0; i < str.length; i++) {
  40061. a = a << 8 | str.charCodeAt(i);
  40062. }
  40063. return a >>> 0;
  40064. }
  40065. function expectString(obj) {
  40066. if (!isString(obj)) {
  40067. error('Malformed CMap: expected string.');
  40068. }
  40069. }
  40070. function expectInt(obj) {
  40071. if (!isInt(obj)) {
  40072. error('Malformed CMap: expected int.');
  40073. }
  40074. }
  40075. function parseBfChar(cMap, lexer) {
  40076. while (true) {
  40077. var obj = lexer.getObj();
  40078. if (isEOF(obj)) {
  40079. break;
  40080. }
  40081. if (isCmd(obj, 'endbfchar')) {
  40082. return;
  40083. }
  40084. expectString(obj);
  40085. var src = strToInt(obj);
  40086. obj = lexer.getObj();
  40087. expectString(obj);
  40088. var dst = obj;
  40089. cMap.mapOne(src, dst);
  40090. }
  40091. }
  40092. function parseBfRange(cMap, lexer) {
  40093. while (true) {
  40094. var obj = lexer.getObj();
  40095. if (isEOF(obj)) {
  40096. break;
  40097. }
  40098. if (isCmd(obj, 'endbfrange')) {
  40099. return;
  40100. }
  40101. expectString(obj);
  40102. var low = strToInt(obj);
  40103. obj = lexer.getObj();
  40104. expectString(obj);
  40105. var high = strToInt(obj);
  40106. obj = lexer.getObj();
  40107. if (isInt(obj) || isString(obj)) {
  40108. var dstLow = isInt(obj) ? String.fromCharCode(obj) : obj;
  40109. cMap.mapBfRange(low, high, dstLow);
  40110. } else if (isCmd(obj, '[')) {
  40111. obj = lexer.getObj();
  40112. var array = [];
  40113. while (!isCmd(obj, ']') && !isEOF(obj)) {
  40114. array.push(obj);
  40115. obj = lexer.getObj();
  40116. }
  40117. cMap.mapBfRangeToArray(low, high, array);
  40118. } else {
  40119. break;
  40120. }
  40121. }
  40122. error('Invalid bf range.');
  40123. }
  40124. function parseCidChar(cMap, lexer) {
  40125. while (true) {
  40126. var obj = lexer.getObj();
  40127. if (isEOF(obj)) {
  40128. break;
  40129. }
  40130. if (isCmd(obj, 'endcidchar')) {
  40131. return;
  40132. }
  40133. expectString(obj);
  40134. var src = strToInt(obj);
  40135. obj = lexer.getObj();
  40136. expectInt(obj);
  40137. var dst = obj;
  40138. cMap.mapOne(src, dst);
  40139. }
  40140. }
  40141. function parseCidRange(cMap, lexer) {
  40142. while (true) {
  40143. var obj = lexer.getObj();
  40144. if (isEOF(obj)) {
  40145. break;
  40146. }
  40147. if (isCmd(obj, 'endcidrange')) {
  40148. return;
  40149. }
  40150. expectString(obj);
  40151. var low = strToInt(obj);
  40152. obj = lexer.getObj();
  40153. expectString(obj);
  40154. var high = strToInt(obj);
  40155. obj = lexer.getObj();
  40156. expectInt(obj);
  40157. var dstLow = obj;
  40158. cMap.mapCidRange(low, high, dstLow);
  40159. }
  40160. }
  40161. function parseCodespaceRange(cMap, lexer) {
  40162. while (true) {
  40163. var obj = lexer.getObj();
  40164. if (isEOF(obj)) {
  40165. break;
  40166. }
  40167. if (isCmd(obj, 'endcodespacerange')) {
  40168. return;
  40169. }
  40170. if (!isString(obj)) {
  40171. break;
  40172. }
  40173. var low = strToInt(obj);
  40174. obj = lexer.getObj();
  40175. if (!isString(obj)) {
  40176. break;
  40177. }
  40178. var high = strToInt(obj);
  40179. cMap.addCodespaceRange(obj.length, low, high);
  40180. }
  40181. error('Invalid codespace range.');
  40182. }
  40183. function parseWMode(cMap, lexer) {
  40184. var obj = lexer.getObj();
  40185. if (isInt(obj)) {
  40186. cMap.vertical = !!obj;
  40187. }
  40188. }
  40189. function parseCMapName(cMap, lexer) {
  40190. var obj = lexer.getObj();
  40191. if (isName(obj) && isString(obj.name)) {
  40192. cMap.name = obj.name;
  40193. }
  40194. }
  40195. function parseCMap(cMap, lexer, builtInCMapParams, useCMap) {
  40196. var previous;
  40197. var embededUseCMap;
  40198. objLoop:
  40199. while (true) {
  40200. try {
  40201. var obj = lexer.getObj();
  40202. if (isEOF(obj)) {
  40203. break;
  40204. } else if (isName(obj)) {
  40205. if (obj.name === 'WMode') {
  40206. parseWMode(cMap, lexer);
  40207. } else if (obj.name === 'CMapName') {
  40208. parseCMapName(cMap, lexer);
  40209. }
  40210. previous = obj;
  40211. } else if (isCmd(obj)) {
  40212. switch (obj.cmd) {
  40213. case 'endcmap':
  40214. break objLoop;
  40215. case 'usecmap':
  40216. if (isName(previous)) {
  40217. embededUseCMap = previous.name;
  40218. }
  40219. break;
  40220. case 'begincodespacerange':
  40221. parseCodespaceRange(cMap, lexer);
  40222. break;
  40223. case 'beginbfchar':
  40224. parseBfChar(cMap, lexer);
  40225. break;
  40226. case 'begincidchar':
  40227. parseCidChar(cMap, lexer);
  40228. break;
  40229. case 'beginbfrange':
  40230. parseBfRange(cMap, lexer);
  40231. break;
  40232. case 'begincidrange':
  40233. parseCidRange(cMap, lexer);
  40234. break;
  40235. }
  40236. }
  40237. } catch (ex) {
  40238. if (ex instanceof MissingDataException) {
  40239. throw ex;
  40240. }
  40241. warn('Invalid cMap data: ' + ex);
  40242. continue;
  40243. }
  40244. }
  40245. if (!useCMap && embededUseCMap) {
  40246. useCMap = embededUseCMap;
  40247. }
  40248. if (useCMap) {
  40249. return extendCMap(cMap, builtInCMapParams, useCMap);
  40250. }
  40251. return Promise.resolve(cMap);
  40252. }
  40253. function extendCMap(cMap, builtInCMapParams, useCMap) {
  40254. return createBuiltInCMap(useCMap, builtInCMapParams).then(function (newCMap) {
  40255. cMap.useCMap = newCMap;
  40256. if (cMap.numCodespaceRanges === 0) {
  40257. var useCodespaceRanges = cMap.useCMap.codespaceRanges;
  40258. for (var i = 0; i < useCodespaceRanges.length; i++) {
  40259. cMap.codespaceRanges[i] = useCodespaceRanges[i].slice();
  40260. }
  40261. cMap.numCodespaceRanges = cMap.useCMap.numCodespaceRanges;
  40262. }
  40263. cMap.useCMap.forEach(function (key, value) {
  40264. if (!cMap.contains(key)) {
  40265. cMap.mapOne(key, cMap.useCMap.lookup(key));
  40266. }
  40267. });
  40268. return cMap;
  40269. });
  40270. }
  40271. function parseBinaryCMap(name, builtInCMapParams) {
  40272. var url = builtInCMapParams.url + name + '.bcmap';
  40273. var cMap = new CMap(true);
  40274. return new BinaryCMapReader().read(url, cMap, function (useCMap) {
  40275. return extendCMap(cMap, builtInCMapParams, useCMap);
  40276. });
  40277. }
  40278. function createBuiltInCMap(name, builtInCMapParams) {
  40279. if (name === 'Identity-H') {
  40280. return Promise.resolve(new IdentityCMap(false, 2));
  40281. } else if (name === 'Identity-V') {
  40282. return Promise.resolve(new IdentityCMap(true, 2));
  40283. }
  40284. if (BUILT_IN_CMAPS.indexOf(name) === -1) {
  40285. return Promise.reject(new Error('Unknown cMap name: ' + name));
  40286. }
  40287. assert(builtInCMapParams, 'built-in cMap parameters are not provided');
  40288. if (builtInCMapParams.packed) {
  40289. return parseBinaryCMap(name, builtInCMapParams);
  40290. }
  40291. return new Promise(function (resolve, reject) {
  40292. var url = builtInCMapParams.url + name;
  40293. var request = new XMLHttpRequest();
  40294. request.onreadystatechange = function () {
  40295. if (request.readyState === XMLHttpRequest.DONE) {
  40296. if (request.status === 200 || request.status === 0) {
  40297. var cMap = new CMap(true);
  40298. var lexer = new Lexer(new StringStream(request.responseText));
  40299. parseCMap(cMap, lexer, builtInCMapParams, null).then(function (parsedCMap) {
  40300. resolve(parsedCMap);
  40301. });
  40302. } else {
  40303. reject(new Error('Unable to get cMap at: ' + url));
  40304. }
  40305. }
  40306. };
  40307. request.open('GET', url, true);
  40308. request.send(null);
  40309. });
  40310. }
  40311. return {
  40312. create: function (encoding, builtInCMapParams, useCMap) {
  40313. if (isName(encoding)) {
  40314. return createBuiltInCMap(encoding.name, builtInCMapParams);
  40315. } else if (isStream(encoding)) {
  40316. var cMap = new CMap();
  40317. var lexer = new Lexer(encoding);
  40318. return parseCMap(cMap, lexer, builtInCMapParams, useCMap).then(function (parsedCMap) {
  40319. if (parsedCMap.isIdentityCMap) {
  40320. return createBuiltInCMap(parsedCMap.name, builtInCMapParams);
  40321. }
  40322. return parsedCMap;
  40323. });
  40324. }
  40325. return Promise.reject(new Error('Encoding required.'));
  40326. }
  40327. };
  40328. }();
  40329. exports.CMap = CMap;
  40330. exports.CMapFactory = CMapFactory;
  40331. exports.IdentityCMap = IdentityCMap;
  40332. }));
  40333. (function (root, factory) {
  40334. factory(root.pdfjsCoreFonts = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreGlyphList, root.pdfjsCoreFontRenderer, root.pdfjsCoreEncodings, root.pdfjsCoreStandardFonts, root.pdfjsCoreUnicode, root.pdfjsCoreType1Parser, root.pdfjsCoreCFFParser);
  40335. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreGlyphList, coreFontRenderer, coreEncodings, coreStandardFonts, coreUnicode, coreType1Parser, coreCFFParser) {
  40336. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  40337. var FontType = sharedUtil.FontType;
  40338. var assert = sharedUtil.assert;
  40339. var bytesToString = sharedUtil.bytesToString;
  40340. var error = sharedUtil.error;
  40341. var info = sharedUtil.info;
  40342. var isArray = sharedUtil.isArray;
  40343. var isInt = sharedUtil.isInt;
  40344. var isNum = sharedUtil.isNum;
  40345. var readUint32 = sharedUtil.readUint32;
  40346. var shadow = sharedUtil.shadow;
  40347. var string32 = sharedUtil.string32;
  40348. var warn = sharedUtil.warn;
  40349. var MissingDataException = sharedUtil.MissingDataException;
  40350. var isSpace = sharedUtil.isSpace;
  40351. var Stream = coreStream.Stream;
  40352. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  40353. var getDingbatsGlyphsUnicode = coreGlyphList.getDingbatsGlyphsUnicode;
  40354. var FontRendererFactory = coreFontRenderer.FontRendererFactory;
  40355. var StandardEncoding = coreEncodings.StandardEncoding;
  40356. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  40357. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  40358. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  40359. var getEncoding = coreEncodings.getEncoding;
  40360. var getStdFontMap = coreStandardFonts.getStdFontMap;
  40361. var getNonStdFontMap = coreStandardFonts.getNonStdFontMap;
  40362. var getGlyphMapForStandardFonts = coreStandardFonts.getGlyphMapForStandardFonts;
  40363. var getSupplementalGlyphMapForArialBlack = coreStandardFonts.getSupplementalGlyphMapForArialBlack;
  40364. var getUnicodeRangeFor = coreUnicode.getUnicodeRangeFor;
  40365. var mapSpecialUnicodeValues = coreUnicode.mapSpecialUnicodeValues;
  40366. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  40367. var Type1Parser = coreType1Parser.Type1Parser;
  40368. var CFFStandardStrings = coreCFFParser.CFFStandardStrings;
  40369. var CFFParser = coreCFFParser.CFFParser;
  40370. var CFFCompiler = coreCFFParser.CFFCompiler;
  40371. var CFF = coreCFFParser.CFF;
  40372. var CFFHeader = coreCFFParser.CFFHeader;
  40373. var CFFTopDict = coreCFFParser.CFFTopDict;
  40374. var CFFPrivateDict = coreCFFParser.CFFPrivateDict;
  40375. var CFFStrings = coreCFFParser.CFFStrings;
  40376. var CFFIndex = coreCFFParser.CFFIndex;
  40377. var CFFCharset = coreCFFParser.CFFCharset;
  40378. var PRIVATE_USE_OFFSET_START = 0xE000;
  40379. var PRIVATE_USE_OFFSET_END = 0xF8FF;
  40380. var SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = false;
  40381. var PDF_GLYPH_SPACE_UNITS = 1000;
  40382. var SEAC_ANALYSIS_ENABLED = false;
  40383. var FontFlags = {
  40384. FixedPitch: 1,
  40385. Serif: 2,
  40386. Symbolic: 4,
  40387. Script: 8,
  40388. Nonsymbolic: 32,
  40389. Italic: 64,
  40390. AllCap: 65536,
  40391. SmallCap: 131072,
  40392. ForceBold: 262144
  40393. };
  40394. var MacStandardGlyphOrdering = [
  40395. '.notdef',
  40396. '.null',
  40397. 'nonmarkingreturn',
  40398. 'space',
  40399. 'exclam',
  40400. 'quotedbl',
  40401. 'numbersign',
  40402. 'dollar',
  40403. 'percent',
  40404. 'ampersand',
  40405. 'quotesingle',
  40406. 'parenleft',
  40407. 'parenright',
  40408. 'asterisk',
  40409. 'plus',
  40410. 'comma',
  40411. 'hyphen',
  40412. 'period',
  40413. 'slash',
  40414. 'zero',
  40415. 'one',
  40416. 'two',
  40417. 'three',
  40418. 'four',
  40419. 'five',
  40420. 'six',
  40421. 'seven',
  40422. 'eight',
  40423. 'nine',
  40424. 'colon',
  40425. 'semicolon',
  40426. 'less',
  40427. 'equal',
  40428. 'greater',
  40429. 'question',
  40430. 'at',
  40431. 'A',
  40432. 'B',
  40433. 'C',
  40434. 'D',
  40435. 'E',
  40436. 'F',
  40437. 'G',
  40438. 'H',
  40439. 'I',
  40440. 'J',
  40441. 'K',
  40442. 'L',
  40443. 'M',
  40444. 'N',
  40445. 'O',
  40446. 'P',
  40447. 'Q',
  40448. 'R',
  40449. 'S',
  40450. 'T',
  40451. 'U',
  40452. 'V',
  40453. 'W',
  40454. 'X',
  40455. 'Y',
  40456. 'Z',
  40457. 'bracketleft',
  40458. 'backslash',
  40459. 'bracketright',
  40460. 'asciicircum',
  40461. 'underscore',
  40462. 'grave',
  40463. 'a',
  40464. 'b',
  40465. 'c',
  40466. 'd',
  40467. 'e',
  40468. 'f',
  40469. 'g',
  40470. 'h',
  40471. 'i',
  40472. 'j',
  40473. 'k',
  40474. 'l',
  40475. 'm',
  40476. 'n',
  40477. 'o',
  40478. 'p',
  40479. 'q',
  40480. 'r',
  40481. 's',
  40482. 't',
  40483. 'u',
  40484. 'v',
  40485. 'w',
  40486. 'x',
  40487. 'y',
  40488. 'z',
  40489. 'braceleft',
  40490. 'bar',
  40491. 'braceright',
  40492. 'asciitilde',
  40493. 'Adieresis',
  40494. 'Aring',
  40495. 'Ccedilla',
  40496. 'Eacute',
  40497. 'Ntilde',
  40498. 'Odieresis',
  40499. 'Udieresis',
  40500. 'aacute',
  40501. 'agrave',
  40502. 'acircumflex',
  40503. 'adieresis',
  40504. 'atilde',
  40505. 'aring',
  40506. 'ccedilla',
  40507. 'eacute',
  40508. 'egrave',
  40509. 'ecircumflex',
  40510. 'edieresis',
  40511. 'iacute',
  40512. 'igrave',
  40513. 'icircumflex',
  40514. 'idieresis',
  40515. 'ntilde',
  40516. 'oacute',
  40517. 'ograve',
  40518. 'ocircumflex',
  40519. 'odieresis',
  40520. 'otilde',
  40521. 'uacute',
  40522. 'ugrave',
  40523. 'ucircumflex',
  40524. 'udieresis',
  40525. 'dagger',
  40526. 'degree',
  40527. 'cent',
  40528. 'sterling',
  40529. 'section',
  40530. 'bullet',
  40531. 'paragraph',
  40532. 'germandbls',
  40533. 'registered',
  40534. 'copyright',
  40535. 'trademark',
  40536. 'acute',
  40537. 'dieresis',
  40538. 'notequal',
  40539. 'AE',
  40540. 'Oslash',
  40541. 'infinity',
  40542. 'plusminus',
  40543. 'lessequal',
  40544. 'greaterequal',
  40545. 'yen',
  40546. 'mu',
  40547. 'partialdiff',
  40548. 'summation',
  40549. 'product',
  40550. 'pi',
  40551. 'integral',
  40552. 'ordfeminine',
  40553. 'ordmasculine',
  40554. 'Omega',
  40555. 'ae',
  40556. 'oslash',
  40557. 'questiondown',
  40558. 'exclamdown',
  40559. 'logicalnot',
  40560. 'radical',
  40561. 'florin',
  40562. 'approxequal',
  40563. 'Delta',
  40564. 'guillemotleft',
  40565. 'guillemotright',
  40566. 'ellipsis',
  40567. 'nonbreakingspace',
  40568. 'Agrave',
  40569. 'Atilde',
  40570. 'Otilde',
  40571. 'OE',
  40572. 'oe',
  40573. 'endash',
  40574. 'emdash',
  40575. 'quotedblleft',
  40576. 'quotedblright',
  40577. 'quoteleft',
  40578. 'quoteright',
  40579. 'divide',
  40580. 'lozenge',
  40581. 'ydieresis',
  40582. 'Ydieresis',
  40583. 'fraction',
  40584. 'currency',
  40585. 'guilsinglleft',
  40586. 'guilsinglright',
  40587. 'fi',
  40588. 'fl',
  40589. 'daggerdbl',
  40590. 'periodcentered',
  40591. 'quotesinglbase',
  40592. 'quotedblbase',
  40593. 'perthousand',
  40594. 'Acircumflex',
  40595. 'Ecircumflex',
  40596. 'Aacute',
  40597. 'Edieresis',
  40598. 'Egrave',
  40599. 'Iacute',
  40600. 'Icircumflex',
  40601. 'Idieresis',
  40602. 'Igrave',
  40603. 'Oacute',
  40604. 'Ocircumflex',
  40605. 'apple',
  40606. 'Ograve',
  40607. 'Uacute',
  40608. 'Ucircumflex',
  40609. 'Ugrave',
  40610. 'dotlessi',
  40611. 'circumflex',
  40612. 'tilde',
  40613. 'macron',
  40614. 'breve',
  40615. 'dotaccent',
  40616. 'ring',
  40617. 'cedilla',
  40618. 'hungarumlaut',
  40619. 'ogonek',
  40620. 'caron',
  40621. 'Lslash',
  40622. 'lslash',
  40623. 'Scaron',
  40624. 'scaron',
  40625. 'Zcaron',
  40626. 'zcaron',
  40627. 'brokenbar',
  40628. 'Eth',
  40629. 'eth',
  40630. 'Yacute',
  40631. 'yacute',
  40632. 'Thorn',
  40633. 'thorn',
  40634. 'minus',
  40635. 'multiply',
  40636. 'onesuperior',
  40637. 'twosuperior',
  40638. 'threesuperior',
  40639. 'onehalf',
  40640. 'onequarter',
  40641. 'threequarters',
  40642. 'franc',
  40643. 'Gbreve',
  40644. 'gbreve',
  40645. 'Idotaccent',
  40646. 'Scedilla',
  40647. 'scedilla',
  40648. 'Cacute',
  40649. 'cacute',
  40650. 'Ccaron',
  40651. 'ccaron',
  40652. 'dcroat'
  40653. ];
  40654. function adjustWidths(properties) {
  40655. if (!properties.fontMatrix) {
  40656. return;
  40657. }
  40658. if (properties.fontMatrix[0] === FONT_IDENTITY_MATRIX[0]) {
  40659. return;
  40660. }
  40661. var scale = 0.001 / properties.fontMatrix[0];
  40662. var glyphsWidths = properties.widths;
  40663. for (var glyph in glyphsWidths) {
  40664. glyphsWidths[glyph] *= scale;
  40665. }
  40666. properties.defaultWidth *= scale;
  40667. }
  40668. function adjustToUnicode(properties, builtInEncoding) {
  40669. if (properties.hasIncludedToUnicodeMap) {
  40670. return;
  40671. }
  40672. if (properties.hasEncoding) {
  40673. return;
  40674. }
  40675. if (builtInEncoding === properties.defaultEncoding) {
  40676. return;
  40677. }
  40678. if (properties.toUnicode instanceof IdentityToUnicodeMap) {
  40679. return;
  40680. }
  40681. var toUnicode = [], glyphsUnicodeMap = getGlyphsUnicode();
  40682. for (var charCode in builtInEncoding) {
  40683. var glyphName = builtInEncoding[charCode];
  40684. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  40685. if (unicode !== -1) {
  40686. toUnicode[charCode] = String.fromCharCode(unicode);
  40687. }
  40688. }
  40689. properties.toUnicode.amend(toUnicode);
  40690. }
  40691. function getFontType(type, subtype) {
  40692. switch (type) {
  40693. case 'Type1':
  40694. return subtype === 'Type1C' ? FontType.TYPE1C : FontType.TYPE1;
  40695. case 'CIDFontType0':
  40696. return subtype === 'CIDFontType0C' ? FontType.CIDFONTTYPE0C : FontType.CIDFONTTYPE0;
  40697. case 'OpenType':
  40698. return FontType.OPENTYPE;
  40699. case 'TrueType':
  40700. return FontType.TRUETYPE;
  40701. case 'CIDFontType2':
  40702. return FontType.CIDFONTTYPE2;
  40703. case 'MMType1':
  40704. return FontType.MMTYPE1;
  40705. case 'Type0':
  40706. return FontType.TYPE0;
  40707. default:
  40708. return FontType.UNKNOWN;
  40709. }
  40710. }
  40711. function recoverGlyphName(name, glyphsUnicodeMap) {
  40712. if (glyphsUnicodeMap[name] !== undefined) {
  40713. return name;
  40714. }
  40715. var unicode = getUnicodeForGlyph(name, glyphsUnicodeMap);
  40716. if (unicode !== -1) {
  40717. for (var key in glyphsUnicodeMap) {
  40718. if (glyphsUnicodeMap[key] === unicode) {
  40719. return key;
  40720. }
  40721. }
  40722. }
  40723. info('Unable to recover a standard glyph name for: ' + name);
  40724. return name;
  40725. }
  40726. var Glyph = function GlyphClosure() {
  40727. function Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40728. this.fontChar = fontChar;
  40729. this.unicode = unicode;
  40730. this.accent = accent;
  40731. this.width = width;
  40732. this.vmetric = vmetric;
  40733. this.operatorListId = operatorListId;
  40734. this.isSpace = isSpace;
  40735. this.isInFont = isInFont;
  40736. }
  40737. Glyph.prototype.matchesForCache = function (fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont) {
  40738. 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;
  40739. };
  40740. return Glyph;
  40741. }();
  40742. var ToUnicodeMap = function ToUnicodeMapClosure() {
  40743. function ToUnicodeMap(cmap) {
  40744. this._map = cmap;
  40745. }
  40746. ToUnicodeMap.prototype = {
  40747. get length() {
  40748. return this._map.length;
  40749. },
  40750. forEach: function (callback) {
  40751. for (var charCode in this._map) {
  40752. callback(charCode, this._map[charCode].charCodeAt(0));
  40753. }
  40754. },
  40755. has: function (i) {
  40756. return this._map[i] !== undefined;
  40757. },
  40758. get: function (i) {
  40759. return this._map[i];
  40760. },
  40761. charCodeOf: function (v) {
  40762. return this._map.indexOf(v);
  40763. },
  40764. amend: function (map) {
  40765. for (var charCode in map) {
  40766. this._map[charCode] = map[charCode];
  40767. }
  40768. }
  40769. };
  40770. return ToUnicodeMap;
  40771. }();
  40772. var IdentityToUnicodeMap = function IdentityToUnicodeMapClosure() {
  40773. function IdentityToUnicodeMap(firstChar, lastChar) {
  40774. this.firstChar = firstChar;
  40775. this.lastChar = lastChar;
  40776. }
  40777. IdentityToUnicodeMap.prototype = {
  40778. get length() {
  40779. return this.lastChar + 1 - this.firstChar;
  40780. },
  40781. forEach: function (callback) {
  40782. for (var i = this.firstChar, ii = this.lastChar; i <= ii; i++) {
  40783. callback(i, i);
  40784. }
  40785. },
  40786. has: function (i) {
  40787. return this.firstChar <= i && i <= this.lastChar;
  40788. },
  40789. get: function (i) {
  40790. if (this.firstChar <= i && i <= this.lastChar) {
  40791. return String.fromCharCode(i);
  40792. }
  40793. return undefined;
  40794. },
  40795. charCodeOf: function (v) {
  40796. return isInt(v) && v >= this.firstChar && v <= this.lastChar ? v : -1;
  40797. },
  40798. amend: function (map) {
  40799. error('Should not call amend()');
  40800. }
  40801. };
  40802. return IdentityToUnicodeMap;
  40803. }();
  40804. var OpenTypeFileBuilder = function OpenTypeFileBuilderClosure() {
  40805. function writeInt16(dest, offset, num) {
  40806. dest[offset] = num >> 8 & 0xFF;
  40807. dest[offset + 1] = num & 0xFF;
  40808. }
  40809. function writeInt32(dest, offset, num) {
  40810. dest[offset] = num >> 24 & 0xFF;
  40811. dest[offset + 1] = num >> 16 & 0xFF;
  40812. dest[offset + 2] = num >> 8 & 0xFF;
  40813. dest[offset + 3] = num & 0xFF;
  40814. }
  40815. function writeData(dest, offset, data) {
  40816. var i, ii;
  40817. if (data instanceof Uint8Array) {
  40818. dest.set(data, offset);
  40819. } else if (typeof data === 'string') {
  40820. for (i = 0, ii = data.length; i < ii; i++) {
  40821. dest[offset++] = data.charCodeAt(i) & 0xFF;
  40822. }
  40823. } else {
  40824. for (i = 0, ii = data.length; i < ii; i++) {
  40825. dest[offset++] = data[i] & 0xFF;
  40826. }
  40827. }
  40828. }
  40829. function OpenTypeFileBuilder(sfnt) {
  40830. this.sfnt = sfnt;
  40831. this.tables = Object.create(null);
  40832. }
  40833. OpenTypeFileBuilder.getSearchParams = function OpenTypeFileBuilder_getSearchParams(entriesCount, entrySize) {
  40834. var maxPower2 = 1, log2 = 0;
  40835. while ((maxPower2 ^ entriesCount) > maxPower2) {
  40836. maxPower2 <<= 1;
  40837. log2++;
  40838. }
  40839. var searchRange = maxPower2 * entrySize;
  40840. return {
  40841. range: searchRange,
  40842. entry: log2,
  40843. rangeShift: entrySize * entriesCount - searchRange
  40844. };
  40845. };
  40846. var OTF_HEADER_SIZE = 12;
  40847. var OTF_TABLE_ENTRY_SIZE = 16;
  40848. OpenTypeFileBuilder.prototype = {
  40849. toArray: function OpenTypeFileBuilder_toArray() {
  40850. var sfnt = this.sfnt;
  40851. var tables = this.tables;
  40852. var tablesNames = Object.keys(tables);
  40853. tablesNames.sort();
  40854. var numTables = tablesNames.length;
  40855. var i, j, jj, table, tableName;
  40856. var offset = OTF_HEADER_SIZE + numTables * OTF_TABLE_ENTRY_SIZE;
  40857. var tableOffsets = [offset];
  40858. for (i = 0; i < numTables; i++) {
  40859. table = tables[tablesNames[i]];
  40860. var paddedLength = (table.length + 3 & ~3) >>> 0;
  40861. offset += paddedLength;
  40862. tableOffsets.push(offset);
  40863. }
  40864. var file = new Uint8Array(offset);
  40865. for (i = 0; i < numTables; i++) {
  40866. table = tables[tablesNames[i]];
  40867. writeData(file, tableOffsets[i], table);
  40868. }
  40869. if (sfnt === 'true') {
  40870. sfnt = string32(0x00010000);
  40871. }
  40872. file[0] = sfnt.charCodeAt(0) & 0xFF;
  40873. file[1] = sfnt.charCodeAt(1) & 0xFF;
  40874. file[2] = sfnt.charCodeAt(2) & 0xFF;
  40875. file[3] = sfnt.charCodeAt(3) & 0xFF;
  40876. writeInt16(file, 4, numTables);
  40877. var searchParams = OpenTypeFileBuilder.getSearchParams(numTables, 16);
  40878. writeInt16(file, 6, searchParams.range);
  40879. writeInt16(file, 8, searchParams.entry);
  40880. writeInt16(file, 10, searchParams.rangeShift);
  40881. offset = OTF_HEADER_SIZE;
  40882. for (i = 0; i < numTables; i++) {
  40883. tableName = tablesNames[i];
  40884. file[offset] = tableName.charCodeAt(0) & 0xFF;
  40885. file[offset + 1] = tableName.charCodeAt(1) & 0xFF;
  40886. file[offset + 2] = tableName.charCodeAt(2) & 0xFF;
  40887. file[offset + 3] = tableName.charCodeAt(3) & 0xFF;
  40888. var checksum = 0;
  40889. for (j = tableOffsets[i], jj = tableOffsets[i + 1]; j < jj; j += 4) {
  40890. var quad = readUint32(file, j);
  40891. checksum = checksum + quad >>> 0;
  40892. }
  40893. writeInt32(file, offset + 4, checksum);
  40894. writeInt32(file, offset + 8, tableOffsets[i]);
  40895. writeInt32(file, offset + 12, tables[tableName].length);
  40896. offset += OTF_TABLE_ENTRY_SIZE;
  40897. }
  40898. return file;
  40899. },
  40900. addTable: function OpenTypeFileBuilder_addTable(tag, data) {
  40901. if (tag in this.tables) {
  40902. throw new Error('Table ' + tag + ' already exists');
  40903. }
  40904. this.tables[tag] = data;
  40905. }
  40906. };
  40907. return OpenTypeFileBuilder;
  40908. }();
  40909. var ProblematicCharRanges = new Int32Array([
  40910. 0x0000,
  40911. 0x0020,
  40912. 0x007F,
  40913. 0x00A1,
  40914. 0x00AD,
  40915. 0x00AE,
  40916. 0x0600,
  40917. 0x0780,
  40918. 0x08A0,
  40919. 0x10A0,
  40920. 0x1780,
  40921. 0x1800,
  40922. 0x1C00,
  40923. 0x1C50,
  40924. 0x2000,
  40925. 0x2010,
  40926. 0x2011,
  40927. 0x2012,
  40928. 0x2028,
  40929. 0x2030,
  40930. 0x205F,
  40931. 0x2070,
  40932. 0x25CC,
  40933. 0x25CD,
  40934. 0x3000,
  40935. 0x3001,
  40936. 0xAA60,
  40937. 0xAA80,
  40938. 0xFFF0,
  40939. 0x10000
  40940. ]);
  40941. var Font = function FontClosure() {
  40942. function Font(name, file, properties) {
  40943. var charCode, glyphName, unicode;
  40944. this.name = name;
  40945. this.loadedName = properties.loadedName;
  40946. this.isType3Font = properties.isType3Font;
  40947. this.sizes = [];
  40948. this.missingFile = false;
  40949. this.glyphCache = Object.create(null);
  40950. var names = name.split('+');
  40951. names = names.length > 1 ? names[1] : names[0];
  40952. names = names.split(/[-,_]/g)[0];
  40953. this.isSerifFont = !!(properties.flags & FontFlags.Serif);
  40954. this.isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  40955. this.isMonospace = !!(properties.flags & FontFlags.FixedPitch);
  40956. var type = properties.type;
  40957. var subtype = properties.subtype;
  40958. this.type = type;
  40959. this.fallbackName = this.isMonospace ? 'monospace' : this.isSerifFont ? 'serif' : 'sans-serif';
  40960. this.differences = properties.differences;
  40961. this.widths = properties.widths;
  40962. this.defaultWidth = properties.defaultWidth;
  40963. this.composite = properties.composite;
  40964. this.wideChars = properties.wideChars;
  40965. this.cMap = properties.cMap;
  40966. this.ascent = properties.ascent / PDF_GLYPH_SPACE_UNITS;
  40967. this.descent = properties.descent / PDF_GLYPH_SPACE_UNITS;
  40968. this.fontMatrix = properties.fontMatrix;
  40969. this.bbox = properties.bbox;
  40970. this.toUnicode = properties.toUnicode;
  40971. this.toFontChar = [];
  40972. if (properties.type === 'Type3') {
  40973. for (charCode = 0; charCode < 256; charCode++) {
  40974. this.toFontChar[charCode] = this.differences[charCode] || properties.defaultEncoding[charCode];
  40975. }
  40976. this.fontType = FontType.TYPE3;
  40977. return;
  40978. }
  40979. this.cidEncoding = properties.cidEncoding;
  40980. this.vertical = properties.vertical;
  40981. if (this.vertical) {
  40982. this.vmetrics = properties.vmetrics;
  40983. this.defaultVMetrics = properties.defaultVMetrics;
  40984. }
  40985. var glyphsUnicodeMap;
  40986. if (!file || file.isEmpty) {
  40987. if (file) {
  40988. warn('Font file is empty in "' + name + '" (' + this.loadedName + ')');
  40989. }
  40990. this.missingFile = true;
  40991. var fontName = name.replace(/[,_]/g, '-');
  40992. var stdFontMap = getStdFontMap(), nonStdFontMap = getNonStdFontMap();
  40993. var isStandardFont = !!stdFontMap[fontName] || !!(nonStdFontMap[fontName] && stdFontMap[nonStdFontMap[fontName]]);
  40994. fontName = stdFontMap[fontName] || nonStdFontMap[fontName] || fontName;
  40995. this.bold = fontName.search(/bold/gi) !== -1;
  40996. this.italic = fontName.search(/oblique/gi) !== -1 || fontName.search(/italic/gi) !== -1;
  40997. this.black = name.search(/Black/g) !== -1;
  40998. this.remeasure = Object.keys(this.widths).length > 0;
  40999. if (isStandardFont && type === 'CIDFontType2' && properties.cidEncoding.indexOf('Identity-') === 0) {
  41000. var GlyphMapForStandardFonts = getGlyphMapForStandardFonts();
  41001. var map = [];
  41002. for (charCode in GlyphMapForStandardFonts) {
  41003. map[+charCode] = GlyphMapForStandardFonts[charCode];
  41004. }
  41005. if (/Arial-?Black/i.test(name)) {
  41006. var SupplementalGlyphMapForArialBlack = getSupplementalGlyphMapForArialBlack();
  41007. for (charCode in SupplementalGlyphMapForArialBlack) {
  41008. map[+charCode] = SupplementalGlyphMapForArialBlack[charCode];
  41009. }
  41010. }
  41011. var isIdentityUnicode = this.toUnicode instanceof IdentityToUnicodeMap;
  41012. if (!isIdentityUnicode) {
  41013. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41014. map[+charCode] = unicodeCharCode;
  41015. });
  41016. }
  41017. this.toFontChar = map;
  41018. this.toUnicode = new ToUnicodeMap(map);
  41019. } else if (/Symbol/i.test(fontName)) {
  41020. this.toFontChar = buildToFontChar(SymbolSetEncoding, getGlyphsUnicode(), properties.differences);
  41021. } else if (/Dingbats/i.test(fontName)) {
  41022. if (/Wingdings/i.test(name)) {
  41023. warn('Non-embedded Wingdings font, falling back to ZapfDingbats.');
  41024. }
  41025. this.toFontChar = buildToFontChar(ZapfDingbatsEncoding, getDingbatsGlyphsUnicode(), properties.differences);
  41026. } else if (isStandardFont) {
  41027. this.toFontChar = buildToFontChar(properties.defaultEncoding, getGlyphsUnicode(), properties.differences);
  41028. } else {
  41029. glyphsUnicodeMap = getGlyphsUnicode();
  41030. this.toUnicode.forEach(function (charCode, unicodeCharCode) {
  41031. if (!this.composite) {
  41032. glyphName = properties.differences[charCode] || properties.defaultEncoding[charCode];
  41033. unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  41034. if (unicode !== -1) {
  41035. unicodeCharCode = unicode;
  41036. }
  41037. }
  41038. this.toFontChar[charCode] = unicodeCharCode;
  41039. }.bind(this));
  41040. }
  41041. this.loadedName = fontName.split('-')[0];
  41042. this.loading = false;
  41043. this.fontType = getFontType(type, subtype);
  41044. return;
  41045. }
  41046. if (subtype === 'Type1C') {
  41047. if (type !== 'Type1' && type !== 'MMType1') {
  41048. if (isTrueTypeFile(file)) {
  41049. subtype = 'TrueType';
  41050. } else {
  41051. type = 'Type1';
  41052. }
  41053. } else if (isOpenTypeFile(file)) {
  41054. type = subtype = 'OpenType';
  41055. }
  41056. }
  41057. if (subtype === 'CIDFontType0C' && type !== 'CIDFontType0') {
  41058. type = 'CIDFontType0';
  41059. }
  41060. if (subtype === 'OpenType') {
  41061. type = 'OpenType';
  41062. }
  41063. if (type === 'CIDFontType0') {
  41064. if (isType1File(file)) {
  41065. subtype = 'CIDFontType0';
  41066. } else if (isOpenTypeFile(file)) {
  41067. type = subtype = 'OpenType';
  41068. } else {
  41069. subtype = 'CIDFontType0C';
  41070. }
  41071. }
  41072. var data;
  41073. switch (type) {
  41074. case 'MMType1':
  41075. info('MMType1 font (' + name + '), falling back to Type1.');
  41076. case 'Type1':
  41077. case 'CIDFontType0':
  41078. this.mimetype = 'font/opentype';
  41079. var cff = subtype === 'Type1C' || subtype === 'CIDFontType0C' ? new CFFFont(file, properties) : new Type1Font(name, file, properties);
  41080. adjustWidths(properties);
  41081. data = this.convert(name, cff, properties);
  41082. break;
  41083. case 'OpenType':
  41084. case 'TrueType':
  41085. case 'CIDFontType2':
  41086. this.mimetype = 'font/opentype';
  41087. data = this.checkAndRepair(name, file, properties);
  41088. if (this.isOpenType) {
  41089. adjustWidths(properties);
  41090. type = 'OpenType';
  41091. }
  41092. break;
  41093. default:
  41094. error('Font ' + type + ' is not supported');
  41095. break;
  41096. }
  41097. this.data = data;
  41098. this.fontType = getFontType(type, subtype);
  41099. this.fontMatrix = properties.fontMatrix;
  41100. this.widths = properties.widths;
  41101. this.defaultWidth = properties.defaultWidth;
  41102. this.toUnicode = properties.toUnicode;
  41103. this.encoding = properties.baseEncoding;
  41104. this.seacMap = properties.seacMap;
  41105. this.loading = true;
  41106. }
  41107. Font.getFontID = function () {
  41108. var ID = 1;
  41109. return function Font_getFontID() {
  41110. return String(ID++);
  41111. };
  41112. }();
  41113. function int16(b0, b1) {
  41114. return (b0 << 8) + b1;
  41115. }
  41116. function signedInt16(b0, b1) {
  41117. var value = (b0 << 8) + b1;
  41118. return value & 1 << 15 ? value - 0x10000 : value;
  41119. }
  41120. function int32(b0, b1, b2, b3) {
  41121. return (b0 << 24) + (b1 << 16) + (b2 << 8) + b3;
  41122. }
  41123. function string16(value) {
  41124. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41125. }
  41126. function safeString16(value) {
  41127. value = value > 0x7FFF ? 0x7FFF : value < -0x8000 ? -0x8000 : value;
  41128. return String.fromCharCode(value >> 8 & 0xff, value & 0xff);
  41129. }
  41130. function isTrueTypeFile(file) {
  41131. var header = file.peekBytes(4);
  41132. return readUint32(header, 0) === 0x00010000;
  41133. }
  41134. function isOpenTypeFile(file) {
  41135. var header = file.peekBytes(4);
  41136. return bytesToString(header) === 'OTTO';
  41137. }
  41138. function isType1File(file) {
  41139. var header = file.peekBytes(2);
  41140. if (header[0] === 0x25 && header[1] === 0x21) {
  41141. return true;
  41142. }
  41143. if (header[0] === 0x80 && header[1] === 0x01) {
  41144. return true;
  41145. }
  41146. return false;
  41147. }
  41148. function buildToFontChar(encoding, glyphsUnicodeMap, differences) {
  41149. var toFontChar = [], unicode;
  41150. for (var i = 0, ii = encoding.length; i < ii; i++) {
  41151. unicode = getUnicodeForGlyph(encoding[i], glyphsUnicodeMap);
  41152. if (unicode !== -1) {
  41153. toFontChar[i] = unicode;
  41154. }
  41155. }
  41156. for (var charCode in differences) {
  41157. unicode = getUnicodeForGlyph(differences[charCode], glyphsUnicodeMap);
  41158. if (unicode !== -1) {
  41159. toFontChar[+charCode] = unicode;
  41160. }
  41161. }
  41162. return toFontChar;
  41163. }
  41164. function isProblematicUnicodeLocation(code) {
  41165. var i = 0, j = ProblematicCharRanges.length - 1;
  41166. while (i < j) {
  41167. var c = i + j + 1 >> 1;
  41168. if (code < ProblematicCharRanges[c]) {
  41169. j = c - 1;
  41170. } else {
  41171. i = c;
  41172. }
  41173. }
  41174. return !(i & 1);
  41175. }
  41176. function adjustMapping(charCodeToGlyphId, properties) {
  41177. var toUnicode = properties.toUnicode;
  41178. var isSymbolic = !!(properties.flags & FontFlags.Symbolic);
  41179. var isIdentityUnicode = properties.toUnicode instanceof IdentityToUnicodeMap;
  41180. var newMap = Object.create(null);
  41181. var toFontChar = [];
  41182. var usedFontCharCodes = [];
  41183. var nextAvailableFontCharCode = PRIVATE_USE_OFFSET_START;
  41184. for (var originalCharCode in charCodeToGlyphId) {
  41185. originalCharCode |= 0;
  41186. var glyphId = charCodeToGlyphId[originalCharCode];
  41187. var fontCharCode = originalCharCode;
  41188. if (!isIdentityUnicode && toUnicode.has(originalCharCode)) {
  41189. var unicode = toUnicode.get(fontCharCode);
  41190. if (unicode.length === 1) {
  41191. fontCharCode = unicode.charCodeAt(0);
  41192. }
  41193. }
  41194. if ((usedFontCharCodes[fontCharCode] !== undefined || isProblematicUnicodeLocation(fontCharCode) || isSymbolic && isIdentityUnicode) && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END) {
  41195. do {
  41196. fontCharCode = nextAvailableFontCharCode++;
  41197. if (SKIP_PRIVATE_USE_RANGE_F000_TO_F01F && fontCharCode === 0xF000) {
  41198. fontCharCode = 0xF020;
  41199. nextAvailableFontCharCode = fontCharCode + 1;
  41200. }
  41201. } while (usedFontCharCodes[fontCharCode] !== undefined && nextAvailableFontCharCode <= PRIVATE_USE_OFFSET_END);
  41202. }
  41203. newMap[fontCharCode] = glyphId;
  41204. toFontChar[originalCharCode] = fontCharCode;
  41205. usedFontCharCodes[fontCharCode] = true;
  41206. }
  41207. return {
  41208. toFontChar: toFontChar,
  41209. charCodeToGlyphId: newMap,
  41210. nextAvailableFontCharCode: nextAvailableFontCharCode
  41211. };
  41212. }
  41213. function getRanges(glyphs, numGlyphs) {
  41214. var codes = [];
  41215. for (var charCode in glyphs) {
  41216. if (glyphs[charCode] >= numGlyphs) {
  41217. continue;
  41218. }
  41219. codes.push({
  41220. fontCharCode: charCode | 0,
  41221. glyphId: glyphs[charCode]
  41222. });
  41223. }
  41224. codes.sort(function fontGetRangesSort(a, b) {
  41225. return a.fontCharCode - b.fontCharCode;
  41226. });
  41227. var ranges = [];
  41228. var length = codes.length;
  41229. for (var n = 0; n < length;) {
  41230. var start = codes[n].fontCharCode;
  41231. var codeIndices = [codes[n].glyphId];
  41232. ++n;
  41233. var end = start;
  41234. while (n < length && end + 1 === codes[n].fontCharCode) {
  41235. codeIndices.push(codes[n].glyphId);
  41236. ++end;
  41237. ++n;
  41238. if (end === 0xFFFF) {
  41239. break;
  41240. }
  41241. }
  41242. ranges.push([
  41243. start,
  41244. end,
  41245. codeIndices
  41246. ]);
  41247. }
  41248. return ranges;
  41249. }
  41250. function createCmapTable(glyphs, numGlyphs) {
  41251. var ranges = getRanges(glyphs, numGlyphs);
  41252. var numTables = ranges[ranges.length - 1][1] > 0xFFFF ? 2 : 1;
  41253. var cmap = '\x00\x00' + string16(numTables) + '\x00\x03' + '\x00\x01' + string32(4 + numTables * 8);
  41254. var i, ii, j, jj;
  41255. for (i = ranges.length - 1; i >= 0; --i) {
  41256. if (ranges[i][0] <= 0xFFFF) {
  41257. break;
  41258. }
  41259. }
  41260. var bmpLength = i + 1;
  41261. if (ranges[i][0] < 0xFFFF && ranges[i][1] === 0xFFFF) {
  41262. ranges[i][1] = 0xFFFE;
  41263. }
  41264. var trailingRangesCount = ranges[i][1] < 0xFFFF ? 1 : 0;
  41265. var segCount = bmpLength + trailingRangesCount;
  41266. var searchParams = OpenTypeFileBuilder.getSearchParams(segCount, 2);
  41267. var startCount = '';
  41268. var endCount = '';
  41269. var idDeltas = '';
  41270. var idRangeOffsets = '';
  41271. var glyphsIds = '';
  41272. var bias = 0;
  41273. var range, start, end, codes;
  41274. for (i = 0, ii = bmpLength; i < ii; i++) {
  41275. range = ranges[i];
  41276. start = range[0];
  41277. end = range[1];
  41278. startCount += string16(start);
  41279. endCount += string16(end);
  41280. codes = range[2];
  41281. var contiguous = true;
  41282. for (j = 1, jj = codes.length; j < jj; ++j) {
  41283. if (codes[j] !== codes[j - 1] + 1) {
  41284. contiguous = false;
  41285. break;
  41286. }
  41287. }
  41288. if (!contiguous) {
  41289. var offset = (segCount - i) * 2 + bias * 2;
  41290. bias += end - start + 1;
  41291. idDeltas += string16(0);
  41292. idRangeOffsets += string16(offset);
  41293. for (j = 0, jj = codes.length; j < jj; ++j) {
  41294. glyphsIds += string16(codes[j]);
  41295. }
  41296. } else {
  41297. var startCode = codes[0];
  41298. idDeltas += string16(startCode - start & 0xFFFF);
  41299. idRangeOffsets += string16(0);
  41300. }
  41301. }
  41302. if (trailingRangesCount > 0) {
  41303. endCount += '\xFF\xFF';
  41304. startCount += '\xFF\xFF';
  41305. idDeltas += '\x00\x01';
  41306. idRangeOffsets += '\x00\x00';
  41307. }
  41308. var format314 = '\x00\x00' + string16(2 * segCount) + string16(searchParams.range) + string16(searchParams.entry) + string16(searchParams.rangeShift) + endCount + '\x00\x00' + startCount + idDeltas + idRangeOffsets + glyphsIds;
  41309. var format31012 = '';
  41310. var header31012 = '';
  41311. if (numTables > 1) {
  41312. cmap += '\x00\x03' + '\x00\x0A' + string32(4 + numTables * 8 + 4 + format314.length);
  41313. format31012 = '';
  41314. for (i = 0, ii = ranges.length; i < ii; i++) {
  41315. range = ranges[i];
  41316. start = range[0];
  41317. codes = range[2];
  41318. var code = codes[0];
  41319. for (j = 1, jj = codes.length; j < jj; ++j) {
  41320. if (codes[j] !== codes[j - 1] + 1) {
  41321. end = range[0] + j - 1;
  41322. format31012 += string32(start) + string32(end) + string32(code);
  41323. start = end + 1;
  41324. code = codes[j];
  41325. }
  41326. }
  41327. format31012 += string32(start) + string32(range[1]) + string32(code);
  41328. }
  41329. header31012 = '\x00\x0C' + '\x00\x00' + string32(format31012.length + 16) + '\x00\x00\x00\x00' + string32(format31012.length / 12);
  41330. }
  41331. return cmap + '\x00\x04' + string16(format314.length + 4) + format314 + header31012 + format31012;
  41332. }
  41333. function validateOS2Table(os2) {
  41334. var stream = new Stream(os2.data);
  41335. var version = stream.getUint16();
  41336. stream.getBytes(60);
  41337. var selection = stream.getUint16();
  41338. if (version < 4 && selection & 0x0300) {
  41339. return false;
  41340. }
  41341. var firstChar = stream.getUint16();
  41342. var lastChar = stream.getUint16();
  41343. if (firstChar > lastChar) {
  41344. return false;
  41345. }
  41346. stream.getBytes(6);
  41347. var usWinAscent = stream.getUint16();
  41348. if (usWinAscent === 0) {
  41349. return false;
  41350. }
  41351. os2.data[8] = os2.data[9] = 0;
  41352. return true;
  41353. }
  41354. function createOS2Table(properties, charstrings, override) {
  41355. override = override || {
  41356. unitsPerEm: 0,
  41357. yMax: 0,
  41358. yMin: 0,
  41359. ascent: 0,
  41360. descent: 0
  41361. };
  41362. var ulUnicodeRange1 = 0;
  41363. var ulUnicodeRange2 = 0;
  41364. var ulUnicodeRange3 = 0;
  41365. var ulUnicodeRange4 = 0;
  41366. var firstCharIndex = null;
  41367. var lastCharIndex = 0;
  41368. if (charstrings) {
  41369. for (var code in charstrings) {
  41370. code |= 0;
  41371. if (firstCharIndex > code || !firstCharIndex) {
  41372. firstCharIndex = code;
  41373. }
  41374. if (lastCharIndex < code) {
  41375. lastCharIndex = code;
  41376. }
  41377. var position = getUnicodeRangeFor(code);
  41378. if (position < 32) {
  41379. ulUnicodeRange1 |= 1 << position;
  41380. } else if (position < 64) {
  41381. ulUnicodeRange2 |= 1 << position - 32;
  41382. } else if (position < 96) {
  41383. ulUnicodeRange3 |= 1 << position - 64;
  41384. } else if (position < 123) {
  41385. ulUnicodeRange4 |= 1 << position - 96;
  41386. } else {
  41387. error('Unicode ranges Bits > 123 are reserved for internal usage');
  41388. }
  41389. }
  41390. } else {
  41391. firstCharIndex = 0;
  41392. lastCharIndex = 255;
  41393. }
  41394. var bbox = properties.bbox || [
  41395. 0,
  41396. 0,
  41397. 0,
  41398. 0
  41399. ];
  41400. var unitsPerEm = override.unitsPerEm || 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  41401. var scale = properties.ascentScaled ? 1.0 : unitsPerEm / PDF_GLYPH_SPACE_UNITS;
  41402. var typoAscent = override.ascent || Math.round(scale * (properties.ascent || bbox[3]));
  41403. var typoDescent = override.descent || Math.round(scale * (properties.descent || bbox[1]));
  41404. if (typoDescent > 0 && properties.descent > 0 && bbox[1] < 0) {
  41405. typoDescent = -typoDescent;
  41406. }
  41407. var winAscent = override.yMax || typoAscent;
  41408. var winDescent = -override.yMin || -typoDescent;
  41409. 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';
  41410. }
  41411. function createPostTable(properties) {
  41412. var angle = Math.floor(properties.italicAngle * Math.pow(2, 16));
  41413. 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';
  41414. }
  41415. function createNameTable(name, proto) {
  41416. if (!proto) {
  41417. proto = [
  41418. [],
  41419. []
  41420. ];
  41421. }
  41422. var strings = [
  41423. proto[0][0] || 'Original licence',
  41424. proto[0][1] || name,
  41425. proto[0][2] || 'Unknown',
  41426. proto[0][3] || 'uniqueID',
  41427. proto[0][4] || name,
  41428. proto[0][5] || 'Version 0.11',
  41429. proto[0][6] || '',
  41430. proto[0][7] || 'Unknown',
  41431. proto[0][8] || 'Unknown',
  41432. proto[0][9] || 'Unknown'
  41433. ];
  41434. var stringsUnicode = [];
  41435. var i, ii, j, jj, str;
  41436. for (i = 0, ii = strings.length; i < ii; i++) {
  41437. str = proto[1][i] || strings[i];
  41438. var strBufUnicode = [];
  41439. for (j = 0, jj = str.length; j < jj; j++) {
  41440. strBufUnicode.push(string16(str.charCodeAt(j)));
  41441. }
  41442. stringsUnicode.push(strBufUnicode.join(''));
  41443. }
  41444. var names = [
  41445. strings,
  41446. stringsUnicode
  41447. ];
  41448. var platforms = [
  41449. '\x00\x01',
  41450. '\x00\x03'
  41451. ];
  41452. var encodings = [
  41453. '\x00\x00',
  41454. '\x00\x01'
  41455. ];
  41456. var languages = [
  41457. '\x00\x00',
  41458. '\x04\x09'
  41459. ];
  41460. var namesRecordCount = strings.length * platforms.length;
  41461. var nameTable = '\x00\x00' + string16(namesRecordCount) + string16(namesRecordCount * 12 + 6);
  41462. var strOffset = 0;
  41463. for (i = 0, ii = platforms.length; i < ii; i++) {
  41464. var strs = names[i];
  41465. for (j = 0, jj = strs.length; j < jj; j++) {
  41466. str = strs[j];
  41467. var nameRecord = platforms[i] + encodings[i] + languages[i] + string16(j) + string16(str.length) + string16(strOffset);
  41468. nameTable += nameRecord;
  41469. strOffset += str.length;
  41470. }
  41471. }
  41472. nameTable += strings.join('') + stringsUnicode.join('');
  41473. return nameTable;
  41474. }
  41475. Font.prototype = {
  41476. name: null,
  41477. font: null,
  41478. mimetype: null,
  41479. encoding: null,
  41480. get renderer() {
  41481. var renderer = FontRendererFactory.create(this, SEAC_ANALYSIS_ENABLED);
  41482. return shadow(this, 'renderer', renderer);
  41483. },
  41484. exportData: function Font_exportData() {
  41485. var data = {};
  41486. for (var i in this) {
  41487. if (this.hasOwnProperty(i)) {
  41488. data[i] = this[i];
  41489. }
  41490. }
  41491. return data;
  41492. },
  41493. checkAndRepair: function Font_checkAndRepair(name, font, properties) {
  41494. function readTableEntry(file) {
  41495. var tag = bytesToString(file.getBytes(4));
  41496. var checksum = file.getInt32() >>> 0;
  41497. var offset = file.getInt32() >>> 0;
  41498. var length = file.getInt32() >>> 0;
  41499. var previousPosition = file.pos;
  41500. file.pos = file.start ? file.start : 0;
  41501. file.skip(offset);
  41502. var data = file.getBytes(length);
  41503. file.pos = previousPosition;
  41504. if (tag === 'head') {
  41505. data[8] = data[9] = data[10] = data[11] = 0;
  41506. data[17] |= 0x20;
  41507. }
  41508. return {
  41509. tag: tag,
  41510. checksum: checksum,
  41511. length: length,
  41512. offset: offset,
  41513. data: data
  41514. };
  41515. }
  41516. function readOpenTypeHeader(ttf) {
  41517. return {
  41518. version: bytesToString(ttf.getBytes(4)),
  41519. numTables: ttf.getUint16(),
  41520. searchRange: ttf.getUint16(),
  41521. entrySelector: ttf.getUint16(),
  41522. rangeShift: ttf.getUint16()
  41523. };
  41524. }
  41525. function readCmapTable(cmap, font, isSymbolicFont, hasEncoding) {
  41526. if (!cmap) {
  41527. warn('No cmap table available.');
  41528. return {
  41529. platformId: -1,
  41530. encodingId: -1,
  41531. mappings: [],
  41532. hasShortCmap: false
  41533. };
  41534. }
  41535. var segment;
  41536. var start = (font.start ? font.start : 0) + cmap.offset;
  41537. font.pos = start;
  41538. var version = font.getUint16();
  41539. var numTables = font.getUint16();
  41540. var potentialTable;
  41541. var canBreak = false;
  41542. for (var i = 0; i < numTables; i++) {
  41543. var platformId = font.getUint16();
  41544. var encodingId = font.getUint16();
  41545. var offset = font.getInt32() >>> 0;
  41546. var useTable = false;
  41547. if (platformId === 0 && encodingId === 0) {
  41548. useTable = true;
  41549. } else if (platformId === 1 && encodingId === 0) {
  41550. useTable = true;
  41551. } else if (platformId === 3 && encodingId === 1 && (!isSymbolicFont && hasEncoding || !potentialTable)) {
  41552. useTable = true;
  41553. if (!isSymbolicFont) {
  41554. canBreak = true;
  41555. }
  41556. } else if (isSymbolicFont && platformId === 3 && encodingId === 0) {
  41557. useTable = true;
  41558. canBreak = true;
  41559. }
  41560. if (useTable) {
  41561. potentialTable = {
  41562. platformId: platformId,
  41563. encodingId: encodingId,
  41564. offset: offset
  41565. };
  41566. }
  41567. if (canBreak) {
  41568. break;
  41569. }
  41570. }
  41571. if (potentialTable) {
  41572. font.pos = start + potentialTable.offset;
  41573. }
  41574. if (!potentialTable || font.peekByte() === -1) {
  41575. warn('Could not find a preferred cmap table.');
  41576. return {
  41577. platformId: -1,
  41578. encodingId: -1,
  41579. mappings: [],
  41580. hasShortCmap: false
  41581. };
  41582. }
  41583. var format = font.getUint16();
  41584. var length = font.getUint16();
  41585. var language = font.getUint16();
  41586. var hasShortCmap = false;
  41587. var mappings = [];
  41588. var j, glyphId;
  41589. if (format === 0) {
  41590. for (j = 0; j < 256; j++) {
  41591. var index = font.getByte();
  41592. if (!index) {
  41593. continue;
  41594. }
  41595. mappings.push({
  41596. charCode: j,
  41597. glyphId: index
  41598. });
  41599. }
  41600. hasShortCmap = true;
  41601. } else if (format === 4) {
  41602. var segCount = font.getUint16() >> 1;
  41603. font.getBytes(6);
  41604. var segIndex, segments = [];
  41605. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41606. segments.push({ end: font.getUint16() });
  41607. }
  41608. font.getUint16();
  41609. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41610. segments[segIndex].start = font.getUint16();
  41611. }
  41612. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41613. segments[segIndex].delta = font.getUint16();
  41614. }
  41615. var offsetsCount = 0;
  41616. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41617. segment = segments[segIndex];
  41618. var rangeOffset = font.getUint16();
  41619. if (!rangeOffset) {
  41620. segment.offsetIndex = -1;
  41621. continue;
  41622. }
  41623. var offsetIndex = (rangeOffset >> 1) - (segCount - segIndex);
  41624. segment.offsetIndex = offsetIndex;
  41625. offsetsCount = Math.max(offsetsCount, offsetIndex + segment.end - segment.start + 1);
  41626. }
  41627. var offsets = [];
  41628. for (j = 0; j < offsetsCount; j++) {
  41629. offsets.push(font.getUint16());
  41630. }
  41631. for (segIndex = 0; segIndex < segCount; segIndex++) {
  41632. segment = segments[segIndex];
  41633. start = segment.start;
  41634. var end = segment.end;
  41635. var delta = segment.delta;
  41636. offsetIndex = segment.offsetIndex;
  41637. for (j = start; j <= end; j++) {
  41638. if (j === 0xFFFF) {
  41639. continue;
  41640. }
  41641. glyphId = offsetIndex < 0 ? j : offsets[offsetIndex + j - start];
  41642. glyphId = glyphId + delta & 0xFFFF;
  41643. if (glyphId === 0) {
  41644. continue;
  41645. }
  41646. mappings.push({
  41647. charCode: j,
  41648. glyphId: glyphId
  41649. });
  41650. }
  41651. }
  41652. } else if (format === 6) {
  41653. var firstCode = font.getUint16();
  41654. var entryCount = font.getUint16();
  41655. for (j = 0; j < entryCount; j++) {
  41656. glyphId = font.getUint16();
  41657. var charCode = firstCode + j;
  41658. mappings.push({
  41659. charCode: charCode,
  41660. glyphId: glyphId
  41661. });
  41662. }
  41663. } else {
  41664. warn('cmap table has unsupported format: ' + format);
  41665. return {
  41666. platformId: -1,
  41667. encodingId: -1,
  41668. mappings: [],
  41669. hasShortCmap: false
  41670. };
  41671. }
  41672. mappings.sort(function (a, b) {
  41673. return a.charCode - b.charCode;
  41674. });
  41675. for (i = 1; i < mappings.length; i++) {
  41676. if (mappings[i - 1].charCode === mappings[i].charCode) {
  41677. mappings.splice(i, 1);
  41678. i--;
  41679. }
  41680. }
  41681. return {
  41682. platformId: potentialTable.platformId,
  41683. encodingId: potentialTable.encodingId,
  41684. mappings: mappings,
  41685. hasShortCmap: hasShortCmap
  41686. };
  41687. }
  41688. function sanitizeMetrics(font, header, metrics, numGlyphs) {
  41689. if (!header) {
  41690. if (metrics) {
  41691. metrics.data = null;
  41692. }
  41693. return;
  41694. }
  41695. font.pos = (font.start ? font.start : 0) + header.offset;
  41696. font.pos += header.length - 2;
  41697. var numOfMetrics = font.getUint16();
  41698. if (numOfMetrics > numGlyphs) {
  41699. info('The numOfMetrics (' + numOfMetrics + ') should not be ' + 'greater than the numGlyphs (' + numGlyphs + ')');
  41700. numOfMetrics = numGlyphs;
  41701. header.data[34] = (numOfMetrics & 0xff00) >> 8;
  41702. header.data[35] = numOfMetrics & 0x00ff;
  41703. }
  41704. var numOfSidebearings = numGlyphs - numOfMetrics;
  41705. var numMissing = numOfSidebearings - (metrics.length - numOfMetrics * 4 >> 1);
  41706. if (numMissing > 0) {
  41707. var entries = new Uint8Array(metrics.length + numMissing * 2);
  41708. entries.set(metrics.data);
  41709. metrics.data = entries;
  41710. }
  41711. }
  41712. function sanitizeGlyph(source, sourceStart, sourceEnd, dest, destStart, hintsValid) {
  41713. if (sourceEnd - sourceStart <= 12) {
  41714. return 0;
  41715. }
  41716. var glyf = source.subarray(sourceStart, sourceEnd);
  41717. var contoursCount = glyf[0] << 8 | glyf[1];
  41718. if (contoursCount & 0x8000) {
  41719. dest.set(glyf, destStart);
  41720. return glyf.length;
  41721. }
  41722. var i, j = 10, flagsCount = 0;
  41723. for (i = 0; i < contoursCount; i++) {
  41724. var endPoint = glyf[j] << 8 | glyf[j + 1];
  41725. flagsCount = endPoint + 1;
  41726. j += 2;
  41727. }
  41728. var instructionsStart = j;
  41729. var instructionsLength = glyf[j] << 8 | glyf[j + 1];
  41730. j += 2 + instructionsLength;
  41731. var instructionsEnd = j;
  41732. var coordinatesLength = 0;
  41733. for (i = 0; i < flagsCount; i++) {
  41734. var flag = glyf[j++];
  41735. if (flag & 0xC0) {
  41736. glyf[j - 1] = flag & 0x3F;
  41737. }
  41738. var xyLength = (flag & 2 ? 1 : flag & 16 ? 0 : 2) + (flag & 4 ? 1 : flag & 32 ? 0 : 2);
  41739. coordinatesLength += xyLength;
  41740. if (flag & 8) {
  41741. var repeat = glyf[j++];
  41742. i += repeat;
  41743. coordinatesLength += repeat * xyLength;
  41744. }
  41745. }
  41746. if (coordinatesLength === 0) {
  41747. return 0;
  41748. }
  41749. var glyphDataLength = j + coordinatesLength;
  41750. if (glyphDataLength > glyf.length) {
  41751. return 0;
  41752. }
  41753. if (!hintsValid && instructionsLength > 0) {
  41754. dest.set(glyf.subarray(0, instructionsStart), destStart);
  41755. dest.set([
  41756. 0,
  41757. 0
  41758. ], destStart + instructionsStart);
  41759. dest.set(glyf.subarray(instructionsEnd, glyphDataLength), destStart + instructionsStart + 2);
  41760. glyphDataLength -= instructionsLength;
  41761. if (glyf.length - glyphDataLength > 3) {
  41762. glyphDataLength = glyphDataLength + 3 & ~3;
  41763. }
  41764. return glyphDataLength;
  41765. }
  41766. if (glyf.length - glyphDataLength > 3) {
  41767. glyphDataLength = glyphDataLength + 3 & ~3;
  41768. dest.set(glyf.subarray(0, glyphDataLength), destStart);
  41769. return glyphDataLength;
  41770. }
  41771. dest.set(glyf, destStart);
  41772. return glyf.length;
  41773. }
  41774. function sanitizeHead(head, numGlyphs, locaLength) {
  41775. var data = head.data;
  41776. var version = int32(data[0], data[1], data[2], data[3]);
  41777. if (version >> 16 !== 1) {
  41778. info('Attempting to fix invalid version in head table: ' + version);
  41779. data[0] = 0;
  41780. data[1] = 1;
  41781. data[2] = 0;
  41782. data[3] = 0;
  41783. }
  41784. var indexToLocFormat = int16(data[50], data[51]);
  41785. if (indexToLocFormat < 0 || indexToLocFormat > 1) {
  41786. info('Attempting to fix invalid indexToLocFormat in head table: ' + indexToLocFormat);
  41787. var numGlyphsPlusOne = numGlyphs + 1;
  41788. if (locaLength === numGlyphsPlusOne << 1) {
  41789. data[50] = 0;
  41790. data[51] = 0;
  41791. } else if (locaLength === numGlyphsPlusOne << 2) {
  41792. data[50] = 0;
  41793. data[51] = 1;
  41794. } else {
  41795. warn('Could not fix indexToLocFormat: ' + indexToLocFormat);
  41796. }
  41797. }
  41798. }
  41799. function sanitizeGlyphLocations(loca, glyf, numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry) {
  41800. var itemSize, itemDecode, itemEncode;
  41801. if (isGlyphLocationsLong) {
  41802. itemSize = 4;
  41803. itemDecode = function fontItemDecodeLong(data, offset) {
  41804. return data[offset] << 24 | data[offset + 1] << 16 | data[offset + 2] << 8 | data[offset + 3];
  41805. };
  41806. itemEncode = function fontItemEncodeLong(data, offset, value) {
  41807. data[offset] = value >>> 24 & 0xFF;
  41808. data[offset + 1] = value >> 16 & 0xFF;
  41809. data[offset + 2] = value >> 8 & 0xFF;
  41810. data[offset + 3] = value & 0xFF;
  41811. };
  41812. } else {
  41813. itemSize = 2;
  41814. itemDecode = function fontItemDecode(data, offset) {
  41815. return data[offset] << 9 | data[offset + 1] << 1;
  41816. };
  41817. itemEncode = function fontItemEncode(data, offset, value) {
  41818. data[offset] = value >> 9 & 0xFF;
  41819. data[offset + 1] = value >> 1 & 0xFF;
  41820. };
  41821. }
  41822. var locaData = loca.data;
  41823. var locaDataSize = itemSize * (1 + numGlyphs);
  41824. if (locaData.length !== locaDataSize) {
  41825. locaData = new Uint8Array(locaDataSize);
  41826. locaData.set(loca.data.subarray(0, locaDataSize));
  41827. loca.data = locaData;
  41828. }
  41829. var oldGlyfData = glyf.data;
  41830. var oldGlyfDataLength = oldGlyfData.length;
  41831. var newGlyfData = new Uint8Array(oldGlyfDataLength);
  41832. var startOffset = itemDecode(locaData, 0);
  41833. var writeOffset = 0;
  41834. var missingGlyphData = Object.create(null);
  41835. itemEncode(locaData, 0, writeOffset);
  41836. var i, j;
  41837. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  41838. var endOffset = itemDecode(locaData, j);
  41839. if (endOffset > oldGlyfDataLength && (oldGlyfDataLength + 3 & ~3) === endOffset) {
  41840. endOffset = oldGlyfDataLength;
  41841. }
  41842. if (endOffset > oldGlyfDataLength) {
  41843. itemEncode(locaData, j, writeOffset);
  41844. startOffset = endOffset;
  41845. continue;
  41846. }
  41847. if (startOffset === endOffset) {
  41848. missingGlyphData[i] = true;
  41849. }
  41850. var newLength = sanitizeGlyph(oldGlyfData, startOffset, endOffset, newGlyfData, writeOffset, hintsValid);
  41851. writeOffset += newLength;
  41852. itemEncode(locaData, j, writeOffset);
  41853. startOffset = endOffset;
  41854. }
  41855. if (writeOffset === 0) {
  41856. var simpleGlyph = new Uint8Array([
  41857. 0,
  41858. 1,
  41859. 0,
  41860. 0,
  41861. 0,
  41862. 0,
  41863. 0,
  41864. 0,
  41865. 0,
  41866. 0,
  41867. 0,
  41868. 0,
  41869. 0,
  41870. 0,
  41871. 49,
  41872. 0
  41873. ]);
  41874. for (i = 0, j = itemSize; i < numGlyphs; i++, j += itemSize) {
  41875. itemEncode(locaData, j, simpleGlyph.length);
  41876. }
  41877. glyf.data = simpleGlyph;
  41878. return missingGlyphData;
  41879. }
  41880. if (dupFirstEntry) {
  41881. var firstEntryLength = itemDecode(locaData, itemSize);
  41882. if (newGlyfData.length > firstEntryLength + writeOffset) {
  41883. glyf.data = newGlyfData.subarray(0, firstEntryLength + writeOffset);
  41884. } else {
  41885. glyf.data = new Uint8Array(firstEntryLength + writeOffset);
  41886. glyf.data.set(newGlyfData.subarray(0, writeOffset));
  41887. }
  41888. glyf.data.set(newGlyfData.subarray(0, firstEntryLength), writeOffset);
  41889. itemEncode(loca.data, locaData.length - itemSize, writeOffset + firstEntryLength);
  41890. } else {
  41891. glyf.data = newGlyfData.subarray(0, writeOffset);
  41892. }
  41893. return missingGlyphData;
  41894. }
  41895. function readPostScriptTable(post, properties, maxpNumGlyphs) {
  41896. var start = (font.start ? font.start : 0) + post.offset;
  41897. font.pos = start;
  41898. var length = post.length, end = start + length;
  41899. var version = font.getInt32();
  41900. font.getBytes(28);
  41901. var glyphNames;
  41902. var valid = true;
  41903. var i;
  41904. switch (version) {
  41905. case 0x00010000:
  41906. glyphNames = MacStandardGlyphOrdering;
  41907. break;
  41908. case 0x00020000:
  41909. var numGlyphs = font.getUint16();
  41910. if (numGlyphs !== maxpNumGlyphs) {
  41911. valid = false;
  41912. break;
  41913. }
  41914. var glyphNameIndexes = [];
  41915. for (i = 0; i < numGlyphs; ++i) {
  41916. var index = font.getUint16();
  41917. if (index >= 32768) {
  41918. valid = false;
  41919. break;
  41920. }
  41921. glyphNameIndexes.push(index);
  41922. }
  41923. if (!valid) {
  41924. break;
  41925. }
  41926. var customNames = [];
  41927. var strBuf = [];
  41928. while (font.pos < end) {
  41929. var stringLength = font.getByte();
  41930. strBuf.length = stringLength;
  41931. for (i = 0; i < stringLength; ++i) {
  41932. strBuf[i] = String.fromCharCode(font.getByte());
  41933. }
  41934. customNames.push(strBuf.join(''));
  41935. }
  41936. glyphNames = [];
  41937. for (i = 0; i < numGlyphs; ++i) {
  41938. var j = glyphNameIndexes[i];
  41939. if (j < 258) {
  41940. glyphNames.push(MacStandardGlyphOrdering[j]);
  41941. continue;
  41942. }
  41943. glyphNames.push(customNames[j - 258]);
  41944. }
  41945. break;
  41946. case 0x00030000:
  41947. break;
  41948. default:
  41949. warn('Unknown/unsupported post table version ' + version);
  41950. valid = false;
  41951. if (properties.defaultEncoding) {
  41952. glyphNames = properties.defaultEncoding;
  41953. }
  41954. break;
  41955. }
  41956. properties.glyphNames = glyphNames;
  41957. return valid;
  41958. }
  41959. function readNameTable(nameTable) {
  41960. var start = (font.start ? font.start : 0) + nameTable.offset;
  41961. font.pos = start;
  41962. var names = [
  41963. [],
  41964. []
  41965. ];
  41966. var length = nameTable.length, end = start + length;
  41967. var format = font.getUint16();
  41968. var FORMAT_0_HEADER_LENGTH = 6;
  41969. if (format !== 0 || length < FORMAT_0_HEADER_LENGTH) {
  41970. return names;
  41971. }
  41972. var numRecords = font.getUint16();
  41973. var stringsStart = font.getUint16();
  41974. var records = [];
  41975. var NAME_RECORD_LENGTH = 12;
  41976. var i, ii;
  41977. for (i = 0; i < numRecords && font.pos + NAME_RECORD_LENGTH <= end; i++) {
  41978. var r = {
  41979. platform: font.getUint16(),
  41980. encoding: font.getUint16(),
  41981. language: font.getUint16(),
  41982. name: font.getUint16(),
  41983. length: font.getUint16(),
  41984. offset: font.getUint16()
  41985. };
  41986. if (r.platform === 1 && r.encoding === 0 && r.language === 0 || r.platform === 3 && r.encoding === 1 && r.language === 0x409) {
  41987. records.push(r);
  41988. }
  41989. }
  41990. for (i = 0, ii = records.length; i < ii; i++) {
  41991. var record = records[i];
  41992. if (record.length <= 0) {
  41993. continue;
  41994. }
  41995. var pos = start + stringsStart + record.offset;
  41996. if (pos + record.length > end) {
  41997. continue;
  41998. }
  41999. font.pos = pos;
  42000. var nameIndex = record.name;
  42001. if (record.encoding) {
  42002. var str = '';
  42003. for (var j = 0, jj = record.length; j < jj; j += 2) {
  42004. str += String.fromCharCode(font.getUint16());
  42005. }
  42006. names[1][nameIndex] = str;
  42007. } else {
  42008. names[0][nameIndex] = bytesToString(font.getBytes(record.length));
  42009. }
  42010. }
  42011. return names;
  42012. }
  42013. var TTOpsStackDeltas = [
  42014. 0,
  42015. 0,
  42016. 0,
  42017. 0,
  42018. 0,
  42019. 0,
  42020. 0,
  42021. 0,
  42022. -2,
  42023. -2,
  42024. -2,
  42025. -2,
  42026. 0,
  42027. 0,
  42028. -2,
  42029. -5,
  42030. -1,
  42031. -1,
  42032. -1,
  42033. -1,
  42034. -1,
  42035. -1,
  42036. -1,
  42037. -1,
  42038. 0,
  42039. 0,
  42040. -1,
  42041. 0,
  42042. -1,
  42043. -1,
  42044. -1,
  42045. -1,
  42046. 1,
  42047. -1,
  42048. -999,
  42049. 0,
  42050. 1,
  42051. 0,
  42052. -1,
  42053. -2,
  42054. 0,
  42055. -1,
  42056. -2,
  42057. -1,
  42058. -1,
  42059. 0,
  42060. -1,
  42061. -1,
  42062. 0,
  42063. 0,
  42064. -999,
  42065. -999,
  42066. -1,
  42067. -1,
  42068. -1,
  42069. -1,
  42070. -2,
  42071. -999,
  42072. -2,
  42073. -2,
  42074. -999,
  42075. 0,
  42076. -2,
  42077. -2,
  42078. 0,
  42079. 0,
  42080. -2,
  42081. 0,
  42082. -2,
  42083. 0,
  42084. 0,
  42085. 0,
  42086. -2,
  42087. -1,
  42088. -1,
  42089. 1,
  42090. 1,
  42091. 0,
  42092. 0,
  42093. -1,
  42094. -1,
  42095. -1,
  42096. -1,
  42097. -1,
  42098. -1,
  42099. -1,
  42100. 0,
  42101. 0,
  42102. -1,
  42103. 0,
  42104. -1,
  42105. -1,
  42106. 0,
  42107. -999,
  42108. -1,
  42109. -1,
  42110. -1,
  42111. -1,
  42112. -1,
  42113. -1,
  42114. 0,
  42115. 0,
  42116. 0,
  42117. 0,
  42118. 0,
  42119. 0,
  42120. 0,
  42121. 0,
  42122. 0,
  42123. 0,
  42124. 0,
  42125. 0,
  42126. -2,
  42127. -999,
  42128. -999,
  42129. -999,
  42130. -999,
  42131. -999,
  42132. -1,
  42133. -1,
  42134. -2,
  42135. -2,
  42136. 0,
  42137. 0,
  42138. 0,
  42139. 0,
  42140. -1,
  42141. -1,
  42142. -999,
  42143. -2,
  42144. -2,
  42145. 0,
  42146. 0,
  42147. -1,
  42148. -2,
  42149. -2,
  42150. 0,
  42151. 0,
  42152. 0,
  42153. -1,
  42154. -1,
  42155. -1,
  42156. -2
  42157. ];
  42158. function sanitizeTTProgram(table, ttContext) {
  42159. var data = table.data;
  42160. var i = 0, j, n, b, funcId, pc, lastEndf = 0, lastDeff = 0;
  42161. var stack = [];
  42162. var callstack = [];
  42163. var functionsCalled = [];
  42164. var tooComplexToFollowFunctions = ttContext.tooComplexToFollowFunctions;
  42165. var inFDEF = false, ifLevel = 0, inELSE = 0;
  42166. for (var ii = data.length; i < ii;) {
  42167. var op = data[i++];
  42168. if (op === 0x40) {
  42169. n = data[i++];
  42170. if (inFDEF || inELSE) {
  42171. i += n;
  42172. } else {
  42173. for (j = 0; j < n; j++) {
  42174. stack.push(data[i++]);
  42175. }
  42176. }
  42177. } else if (op === 0x41) {
  42178. n = data[i++];
  42179. if (inFDEF || inELSE) {
  42180. i += n * 2;
  42181. } else {
  42182. for (j = 0; j < n; j++) {
  42183. b = data[i++];
  42184. stack.push(b << 8 | data[i++]);
  42185. }
  42186. }
  42187. } else if ((op & 0xF8) === 0xB0) {
  42188. n = op - 0xB0 + 1;
  42189. if (inFDEF || inELSE) {
  42190. i += n;
  42191. } else {
  42192. for (j = 0; j < n; j++) {
  42193. stack.push(data[i++]);
  42194. }
  42195. }
  42196. } else if ((op & 0xF8) === 0xB8) {
  42197. n = op - 0xB8 + 1;
  42198. if (inFDEF || inELSE) {
  42199. i += n * 2;
  42200. } else {
  42201. for (j = 0; j < n; j++) {
  42202. b = data[i++];
  42203. stack.push(b << 8 | data[i++]);
  42204. }
  42205. }
  42206. } else if (op === 0x2B && !tooComplexToFollowFunctions) {
  42207. if (!inFDEF && !inELSE) {
  42208. funcId = stack[stack.length - 1];
  42209. ttContext.functionsUsed[funcId] = true;
  42210. if (funcId in ttContext.functionsStackDeltas) {
  42211. stack.length += ttContext.functionsStackDeltas[funcId];
  42212. } else if (funcId in ttContext.functionsDefined && functionsCalled.indexOf(funcId) < 0) {
  42213. callstack.push({
  42214. data: data,
  42215. i: i,
  42216. stackTop: stack.length - 1
  42217. });
  42218. functionsCalled.push(funcId);
  42219. pc = ttContext.functionsDefined[funcId];
  42220. if (!pc) {
  42221. warn('TT: CALL non-existent function');
  42222. ttContext.hintsValid = false;
  42223. return;
  42224. }
  42225. data = pc.data;
  42226. i = pc.i;
  42227. }
  42228. }
  42229. } else if (op === 0x2C && !tooComplexToFollowFunctions) {
  42230. if (inFDEF || inELSE) {
  42231. warn('TT: nested FDEFs not allowed');
  42232. tooComplexToFollowFunctions = true;
  42233. }
  42234. inFDEF = true;
  42235. lastDeff = i;
  42236. funcId = stack.pop();
  42237. ttContext.functionsDefined[funcId] = {
  42238. data: data,
  42239. i: i
  42240. };
  42241. } else if (op === 0x2D) {
  42242. if (inFDEF) {
  42243. inFDEF = false;
  42244. lastEndf = i;
  42245. } else {
  42246. pc = callstack.pop();
  42247. if (!pc) {
  42248. warn('TT: ENDF bad stack');
  42249. ttContext.hintsValid = false;
  42250. return;
  42251. }
  42252. funcId = functionsCalled.pop();
  42253. data = pc.data;
  42254. i = pc.i;
  42255. ttContext.functionsStackDeltas[funcId] = stack.length - pc.stackTop;
  42256. }
  42257. } else if (op === 0x89) {
  42258. if (inFDEF || inELSE) {
  42259. warn('TT: nested IDEFs not allowed');
  42260. tooComplexToFollowFunctions = true;
  42261. }
  42262. inFDEF = true;
  42263. lastDeff = i;
  42264. } else if (op === 0x58) {
  42265. ++ifLevel;
  42266. } else if (op === 0x1B) {
  42267. inELSE = ifLevel;
  42268. } else if (op === 0x59) {
  42269. if (inELSE === ifLevel) {
  42270. inELSE = 0;
  42271. }
  42272. --ifLevel;
  42273. } else if (op === 0x1C) {
  42274. if (!inFDEF && !inELSE) {
  42275. var offset = stack[stack.length - 1];
  42276. if (offset > 0) {
  42277. i += offset - 1;
  42278. }
  42279. }
  42280. }
  42281. if (!inFDEF && !inELSE) {
  42282. var stackDelta = op <= 0x8E ? TTOpsStackDeltas[op] : op >= 0xC0 && op <= 0xDF ? -1 : op >= 0xE0 ? -2 : 0;
  42283. if (op >= 0x71 && op <= 0x75) {
  42284. n = stack.pop();
  42285. if (n === n) {
  42286. stackDelta = -n * 2;
  42287. }
  42288. }
  42289. while (stackDelta < 0 && stack.length > 0) {
  42290. stack.pop();
  42291. stackDelta++;
  42292. }
  42293. while (stackDelta > 0) {
  42294. stack.push(NaN);
  42295. stackDelta--;
  42296. }
  42297. }
  42298. }
  42299. ttContext.tooComplexToFollowFunctions = tooComplexToFollowFunctions;
  42300. var content = [data];
  42301. if (i > data.length) {
  42302. content.push(new Uint8Array(i - data.length));
  42303. }
  42304. if (lastDeff > lastEndf) {
  42305. warn('TT: complementing a missing function tail');
  42306. content.push(new Uint8Array([
  42307. 0x22,
  42308. 0x2D
  42309. ]));
  42310. }
  42311. foldTTTable(table, content);
  42312. }
  42313. function checkInvalidFunctions(ttContext, maxFunctionDefs) {
  42314. if (ttContext.tooComplexToFollowFunctions) {
  42315. return;
  42316. }
  42317. if (ttContext.functionsDefined.length > maxFunctionDefs) {
  42318. warn('TT: more functions defined than expected');
  42319. ttContext.hintsValid = false;
  42320. return;
  42321. }
  42322. for (var j = 0, jj = ttContext.functionsUsed.length; j < jj; j++) {
  42323. if (j > maxFunctionDefs) {
  42324. warn('TT: invalid function id: ' + j);
  42325. ttContext.hintsValid = false;
  42326. return;
  42327. }
  42328. if (ttContext.functionsUsed[j] && !ttContext.functionsDefined[j]) {
  42329. warn('TT: undefined function: ' + j);
  42330. ttContext.hintsValid = false;
  42331. return;
  42332. }
  42333. }
  42334. }
  42335. function foldTTTable(table, content) {
  42336. if (content.length > 1) {
  42337. var newLength = 0;
  42338. var j, jj;
  42339. for (j = 0, jj = content.length; j < jj; j++) {
  42340. newLength += content[j].length;
  42341. }
  42342. newLength = newLength + 3 & ~3;
  42343. var result = new Uint8Array(newLength);
  42344. var pos = 0;
  42345. for (j = 0, jj = content.length; j < jj; j++) {
  42346. result.set(content[j], pos);
  42347. pos += content[j].length;
  42348. }
  42349. table.data = result;
  42350. table.length = newLength;
  42351. }
  42352. }
  42353. function sanitizeTTPrograms(fpgm, prep, cvt, maxFunctionDefs) {
  42354. var ttContext = {
  42355. functionsDefined: [],
  42356. functionsUsed: [],
  42357. functionsStackDeltas: [],
  42358. tooComplexToFollowFunctions: false,
  42359. hintsValid: true
  42360. };
  42361. if (fpgm) {
  42362. sanitizeTTProgram(fpgm, ttContext);
  42363. }
  42364. if (prep) {
  42365. sanitizeTTProgram(prep, ttContext);
  42366. }
  42367. if (fpgm) {
  42368. checkInvalidFunctions(ttContext, maxFunctionDefs);
  42369. }
  42370. if (cvt && cvt.length & 1) {
  42371. var cvtData = new Uint8Array(cvt.length + 1);
  42372. cvtData.set(cvt.data);
  42373. cvt.data = cvtData;
  42374. }
  42375. return ttContext.hintsValid;
  42376. }
  42377. font = new Stream(new Uint8Array(font.getBytes()));
  42378. var VALID_TABLES = [
  42379. 'OS/2',
  42380. 'cmap',
  42381. 'head',
  42382. 'hhea',
  42383. 'hmtx',
  42384. 'maxp',
  42385. 'name',
  42386. 'post',
  42387. 'loca',
  42388. 'glyf',
  42389. 'fpgm',
  42390. 'prep',
  42391. 'cvt ',
  42392. 'CFF '
  42393. ];
  42394. var header = readOpenTypeHeader(font);
  42395. var numTables = header.numTables;
  42396. var cff, cffFile;
  42397. var tables = Object.create(null);
  42398. tables['OS/2'] = null;
  42399. tables['cmap'] = null;
  42400. tables['head'] = null;
  42401. tables['hhea'] = null;
  42402. tables['hmtx'] = null;
  42403. tables['maxp'] = null;
  42404. tables['name'] = null;
  42405. tables['post'] = null;
  42406. var table;
  42407. for (var i = 0; i < numTables; i++) {
  42408. table = readTableEntry(font);
  42409. if (VALID_TABLES.indexOf(table.tag) < 0) {
  42410. continue;
  42411. }
  42412. if (table.length === 0) {
  42413. continue;
  42414. }
  42415. tables[table.tag] = table;
  42416. }
  42417. var isTrueType = !tables['CFF '];
  42418. if (!isTrueType) {
  42419. if (header.version === 'OTTO' && properties.type !== 'CIDFontType2' || !tables['head'] || !tables['hhea'] || !tables['maxp'] || !tables['post']) {
  42420. cffFile = new Stream(tables['CFF '].data);
  42421. cff = new CFFFont(cffFile, properties);
  42422. adjustWidths(properties);
  42423. return this.convert(name, cff, properties);
  42424. }
  42425. delete tables['glyf'];
  42426. delete tables['loca'];
  42427. delete tables['fpgm'];
  42428. delete tables['prep'];
  42429. delete tables['cvt '];
  42430. this.isOpenType = true;
  42431. } else {
  42432. if (!tables['loca']) {
  42433. error('Required "loca" table is not found');
  42434. }
  42435. if (!tables['glyf']) {
  42436. warn('Required "glyf" table is not found -- trying to recover.');
  42437. tables['glyf'] = {
  42438. tag: 'glyf',
  42439. data: new Uint8Array(0)
  42440. };
  42441. }
  42442. this.isOpenType = false;
  42443. }
  42444. if (!tables['maxp']) {
  42445. error('Required "maxp" table is not found');
  42446. }
  42447. font.pos = (font.start || 0) + tables['maxp'].offset;
  42448. var version = font.getInt32();
  42449. var numGlyphs = font.getUint16();
  42450. var maxFunctionDefs = 0;
  42451. if (version >= 0x00010000 && tables['maxp'].length >= 22) {
  42452. font.pos += 8;
  42453. var maxZones = font.getUint16();
  42454. if (maxZones > 2) {
  42455. tables['maxp'].data[14] = 0;
  42456. tables['maxp'].data[15] = 2;
  42457. }
  42458. font.pos += 4;
  42459. maxFunctionDefs = font.getUint16();
  42460. }
  42461. var dupFirstEntry = false;
  42462. if (properties.type === 'CIDFontType2' && properties.toUnicode && properties.toUnicode.get(0) > '\u0000') {
  42463. dupFirstEntry = true;
  42464. numGlyphs++;
  42465. tables['maxp'].data[4] = numGlyphs >> 8;
  42466. tables['maxp'].data[5] = numGlyphs & 255;
  42467. }
  42468. var hintsValid = sanitizeTTPrograms(tables['fpgm'], tables['prep'], tables['cvt '], maxFunctionDefs);
  42469. if (!hintsValid) {
  42470. delete tables['fpgm'];
  42471. delete tables['prep'];
  42472. delete tables['cvt '];
  42473. }
  42474. sanitizeMetrics(font, tables['hhea'], tables['hmtx'], numGlyphs);
  42475. if (!tables['head']) {
  42476. error('Required "head" table is not found');
  42477. }
  42478. sanitizeHead(tables['head'], numGlyphs, isTrueType ? tables['loca'].length : 0);
  42479. var missingGlyphs = Object.create(null);
  42480. if (isTrueType) {
  42481. var isGlyphLocationsLong = int16(tables['head'].data[50], tables['head'].data[51]);
  42482. missingGlyphs = sanitizeGlyphLocations(tables['loca'], tables['glyf'], numGlyphs, isGlyphLocationsLong, hintsValid, dupFirstEntry);
  42483. }
  42484. if (!tables['hhea']) {
  42485. error('Required "hhea" table is not found');
  42486. }
  42487. if (tables['hhea'].data[10] === 0 && tables['hhea'].data[11] === 0) {
  42488. tables['hhea'].data[10] = 0xFF;
  42489. tables['hhea'].data[11] = 0xFF;
  42490. }
  42491. var metricsOverride = {
  42492. unitsPerEm: int16(tables['head'].data[18], tables['head'].data[19]),
  42493. yMax: int16(tables['head'].data[42], tables['head'].data[43]),
  42494. yMin: signedInt16(tables['head'].data[38], tables['head'].data[39]),
  42495. ascent: int16(tables['hhea'].data[4], tables['hhea'].data[5]),
  42496. descent: signedInt16(tables['hhea'].data[6], tables['hhea'].data[7])
  42497. };
  42498. this.ascent = metricsOverride.ascent / metricsOverride.unitsPerEm;
  42499. this.descent = metricsOverride.descent / metricsOverride.unitsPerEm;
  42500. if (tables['post']) {
  42501. var valid = readPostScriptTable(tables['post'], properties, numGlyphs);
  42502. if (!valid) {
  42503. tables['post'] = null;
  42504. }
  42505. }
  42506. var charCodeToGlyphId = [], charCode;
  42507. var toUnicode = properties.toUnicode, widths = properties.widths;
  42508. var skipToUnicode = toUnicode instanceof IdentityToUnicodeMap || toUnicode.length === 0x10000;
  42509. function hasGlyph(glyphId, charCode, widthCode) {
  42510. if (!missingGlyphs[glyphId]) {
  42511. return true;
  42512. }
  42513. if (!skipToUnicode && charCode >= 0 && toUnicode.has(charCode)) {
  42514. return true;
  42515. }
  42516. if (widths && widthCode >= 0 && isNum(widths[widthCode])) {
  42517. return true;
  42518. }
  42519. return false;
  42520. }
  42521. if (properties.type === 'CIDFontType2') {
  42522. var cidToGidMap = properties.cidToGidMap || [];
  42523. var isCidToGidMapEmpty = cidToGidMap.length === 0;
  42524. properties.cMap.forEach(function (charCode, cid) {
  42525. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  42526. var glyphId = -1;
  42527. if (isCidToGidMapEmpty) {
  42528. glyphId = cid;
  42529. } else if (cidToGidMap[cid] !== undefined) {
  42530. glyphId = cidToGidMap[cid];
  42531. }
  42532. if (glyphId >= 0 && glyphId < numGlyphs && hasGlyph(glyphId, charCode, cid)) {
  42533. charCodeToGlyphId[charCode] = glyphId;
  42534. }
  42535. });
  42536. if (dupFirstEntry && (isCidToGidMapEmpty || !charCodeToGlyphId[0])) {
  42537. charCodeToGlyphId[0] = numGlyphs - 1;
  42538. }
  42539. } else {
  42540. var cmapTable = readCmapTable(tables['cmap'], font, this.isSymbolicFont, properties.hasEncoding);
  42541. var cmapPlatformId = cmapTable.platformId;
  42542. var cmapEncodingId = cmapTable.encodingId;
  42543. var cmapMappings = cmapTable.mappings;
  42544. var cmapMappingsLength = cmapMappings.length;
  42545. if (properties.hasEncoding && (cmapPlatformId === 3 && cmapEncodingId === 1 || cmapPlatformId === 1 && cmapEncodingId === 0) || cmapPlatformId === -1 && cmapEncodingId === -1 && !!getEncoding(properties.baseEncodingName)) {
  42546. var baseEncoding = [];
  42547. if (properties.baseEncodingName === 'MacRomanEncoding' || properties.baseEncodingName === 'WinAnsiEncoding') {
  42548. baseEncoding = getEncoding(properties.baseEncodingName);
  42549. }
  42550. var glyphsUnicodeMap = getGlyphsUnicode();
  42551. for (charCode = 0; charCode < 256; charCode++) {
  42552. var glyphName, standardGlyphName;
  42553. if (this.differences && charCode in this.differences) {
  42554. glyphName = this.differences[charCode];
  42555. } else if (charCode in baseEncoding && baseEncoding[charCode] !== '') {
  42556. glyphName = baseEncoding[charCode];
  42557. } else {
  42558. glyphName = StandardEncoding[charCode];
  42559. }
  42560. if (!glyphName) {
  42561. continue;
  42562. }
  42563. standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42564. var unicodeOrCharCode, isUnicode = false;
  42565. if (cmapPlatformId === 3 && cmapEncodingId === 1) {
  42566. unicodeOrCharCode = glyphsUnicodeMap[standardGlyphName];
  42567. isUnicode = true;
  42568. } else if (cmapPlatformId === 1 && cmapEncodingId === 0) {
  42569. unicodeOrCharCode = MacRomanEncoding.indexOf(standardGlyphName);
  42570. }
  42571. var found = false;
  42572. for (i = 0; i < cmapMappingsLength; ++i) {
  42573. if (cmapMappings[i].charCode !== unicodeOrCharCode) {
  42574. continue;
  42575. }
  42576. var code = isUnicode ? charCode : unicodeOrCharCode;
  42577. if (hasGlyph(cmapMappings[i].glyphId, code, -1)) {
  42578. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42579. found = true;
  42580. break;
  42581. }
  42582. }
  42583. if (!found && properties.glyphNames) {
  42584. var glyphId = properties.glyphNames.indexOf(glyphName);
  42585. if (glyphId === -1 && standardGlyphName !== glyphName) {
  42586. glyphId = properties.glyphNames.indexOf(standardGlyphName);
  42587. }
  42588. if (glyphId > 0 && hasGlyph(glyphId, -1, -1)) {
  42589. charCodeToGlyphId[charCode] = glyphId;
  42590. found = true;
  42591. }
  42592. }
  42593. if (!found) {
  42594. charCodeToGlyphId[charCode] = 0;
  42595. }
  42596. }
  42597. } else if (cmapPlatformId === 0 && cmapEncodingId === 0) {
  42598. for (i = 0; i < cmapMappingsLength; ++i) {
  42599. charCodeToGlyphId[cmapMappings[i].charCode] = cmapMappings[i].glyphId;
  42600. }
  42601. } else {
  42602. for (i = 0; i < cmapMappingsLength; ++i) {
  42603. charCode = cmapMappings[i].charCode & 0xFF;
  42604. charCodeToGlyphId[charCode] = cmapMappings[i].glyphId;
  42605. }
  42606. }
  42607. }
  42608. if (charCodeToGlyphId.length === 0) {
  42609. charCodeToGlyphId[0] = 0;
  42610. }
  42611. var newMapping = adjustMapping(charCodeToGlyphId, properties);
  42612. this.toFontChar = newMapping.toFontChar;
  42613. tables['cmap'] = {
  42614. tag: 'cmap',
  42615. data: createCmapTable(newMapping.charCodeToGlyphId, numGlyphs)
  42616. };
  42617. if (!tables['OS/2'] || !validateOS2Table(tables['OS/2'])) {
  42618. tables['OS/2'] = {
  42619. tag: 'OS/2',
  42620. data: createOS2Table(properties, newMapping.charCodeToGlyphId, metricsOverride)
  42621. };
  42622. }
  42623. if (!tables['post']) {
  42624. tables['post'] = {
  42625. tag: 'post',
  42626. data: createPostTable(properties)
  42627. };
  42628. }
  42629. if (!isTrueType) {
  42630. try {
  42631. cffFile = new Stream(tables['CFF '].data);
  42632. var parser = new CFFParser(cffFile, properties, SEAC_ANALYSIS_ENABLED);
  42633. cff = parser.parse();
  42634. var compiler = new CFFCompiler(cff);
  42635. tables['CFF '].data = compiler.compile();
  42636. } catch (e) {
  42637. warn('Failed to compile font ' + properties.loadedName);
  42638. }
  42639. }
  42640. if (!tables['name']) {
  42641. tables['name'] = {
  42642. tag: 'name',
  42643. data: createNameTable(this.name)
  42644. };
  42645. } else {
  42646. var namePrototype = readNameTable(tables['name']);
  42647. tables['name'].data = createNameTable(name, namePrototype);
  42648. }
  42649. var builder = new OpenTypeFileBuilder(header.version);
  42650. for (var tableTag in tables) {
  42651. builder.addTable(tableTag, tables[tableTag].data);
  42652. }
  42653. return builder.toArray();
  42654. },
  42655. convert: function Font_convert(fontName, font, properties) {
  42656. properties.fixedPitch = false;
  42657. if (properties.builtInEncoding) {
  42658. adjustToUnicode(properties, properties.builtInEncoding);
  42659. }
  42660. var mapping = font.getGlyphMapping(properties);
  42661. var newMapping = adjustMapping(mapping, properties);
  42662. this.toFontChar = newMapping.toFontChar;
  42663. var numGlyphs = font.numGlyphs;
  42664. function getCharCodes(charCodeToGlyphId, glyphId) {
  42665. var charCodes = null;
  42666. for (var charCode in charCodeToGlyphId) {
  42667. if (glyphId === charCodeToGlyphId[charCode]) {
  42668. if (!charCodes) {
  42669. charCodes = [];
  42670. }
  42671. charCodes.push(charCode | 0);
  42672. }
  42673. }
  42674. return charCodes;
  42675. }
  42676. function createCharCode(charCodeToGlyphId, glyphId) {
  42677. for (var charCode in charCodeToGlyphId) {
  42678. if (glyphId === charCodeToGlyphId[charCode]) {
  42679. return charCode | 0;
  42680. }
  42681. }
  42682. newMapping.charCodeToGlyphId[newMapping.nextAvailableFontCharCode] = glyphId;
  42683. return newMapping.nextAvailableFontCharCode++;
  42684. }
  42685. var seacs = font.seacs;
  42686. if (SEAC_ANALYSIS_ENABLED && seacs && seacs.length) {
  42687. var matrix = properties.fontMatrix || FONT_IDENTITY_MATRIX;
  42688. var charset = font.getCharset();
  42689. var seacMap = Object.create(null);
  42690. for (var glyphId in seacs) {
  42691. glyphId |= 0;
  42692. var seac = seacs[glyphId];
  42693. var baseGlyphName = StandardEncoding[seac[2]];
  42694. var accentGlyphName = StandardEncoding[seac[3]];
  42695. var baseGlyphId = charset.indexOf(baseGlyphName);
  42696. var accentGlyphId = charset.indexOf(accentGlyphName);
  42697. if (baseGlyphId < 0 || accentGlyphId < 0) {
  42698. continue;
  42699. }
  42700. var accentOffset = {
  42701. x: seac[0] * matrix[0] + seac[1] * matrix[2] + matrix[4],
  42702. y: seac[0] * matrix[1] + seac[1] * matrix[3] + matrix[5]
  42703. };
  42704. var charCodes = getCharCodes(mapping, glyphId);
  42705. if (!charCodes) {
  42706. continue;
  42707. }
  42708. for (var i = 0, ii = charCodes.length; i < ii; i++) {
  42709. var charCode = charCodes[i];
  42710. var charCodeToGlyphId = newMapping.charCodeToGlyphId;
  42711. var baseFontCharCode = createCharCode(charCodeToGlyphId, baseGlyphId);
  42712. var accentFontCharCode = createCharCode(charCodeToGlyphId, accentGlyphId);
  42713. seacMap[charCode] = {
  42714. baseFontCharCode: baseFontCharCode,
  42715. accentFontCharCode: accentFontCharCode,
  42716. accentOffset: accentOffset
  42717. };
  42718. }
  42719. }
  42720. properties.seacMap = seacMap;
  42721. }
  42722. var unitsPerEm = 1 / (properties.fontMatrix || FONT_IDENTITY_MATRIX)[0];
  42723. var builder = new OpenTypeFileBuilder('\x4F\x54\x54\x4F');
  42724. builder.addTable('CFF ', font.data);
  42725. builder.addTable('OS/2', createOS2Table(properties, newMapping.charCodeToGlyphId));
  42726. builder.addTable('cmap', createCmapTable(newMapping.charCodeToGlyphId, numGlyphs));
  42727. 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');
  42728. 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));
  42729. builder.addTable('hmtx', function fontFieldsHmtx() {
  42730. var charstrings = font.charstrings;
  42731. var cffWidths = font.cff ? font.cff.widths : null;
  42732. var hmtx = '\x00\x00\x00\x00';
  42733. for (var i = 1, ii = numGlyphs; i < ii; i++) {
  42734. var width = 0;
  42735. if (charstrings) {
  42736. var charstring = charstrings[i - 1];
  42737. width = 'width' in charstring ? charstring.width : 0;
  42738. } else if (cffWidths) {
  42739. width = Math.ceil(cffWidths[i] || 0);
  42740. }
  42741. hmtx += string16(width) + string16(0);
  42742. }
  42743. return hmtx;
  42744. }());
  42745. builder.addTable('maxp', '\x00\x00\x50\x00' + string16(numGlyphs));
  42746. builder.addTable('name', createNameTable(fontName));
  42747. builder.addTable('post', createPostTable(properties));
  42748. return builder.toArray();
  42749. },
  42750. get spaceWidth() {
  42751. if ('_shadowWidth' in this) {
  42752. return this._shadowWidth;
  42753. }
  42754. var possibleSpaceReplacements = [
  42755. 'space',
  42756. 'minus',
  42757. 'one',
  42758. 'i',
  42759. 'I'
  42760. ];
  42761. var width;
  42762. for (var i = 0, ii = possibleSpaceReplacements.length; i < ii; i++) {
  42763. var glyphName = possibleSpaceReplacements[i];
  42764. if (glyphName in this.widths) {
  42765. width = this.widths[glyphName];
  42766. break;
  42767. }
  42768. var glyphsUnicodeMap = getGlyphsUnicode();
  42769. var glyphUnicode = glyphsUnicodeMap[glyphName];
  42770. var charcode = 0;
  42771. if (this.composite) {
  42772. if (this.cMap.contains(glyphUnicode)) {
  42773. charcode = this.cMap.lookup(glyphUnicode);
  42774. }
  42775. }
  42776. if (!charcode && this.toUnicode) {
  42777. charcode = this.toUnicode.charCodeOf(glyphUnicode);
  42778. }
  42779. if (charcode <= 0) {
  42780. charcode = glyphUnicode;
  42781. }
  42782. width = this.widths[charcode];
  42783. if (width) {
  42784. break;
  42785. }
  42786. }
  42787. width = width || this.defaultWidth;
  42788. this._shadowWidth = width;
  42789. return width;
  42790. },
  42791. charToGlyph: function Font_charToGlyph(charcode, isSpace) {
  42792. var fontCharCode, width, operatorListId;
  42793. var widthCode = charcode;
  42794. if (this.cMap && this.cMap.contains(charcode)) {
  42795. widthCode = this.cMap.lookup(charcode);
  42796. }
  42797. width = this.widths[widthCode];
  42798. width = isNum(width) ? width : this.defaultWidth;
  42799. var vmetric = this.vmetrics && this.vmetrics[widthCode];
  42800. var unicode = this.toUnicode.get(charcode) || charcode;
  42801. if (typeof unicode === 'number') {
  42802. unicode = String.fromCharCode(unicode);
  42803. }
  42804. var isInFont = charcode in this.toFontChar;
  42805. fontCharCode = this.toFontChar[charcode] || charcode;
  42806. if (this.missingFile) {
  42807. fontCharCode = mapSpecialUnicodeValues(fontCharCode);
  42808. }
  42809. if (this.isType3Font) {
  42810. operatorListId = fontCharCode;
  42811. }
  42812. var accent = null;
  42813. if (this.seacMap && this.seacMap[charcode]) {
  42814. isInFont = true;
  42815. var seac = this.seacMap[charcode];
  42816. fontCharCode = seac.baseFontCharCode;
  42817. accent = {
  42818. fontChar: String.fromCharCode(seac.accentFontCharCode),
  42819. offset: seac.accentOffset
  42820. };
  42821. }
  42822. var fontChar = String.fromCharCode(fontCharCode);
  42823. var glyph = this.glyphCache[charcode];
  42824. if (!glyph || !glyph.matchesForCache(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont)) {
  42825. glyph = new Glyph(fontChar, unicode, accent, width, vmetric, operatorListId, isSpace, isInFont);
  42826. this.glyphCache[charcode] = glyph;
  42827. }
  42828. return glyph;
  42829. },
  42830. charsToGlyphs: function Font_charsToGlyphs(chars) {
  42831. var charsCache = this.charsCache;
  42832. var glyphs, glyph, charcode;
  42833. if (charsCache) {
  42834. glyphs = charsCache[chars];
  42835. if (glyphs) {
  42836. return glyphs;
  42837. }
  42838. }
  42839. if (!charsCache) {
  42840. charsCache = this.charsCache = Object.create(null);
  42841. }
  42842. glyphs = [];
  42843. var charsCacheKey = chars;
  42844. var i = 0, ii;
  42845. if (this.cMap) {
  42846. var c = Object.create(null);
  42847. while (i < chars.length) {
  42848. this.cMap.readCharCode(chars, i, c);
  42849. charcode = c.charcode;
  42850. var length = c.length;
  42851. i += length;
  42852. var isSpace = length === 1 && chars.charCodeAt(i - 1) === 0x20;
  42853. glyph = this.charToGlyph(charcode, isSpace);
  42854. glyphs.push(glyph);
  42855. }
  42856. } else {
  42857. for (i = 0, ii = chars.length; i < ii; ++i) {
  42858. charcode = chars.charCodeAt(i);
  42859. glyph = this.charToGlyph(charcode, charcode === 0x20);
  42860. glyphs.push(glyph);
  42861. }
  42862. }
  42863. return charsCache[charsCacheKey] = glyphs;
  42864. }
  42865. };
  42866. return Font;
  42867. }();
  42868. var ErrorFont = function ErrorFontClosure() {
  42869. function ErrorFont(error) {
  42870. this.error = error;
  42871. this.loadedName = 'g_font_error';
  42872. this.loading = false;
  42873. }
  42874. ErrorFont.prototype = {
  42875. charsToGlyphs: function ErrorFont_charsToGlyphs() {
  42876. return [];
  42877. },
  42878. exportData: function ErrorFont_exportData() {
  42879. return { error: this.error };
  42880. }
  42881. };
  42882. return ErrorFont;
  42883. }();
  42884. function type1FontGlyphMapping(properties, builtInEncoding, glyphNames) {
  42885. var charCodeToGlyphId = Object.create(null);
  42886. var glyphId, charCode, baseEncoding;
  42887. if (properties.baseEncodingName) {
  42888. baseEncoding = getEncoding(properties.baseEncodingName);
  42889. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  42890. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  42891. if (glyphId >= 0) {
  42892. charCodeToGlyphId[charCode] = glyphId;
  42893. } else {
  42894. charCodeToGlyphId[charCode] = 0;
  42895. }
  42896. }
  42897. } else if (!!(properties.flags & FontFlags.Symbolic)) {
  42898. for (charCode in builtInEncoding) {
  42899. charCodeToGlyphId[charCode] = builtInEncoding[charCode];
  42900. }
  42901. } else {
  42902. baseEncoding = StandardEncoding;
  42903. for (charCode = 0; charCode < baseEncoding.length; charCode++) {
  42904. glyphId = glyphNames.indexOf(baseEncoding[charCode]);
  42905. if (glyphId >= 0) {
  42906. charCodeToGlyphId[charCode] = glyphId;
  42907. } else {
  42908. charCodeToGlyphId[charCode] = 0;
  42909. }
  42910. }
  42911. }
  42912. var differences = properties.differences, glyphsUnicodeMap;
  42913. if (differences) {
  42914. for (charCode in differences) {
  42915. var glyphName = differences[charCode];
  42916. glyphId = glyphNames.indexOf(glyphName);
  42917. if (glyphId === -1) {
  42918. if (!glyphsUnicodeMap) {
  42919. glyphsUnicodeMap = getGlyphsUnicode();
  42920. }
  42921. var standardGlyphName = recoverGlyphName(glyphName, glyphsUnicodeMap);
  42922. if (standardGlyphName !== glyphName) {
  42923. glyphId = glyphNames.indexOf(standardGlyphName);
  42924. }
  42925. }
  42926. if (glyphId >= 0) {
  42927. charCodeToGlyphId[charCode] = glyphId;
  42928. } else {
  42929. charCodeToGlyphId[charCode] = 0;
  42930. }
  42931. }
  42932. }
  42933. return charCodeToGlyphId;
  42934. }
  42935. var Type1Font = function Type1FontClosure() {
  42936. function findBlock(streamBytes, signature, startIndex) {
  42937. var streamBytesLength = streamBytes.length;
  42938. var signatureLength = signature.length;
  42939. var scanLength = streamBytesLength - signatureLength;
  42940. var i = startIndex, j, found = false;
  42941. while (i < scanLength) {
  42942. j = 0;
  42943. while (j < signatureLength && streamBytes[i + j] === signature[j]) {
  42944. j++;
  42945. }
  42946. if (j >= signatureLength) {
  42947. i += j;
  42948. while (i < streamBytesLength && isSpace(streamBytes[i])) {
  42949. i++;
  42950. }
  42951. found = true;
  42952. break;
  42953. }
  42954. i++;
  42955. }
  42956. return {
  42957. found: found,
  42958. length: i
  42959. };
  42960. }
  42961. function getHeaderBlock(stream, suggestedLength) {
  42962. var EEXEC_SIGNATURE = [
  42963. 0x65,
  42964. 0x65,
  42965. 0x78,
  42966. 0x65,
  42967. 0x63
  42968. ];
  42969. var streamStartPos = stream.pos;
  42970. var headerBytes, headerBytesLength, block;
  42971. try {
  42972. headerBytes = stream.getBytes(suggestedLength);
  42973. headerBytesLength = headerBytes.length;
  42974. } catch (ex) {
  42975. if (ex instanceof MissingDataException) {
  42976. throw ex;
  42977. }
  42978. }
  42979. if (headerBytesLength === suggestedLength) {
  42980. block = findBlock(headerBytes, EEXEC_SIGNATURE, suggestedLength - 2 * EEXEC_SIGNATURE.length);
  42981. if (block.found && block.length === suggestedLength) {
  42982. return {
  42983. stream: new Stream(headerBytes),
  42984. length: suggestedLength
  42985. };
  42986. }
  42987. }
  42988. warn('Invalid "Length1" property in Type1 font -- trying to recover.');
  42989. stream.pos = streamStartPos;
  42990. var SCAN_BLOCK_LENGTH = 2048;
  42991. var actualLength;
  42992. while (true) {
  42993. var scanBytes = stream.peekBytes(SCAN_BLOCK_LENGTH);
  42994. block = findBlock(scanBytes, EEXEC_SIGNATURE, 0);
  42995. if (block.length === 0) {
  42996. break;
  42997. }
  42998. stream.pos += block.length;
  42999. if (block.found) {
  43000. actualLength = stream.pos - streamStartPos;
  43001. break;
  43002. }
  43003. }
  43004. stream.pos = streamStartPos;
  43005. if (actualLength) {
  43006. return {
  43007. stream: new Stream(stream.getBytes(actualLength)),
  43008. length: actualLength
  43009. };
  43010. }
  43011. warn('Unable to recover "Length1" property in Type1 font -- using as is.');
  43012. return {
  43013. stream: new Stream(stream.getBytes(suggestedLength)),
  43014. length: suggestedLength
  43015. };
  43016. }
  43017. function getEexecBlock(stream, suggestedLength) {
  43018. var eexecBytes = stream.getBytes();
  43019. return {
  43020. stream: new Stream(eexecBytes),
  43021. length: eexecBytes.length
  43022. };
  43023. }
  43024. function Type1Font(name, file, properties) {
  43025. var PFB_HEADER_SIZE = 6;
  43026. var headerBlockLength = properties.length1;
  43027. var eexecBlockLength = properties.length2;
  43028. var pfbHeader = file.peekBytes(PFB_HEADER_SIZE);
  43029. var pfbHeaderPresent = pfbHeader[0] === 0x80 && pfbHeader[1] === 0x01;
  43030. if (pfbHeaderPresent) {
  43031. file.skip(PFB_HEADER_SIZE);
  43032. headerBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43033. }
  43034. var headerBlock = getHeaderBlock(file, headerBlockLength);
  43035. headerBlockLength = headerBlock.length;
  43036. var headerBlockParser = new Type1Parser(headerBlock.stream, false, SEAC_ANALYSIS_ENABLED);
  43037. headerBlockParser.extractFontHeader(properties);
  43038. if (pfbHeaderPresent) {
  43039. pfbHeader = file.getBytes(PFB_HEADER_SIZE);
  43040. eexecBlockLength = pfbHeader[5] << 24 | pfbHeader[4] << 16 | pfbHeader[3] << 8 | pfbHeader[2];
  43041. }
  43042. var eexecBlock = getEexecBlock(file, eexecBlockLength);
  43043. eexecBlockLength = eexecBlock.length;
  43044. var eexecBlockParser = new Type1Parser(eexecBlock.stream, true, SEAC_ANALYSIS_ENABLED);
  43045. var data = eexecBlockParser.extractFontProgram();
  43046. for (var info in data.properties) {
  43047. properties[info] = data.properties[info];
  43048. }
  43049. var charstrings = data.charstrings;
  43050. var type2Charstrings = this.getType2Charstrings(charstrings);
  43051. var subrs = this.getType2Subrs(data.subrs);
  43052. this.charstrings = charstrings;
  43053. this.data = this.wrap(name, type2Charstrings, this.charstrings, subrs, properties);
  43054. this.seacs = this.getSeacs(data.charstrings);
  43055. }
  43056. Type1Font.prototype = {
  43057. get numGlyphs() {
  43058. return this.charstrings.length + 1;
  43059. },
  43060. getCharset: function Type1Font_getCharset() {
  43061. var charset = ['.notdef'];
  43062. var charstrings = this.charstrings;
  43063. for (var glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43064. charset.push(charstrings[glyphId].glyphName);
  43065. }
  43066. return charset;
  43067. },
  43068. getGlyphMapping: function Type1Font_getGlyphMapping(properties) {
  43069. var charstrings = this.charstrings;
  43070. var glyphNames = ['.notdef'], glyphId;
  43071. for (glyphId = 0; glyphId < charstrings.length; glyphId++) {
  43072. glyphNames.push(charstrings[glyphId].glyphName);
  43073. }
  43074. var encoding = properties.builtInEncoding;
  43075. if (encoding) {
  43076. var builtInEncoding = Object.create(null);
  43077. for (var charCode in encoding) {
  43078. glyphId = glyphNames.indexOf(encoding[charCode]);
  43079. if (glyphId >= 0) {
  43080. builtInEncoding[charCode] = glyphId;
  43081. }
  43082. }
  43083. }
  43084. return type1FontGlyphMapping(properties, builtInEncoding, glyphNames);
  43085. },
  43086. getSeacs: function Type1Font_getSeacs(charstrings) {
  43087. var i, ii;
  43088. var seacMap = [];
  43089. for (i = 0, ii = charstrings.length; i < ii; i++) {
  43090. var charstring = charstrings[i];
  43091. if (charstring.seac) {
  43092. seacMap[i + 1] = charstring.seac;
  43093. }
  43094. }
  43095. return seacMap;
  43096. },
  43097. getType2Charstrings: function Type1Font_getType2Charstrings(type1Charstrings) {
  43098. var type2Charstrings = [];
  43099. for (var i = 0, ii = type1Charstrings.length; i < ii; i++) {
  43100. type2Charstrings.push(type1Charstrings[i].charstring);
  43101. }
  43102. return type2Charstrings;
  43103. },
  43104. getType2Subrs: function Type1Font_getType2Subrs(type1Subrs) {
  43105. var bias = 0;
  43106. var count = type1Subrs.length;
  43107. if (count < 1133) {
  43108. bias = 107;
  43109. } else if (count < 33769) {
  43110. bias = 1131;
  43111. } else {
  43112. bias = 32768;
  43113. }
  43114. var type2Subrs = [];
  43115. var i;
  43116. for (i = 0; i < bias; i++) {
  43117. type2Subrs.push([0x0B]);
  43118. }
  43119. for (i = 0; i < count; i++) {
  43120. type2Subrs.push(type1Subrs[i]);
  43121. }
  43122. return type2Subrs;
  43123. },
  43124. wrap: function Type1Font_wrap(name, glyphs, charstrings, subrs, properties) {
  43125. var cff = new CFF();
  43126. cff.header = new CFFHeader(1, 0, 4, 4);
  43127. cff.names = [name];
  43128. var topDict = new CFFTopDict();
  43129. topDict.setByName('version', 391);
  43130. topDict.setByName('Notice', 392);
  43131. topDict.setByName('FullName', 393);
  43132. topDict.setByName('FamilyName', 394);
  43133. topDict.setByName('Weight', 395);
  43134. topDict.setByName('Encoding', null);
  43135. topDict.setByName('FontMatrix', properties.fontMatrix);
  43136. topDict.setByName('FontBBox', properties.bbox);
  43137. topDict.setByName('charset', null);
  43138. topDict.setByName('CharStrings', null);
  43139. topDict.setByName('Private', null);
  43140. cff.topDict = topDict;
  43141. var strings = new CFFStrings();
  43142. strings.add('Version 0.11');
  43143. strings.add('See original notice');
  43144. strings.add(name);
  43145. strings.add(name);
  43146. strings.add('Medium');
  43147. cff.strings = strings;
  43148. cff.globalSubrIndex = new CFFIndex();
  43149. var count = glyphs.length;
  43150. var charsetArray = [0];
  43151. var i, ii;
  43152. for (i = 0; i < count; i++) {
  43153. var index = CFFStandardStrings.indexOf(charstrings[i].glyphName);
  43154. if (index === -1) {
  43155. index = 0;
  43156. }
  43157. charsetArray.push(index >> 8 & 0xff, index & 0xff);
  43158. }
  43159. cff.charset = new CFFCharset(false, 0, [], charsetArray);
  43160. var charStringsIndex = new CFFIndex();
  43161. charStringsIndex.add([
  43162. 0x8B,
  43163. 0x0E
  43164. ]);
  43165. for (i = 0; i < count; i++) {
  43166. var glyph = glyphs[i];
  43167. if (glyph.length === 0) {
  43168. charStringsIndex.add([
  43169. 0x8B,
  43170. 0x0E
  43171. ]);
  43172. continue;
  43173. }
  43174. charStringsIndex.add(glyph);
  43175. }
  43176. cff.charStrings = charStringsIndex;
  43177. var privateDict = new CFFPrivateDict();
  43178. privateDict.setByName('Subrs', null);
  43179. var fields = [
  43180. 'BlueValues',
  43181. 'OtherBlues',
  43182. 'FamilyBlues',
  43183. 'FamilyOtherBlues',
  43184. 'StemSnapH',
  43185. 'StemSnapV',
  43186. 'BlueShift',
  43187. 'BlueFuzz',
  43188. 'BlueScale',
  43189. 'LanguageGroup',
  43190. 'ExpansionFactor',
  43191. 'ForceBold',
  43192. 'StdHW',
  43193. 'StdVW'
  43194. ];
  43195. for (i = 0, ii = fields.length; i < ii; i++) {
  43196. var field = fields[i];
  43197. if (!(field in properties.privateData)) {
  43198. continue;
  43199. }
  43200. var value = properties.privateData[field];
  43201. if (isArray(value)) {
  43202. for (var j = value.length - 1; j > 0; j--) {
  43203. value[j] -= value[j - 1];
  43204. }
  43205. }
  43206. privateDict.setByName(field, value);
  43207. }
  43208. cff.topDict.privateDict = privateDict;
  43209. var subrIndex = new CFFIndex();
  43210. for (i = 0, ii = subrs.length; i < ii; i++) {
  43211. subrIndex.add(subrs[i]);
  43212. }
  43213. privateDict.subrsIndex = subrIndex;
  43214. var compiler = new CFFCompiler(cff);
  43215. return compiler.compile();
  43216. }
  43217. };
  43218. return Type1Font;
  43219. }();
  43220. var CFFFont = function CFFFontClosure() {
  43221. function CFFFont(file, properties) {
  43222. this.properties = properties;
  43223. var parser = new CFFParser(file, properties, SEAC_ANALYSIS_ENABLED);
  43224. this.cff = parser.parse();
  43225. var compiler = new CFFCompiler(this.cff);
  43226. this.seacs = this.cff.seacs;
  43227. try {
  43228. this.data = compiler.compile();
  43229. } catch (e) {
  43230. warn('Failed to compile font ' + properties.loadedName);
  43231. this.data = file;
  43232. }
  43233. }
  43234. CFFFont.prototype = {
  43235. get numGlyphs() {
  43236. return this.cff.charStrings.count;
  43237. },
  43238. getCharset: function CFFFont_getCharset() {
  43239. return this.cff.charset.charset;
  43240. },
  43241. getGlyphMapping: function CFFFont_getGlyphMapping() {
  43242. var cff = this.cff;
  43243. var properties = this.properties;
  43244. var charsets = cff.charset.charset;
  43245. var charCodeToGlyphId;
  43246. var glyphId;
  43247. if (properties.composite) {
  43248. charCodeToGlyphId = Object.create(null);
  43249. if (cff.isCIDFont) {
  43250. for (glyphId = 0; glyphId < charsets.length; glyphId++) {
  43251. var cid = charsets[glyphId];
  43252. var charCode = properties.cMap.charCodeOf(cid);
  43253. charCodeToGlyphId[charCode] = glyphId;
  43254. }
  43255. } else {
  43256. for (glyphId = 0; glyphId < cff.charStrings.count; glyphId++) {
  43257. charCodeToGlyphId[glyphId] = glyphId;
  43258. }
  43259. }
  43260. return charCodeToGlyphId;
  43261. }
  43262. var encoding = cff.encoding ? cff.encoding.encoding : null;
  43263. charCodeToGlyphId = type1FontGlyphMapping(properties, encoding, charsets);
  43264. return charCodeToGlyphId;
  43265. }
  43266. };
  43267. return CFFFont;
  43268. }();
  43269. (function checkSeacSupport() {
  43270. if (typeof navigator !== 'undefined' && /Windows/.test(navigator.userAgent)) {
  43271. SEAC_ANALYSIS_ENABLED = true;
  43272. }
  43273. }());
  43274. (function checkChromeWindows() {
  43275. if (typeof navigator !== 'undefined' && /Windows.*Chrome/.test(navigator.userAgent)) {
  43276. SKIP_PRIVATE_USE_RANGE_F000_TO_F01F = true;
  43277. }
  43278. }());
  43279. exports.ErrorFont = ErrorFont;
  43280. exports.Font = Font;
  43281. exports.FontFlags = FontFlags;
  43282. exports.IdentityToUnicodeMap = IdentityToUnicodeMap;
  43283. exports.ToUnicodeMap = ToUnicodeMap;
  43284. exports.getFontType = getFontType;
  43285. }));
  43286. (function (root, factory) {
  43287. factory(root.pdfjsCorePsParser = {}, root.pdfjsSharedUtil, root.pdfjsCoreParser);
  43288. }(this, function (exports, sharedUtil, coreParser) {
  43289. var error = sharedUtil.error;
  43290. var isSpace = sharedUtil.isSpace;
  43291. var EOF = coreParser.EOF;
  43292. var PostScriptParser = function PostScriptParserClosure() {
  43293. function PostScriptParser(lexer) {
  43294. this.lexer = lexer;
  43295. this.operators = [];
  43296. this.token = null;
  43297. this.prev = null;
  43298. }
  43299. PostScriptParser.prototype = {
  43300. nextToken: function PostScriptParser_nextToken() {
  43301. this.prev = this.token;
  43302. this.token = this.lexer.getToken();
  43303. },
  43304. accept: function PostScriptParser_accept(type) {
  43305. if (this.token.type === type) {
  43306. this.nextToken();
  43307. return true;
  43308. }
  43309. return false;
  43310. },
  43311. expect: function PostScriptParser_expect(type) {
  43312. if (this.accept(type)) {
  43313. return true;
  43314. }
  43315. error('Unexpected symbol: found ' + this.token.type + ' expected ' + type + '.');
  43316. },
  43317. parse: function PostScriptParser_parse() {
  43318. this.nextToken();
  43319. this.expect(PostScriptTokenTypes.LBRACE);
  43320. this.parseBlock();
  43321. this.expect(PostScriptTokenTypes.RBRACE);
  43322. return this.operators;
  43323. },
  43324. parseBlock: function PostScriptParser_parseBlock() {
  43325. while (true) {
  43326. if (this.accept(PostScriptTokenTypes.NUMBER)) {
  43327. this.operators.push(this.prev.value);
  43328. } else if (this.accept(PostScriptTokenTypes.OPERATOR)) {
  43329. this.operators.push(this.prev.value);
  43330. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43331. this.parseCondition();
  43332. } else {
  43333. return;
  43334. }
  43335. }
  43336. },
  43337. parseCondition: function PostScriptParser_parseCondition() {
  43338. var conditionLocation = this.operators.length;
  43339. this.operators.push(null, null);
  43340. this.parseBlock();
  43341. this.expect(PostScriptTokenTypes.RBRACE);
  43342. if (this.accept(PostScriptTokenTypes.IF)) {
  43343. this.operators[conditionLocation] = this.operators.length;
  43344. this.operators[conditionLocation + 1] = 'jz';
  43345. } else if (this.accept(PostScriptTokenTypes.LBRACE)) {
  43346. var jumpLocation = this.operators.length;
  43347. this.operators.push(null, null);
  43348. var endOfTrue = this.operators.length;
  43349. this.parseBlock();
  43350. this.expect(PostScriptTokenTypes.RBRACE);
  43351. this.expect(PostScriptTokenTypes.IFELSE);
  43352. this.operators[jumpLocation] = this.operators.length;
  43353. this.operators[jumpLocation + 1] = 'j';
  43354. this.operators[conditionLocation] = endOfTrue;
  43355. this.operators[conditionLocation + 1] = 'jz';
  43356. } else {
  43357. error('PS Function: error parsing conditional.');
  43358. }
  43359. }
  43360. };
  43361. return PostScriptParser;
  43362. }();
  43363. var PostScriptTokenTypes = {
  43364. LBRACE: 0,
  43365. RBRACE: 1,
  43366. NUMBER: 2,
  43367. OPERATOR: 3,
  43368. IF: 4,
  43369. IFELSE: 5
  43370. };
  43371. var PostScriptToken = function PostScriptTokenClosure() {
  43372. function PostScriptToken(type, value) {
  43373. this.type = type;
  43374. this.value = value;
  43375. }
  43376. var opCache = Object.create(null);
  43377. PostScriptToken.getOperator = function PostScriptToken_getOperator(op) {
  43378. var opValue = opCache[op];
  43379. if (opValue) {
  43380. return opValue;
  43381. }
  43382. return opCache[op] = new PostScriptToken(PostScriptTokenTypes.OPERATOR, op);
  43383. };
  43384. PostScriptToken.LBRACE = new PostScriptToken(PostScriptTokenTypes.LBRACE, '{');
  43385. PostScriptToken.RBRACE = new PostScriptToken(PostScriptTokenTypes.RBRACE, '}');
  43386. PostScriptToken.IF = new PostScriptToken(PostScriptTokenTypes.IF, 'IF');
  43387. PostScriptToken.IFELSE = new PostScriptToken(PostScriptTokenTypes.IFELSE, 'IFELSE');
  43388. return PostScriptToken;
  43389. }();
  43390. var PostScriptLexer = function PostScriptLexerClosure() {
  43391. function PostScriptLexer(stream) {
  43392. this.stream = stream;
  43393. this.nextChar();
  43394. this.strBuf = [];
  43395. }
  43396. PostScriptLexer.prototype = {
  43397. nextChar: function PostScriptLexer_nextChar() {
  43398. return this.currentChar = this.stream.getByte();
  43399. },
  43400. getToken: function PostScriptLexer_getToken() {
  43401. var comment = false;
  43402. var ch = this.currentChar;
  43403. while (true) {
  43404. if (ch < 0) {
  43405. return EOF;
  43406. }
  43407. if (comment) {
  43408. if (ch === 0x0A || ch === 0x0D) {
  43409. comment = false;
  43410. }
  43411. } else if (ch === 0x25) {
  43412. comment = true;
  43413. } else if (!isSpace(ch)) {
  43414. break;
  43415. }
  43416. ch = this.nextChar();
  43417. }
  43418. switch (ch | 0) {
  43419. case 0x30:
  43420. case 0x31:
  43421. case 0x32:
  43422. case 0x33:
  43423. case 0x34:
  43424. case 0x35:
  43425. case 0x36:
  43426. case 0x37:
  43427. case 0x38:
  43428. case 0x39:
  43429. case 0x2B:
  43430. case 0x2D:
  43431. case 0x2E:
  43432. return new PostScriptToken(PostScriptTokenTypes.NUMBER, this.getNumber());
  43433. case 0x7B:
  43434. this.nextChar();
  43435. return PostScriptToken.LBRACE;
  43436. case 0x7D:
  43437. this.nextChar();
  43438. return PostScriptToken.RBRACE;
  43439. }
  43440. var strBuf = this.strBuf;
  43441. strBuf.length = 0;
  43442. strBuf[0] = String.fromCharCode(ch);
  43443. while ((ch = this.nextChar()) >= 0 && (ch >= 0x41 && ch <= 0x5A || ch >= 0x61 && ch <= 0x7A)) {
  43444. strBuf.push(String.fromCharCode(ch));
  43445. }
  43446. var str = strBuf.join('');
  43447. switch (str.toLowerCase()) {
  43448. case 'if':
  43449. return PostScriptToken.IF;
  43450. case 'ifelse':
  43451. return PostScriptToken.IFELSE;
  43452. default:
  43453. return PostScriptToken.getOperator(str);
  43454. }
  43455. },
  43456. getNumber: function PostScriptLexer_getNumber() {
  43457. var ch = this.currentChar;
  43458. var strBuf = this.strBuf;
  43459. strBuf.length = 0;
  43460. strBuf[0] = String.fromCharCode(ch);
  43461. while ((ch = this.nextChar()) >= 0) {
  43462. if (ch >= 0x30 && ch <= 0x39 || ch === 0x2D || ch === 0x2E) {
  43463. strBuf.push(String.fromCharCode(ch));
  43464. } else {
  43465. break;
  43466. }
  43467. }
  43468. var value = parseFloat(strBuf.join(''));
  43469. if (isNaN(value)) {
  43470. error('Invalid floating point number: ' + value);
  43471. }
  43472. return value;
  43473. }
  43474. };
  43475. return PostScriptLexer;
  43476. }();
  43477. exports.PostScriptLexer = PostScriptLexer;
  43478. exports.PostScriptParser = PostScriptParser;
  43479. }));
  43480. (function (root, factory) {
  43481. factory(root.pdfjsDisplayCanvas = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayPatternHelper, root.pdfjsDisplayWebGL);
  43482. }(this, function (exports, sharedUtil, displayDOMUtils, displayPatternHelper, displayWebGL) {
  43483. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  43484. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  43485. var ImageKind = sharedUtil.ImageKind;
  43486. var OPS = sharedUtil.OPS;
  43487. var TextRenderingMode = sharedUtil.TextRenderingMode;
  43488. var Uint32ArrayView = sharedUtil.Uint32ArrayView;
  43489. var Util = sharedUtil.Util;
  43490. var assert = sharedUtil.assert;
  43491. var info = sharedUtil.info;
  43492. var isNum = sharedUtil.isNum;
  43493. var isArray = sharedUtil.isArray;
  43494. var isLittleEndian = sharedUtil.isLittleEndian;
  43495. var error = sharedUtil.error;
  43496. var shadow = sharedUtil.shadow;
  43497. var warn = sharedUtil.warn;
  43498. var TilingPattern = displayPatternHelper.TilingPattern;
  43499. var getShadingPatternFromIR = displayPatternHelper.getShadingPatternFromIR;
  43500. var WebGLUtils = displayWebGL.WebGLUtils;
  43501. var hasCanvasTypedArrays = displayDOMUtils.hasCanvasTypedArrays;
  43502. var MIN_FONT_SIZE = 16;
  43503. var MAX_FONT_SIZE = 100;
  43504. var MAX_GROUP_SIZE = 4096;
  43505. var MIN_WIDTH_FACTOR = 0.65;
  43506. var COMPILE_TYPE3_GLYPHS = true;
  43507. var MAX_SIZE_TO_COMPILE = 1000;
  43508. var FULL_CHUNK_HEIGHT = 16;
  43509. var HasCanvasTypedArraysCached = {
  43510. get value() {
  43511. return shadow(HasCanvasTypedArraysCached, 'value', hasCanvasTypedArrays());
  43512. }
  43513. };
  43514. var IsLittleEndianCached = {
  43515. get value() {
  43516. return shadow(IsLittleEndianCached, 'value', isLittleEndian());
  43517. }
  43518. };
  43519. function createScratchCanvas(width, height) {
  43520. var canvas = document.createElement('canvas');
  43521. canvas.width = width;
  43522. canvas.height = height;
  43523. return canvas;
  43524. }
  43525. function addContextCurrentTransform(ctx) {
  43526. if (!ctx.mozCurrentTransform) {
  43527. ctx._originalSave = ctx.save;
  43528. ctx._originalRestore = ctx.restore;
  43529. ctx._originalRotate = ctx.rotate;
  43530. ctx._originalScale = ctx.scale;
  43531. ctx._originalTranslate = ctx.translate;
  43532. ctx._originalTransform = ctx.transform;
  43533. ctx._originalSetTransform = ctx.setTransform;
  43534. ctx._transformMatrix = ctx._transformMatrix || [
  43535. 1,
  43536. 0,
  43537. 0,
  43538. 1,
  43539. 0,
  43540. 0
  43541. ];
  43542. ctx._transformStack = [];
  43543. Object.defineProperty(ctx, 'mozCurrentTransform', {
  43544. get: function getCurrentTransform() {
  43545. return this._transformMatrix;
  43546. }
  43547. });
  43548. Object.defineProperty(ctx, 'mozCurrentTransformInverse', {
  43549. get: function getCurrentTransformInverse() {
  43550. var m = this._transformMatrix;
  43551. var a = m[0], b = m[1], c = m[2], d = m[3], e = m[4], f = m[5];
  43552. var ad_bc = a * d - b * c;
  43553. var bc_ad = b * c - a * d;
  43554. return [
  43555. d / ad_bc,
  43556. b / bc_ad,
  43557. c / bc_ad,
  43558. a / ad_bc,
  43559. (d * e - c * f) / bc_ad,
  43560. (b * e - a * f) / ad_bc
  43561. ];
  43562. }
  43563. });
  43564. ctx.save = function ctxSave() {
  43565. var old = this._transformMatrix;
  43566. this._transformStack.push(old);
  43567. this._transformMatrix = old.slice(0, 6);
  43568. this._originalSave();
  43569. };
  43570. ctx.restore = function ctxRestore() {
  43571. var prev = this._transformStack.pop();
  43572. if (prev) {
  43573. this._transformMatrix = prev;
  43574. this._originalRestore();
  43575. }
  43576. };
  43577. ctx.translate = function ctxTranslate(x, y) {
  43578. var m = this._transformMatrix;
  43579. m[4] = m[0] * x + m[2] * y + m[4];
  43580. m[5] = m[1] * x + m[3] * y + m[5];
  43581. this._originalTranslate(x, y);
  43582. };
  43583. ctx.scale = function ctxScale(x, y) {
  43584. var m = this._transformMatrix;
  43585. m[0] = m[0] * x;
  43586. m[1] = m[1] * x;
  43587. m[2] = m[2] * y;
  43588. m[3] = m[3] * y;
  43589. this._originalScale(x, y);
  43590. };
  43591. ctx.transform = function ctxTransform(a, b, c, d, e, f) {
  43592. var m = this._transformMatrix;
  43593. this._transformMatrix = [
  43594. m[0] * a + m[2] * b,
  43595. m[1] * a + m[3] * b,
  43596. m[0] * c + m[2] * d,
  43597. m[1] * c + m[3] * d,
  43598. m[0] * e + m[2] * f + m[4],
  43599. m[1] * e + m[3] * f + m[5]
  43600. ];
  43601. ctx._originalTransform(a, b, c, d, e, f);
  43602. };
  43603. ctx.setTransform = function ctxSetTransform(a, b, c, d, e, f) {
  43604. this._transformMatrix = [
  43605. a,
  43606. b,
  43607. c,
  43608. d,
  43609. e,
  43610. f
  43611. ];
  43612. ctx._originalSetTransform(a, b, c, d, e, f);
  43613. };
  43614. ctx.rotate = function ctxRotate(angle) {
  43615. var cosValue = Math.cos(angle);
  43616. var sinValue = Math.sin(angle);
  43617. var m = this._transformMatrix;
  43618. this._transformMatrix = [
  43619. m[0] * cosValue + m[2] * sinValue,
  43620. m[1] * cosValue + m[3] * sinValue,
  43621. m[0] * -sinValue + m[2] * cosValue,
  43622. m[1] * -sinValue + m[3] * cosValue,
  43623. m[4],
  43624. m[5]
  43625. ];
  43626. this._originalRotate(angle);
  43627. };
  43628. }
  43629. }
  43630. var CachedCanvases = function CachedCanvasesClosure() {
  43631. function CachedCanvases() {
  43632. this.cache = Object.create(null);
  43633. }
  43634. CachedCanvases.prototype = {
  43635. getCanvas: function CachedCanvases_getCanvas(id, width, height, trackTransform) {
  43636. var canvasEntry;
  43637. if (this.cache[id] !== undefined) {
  43638. canvasEntry = this.cache[id];
  43639. canvasEntry.canvas.width = width;
  43640. canvasEntry.canvas.height = height;
  43641. canvasEntry.context.setTransform(1, 0, 0, 1, 0, 0);
  43642. } else {
  43643. var canvas = createScratchCanvas(width, height);
  43644. var ctx = canvas.getContext('2d');
  43645. if (trackTransform) {
  43646. addContextCurrentTransform(ctx);
  43647. }
  43648. this.cache[id] = canvasEntry = {
  43649. canvas: canvas,
  43650. context: ctx
  43651. };
  43652. }
  43653. return canvasEntry;
  43654. },
  43655. clear: function () {
  43656. for (var id in this.cache) {
  43657. var canvasEntry = this.cache[id];
  43658. canvasEntry.canvas.width = 0;
  43659. canvasEntry.canvas.height = 0;
  43660. delete this.cache[id];
  43661. }
  43662. }
  43663. };
  43664. return CachedCanvases;
  43665. }();
  43666. function compileType3Glyph(imgData) {
  43667. var POINT_TO_PROCESS_LIMIT = 1000;
  43668. var width = imgData.width, height = imgData.height;
  43669. var i, j, j0, width1 = width + 1;
  43670. var points = new Uint8Array(width1 * (height + 1));
  43671. var POINT_TYPES = new Uint8Array([
  43672. 0,
  43673. 2,
  43674. 4,
  43675. 0,
  43676. 1,
  43677. 0,
  43678. 5,
  43679. 4,
  43680. 8,
  43681. 10,
  43682. 0,
  43683. 8,
  43684. 0,
  43685. 2,
  43686. 1,
  43687. 0
  43688. ]);
  43689. var lineSize = width + 7 & ~7, data0 = imgData.data;
  43690. var data = new Uint8Array(lineSize * height), pos = 0, ii;
  43691. for (i = 0, ii = data0.length; i < ii; i++) {
  43692. var mask = 128, elem = data0[i];
  43693. while (mask > 0) {
  43694. data[pos++] = elem & mask ? 0 : 255;
  43695. mask >>= 1;
  43696. }
  43697. }
  43698. var count = 0;
  43699. pos = 0;
  43700. if (data[pos] !== 0) {
  43701. points[0] = 1;
  43702. ++count;
  43703. }
  43704. for (j = 1; j < width; j++) {
  43705. if (data[pos] !== data[pos + 1]) {
  43706. points[j] = data[pos] ? 2 : 1;
  43707. ++count;
  43708. }
  43709. pos++;
  43710. }
  43711. if (data[pos] !== 0) {
  43712. points[j] = 2;
  43713. ++count;
  43714. }
  43715. for (i = 1; i < height; i++) {
  43716. pos = i * lineSize;
  43717. j0 = i * width1;
  43718. if (data[pos - lineSize] !== data[pos]) {
  43719. points[j0] = data[pos] ? 1 : 8;
  43720. ++count;
  43721. }
  43722. var sum = (data[pos] ? 4 : 0) + (data[pos - lineSize] ? 8 : 0);
  43723. for (j = 1; j < width; j++) {
  43724. sum = (sum >> 2) + (data[pos + 1] ? 4 : 0) + (data[pos - lineSize + 1] ? 8 : 0);
  43725. if (POINT_TYPES[sum]) {
  43726. points[j0 + j] = POINT_TYPES[sum];
  43727. ++count;
  43728. }
  43729. pos++;
  43730. }
  43731. if (data[pos - lineSize] !== data[pos]) {
  43732. points[j0 + j] = data[pos] ? 2 : 4;
  43733. ++count;
  43734. }
  43735. if (count > POINT_TO_PROCESS_LIMIT) {
  43736. return null;
  43737. }
  43738. }
  43739. pos = lineSize * (height - 1);
  43740. j0 = i * width1;
  43741. if (data[pos] !== 0) {
  43742. points[j0] = 8;
  43743. ++count;
  43744. }
  43745. for (j = 1; j < width; j++) {
  43746. if (data[pos] !== data[pos + 1]) {
  43747. points[j0 + j] = data[pos] ? 4 : 8;
  43748. ++count;
  43749. }
  43750. pos++;
  43751. }
  43752. if (data[pos] !== 0) {
  43753. points[j0 + j] = 4;
  43754. ++count;
  43755. }
  43756. if (count > POINT_TO_PROCESS_LIMIT) {
  43757. return null;
  43758. }
  43759. var steps = new Int32Array([
  43760. 0,
  43761. width1,
  43762. -1,
  43763. 0,
  43764. -width1,
  43765. 0,
  43766. 0,
  43767. 0,
  43768. 1
  43769. ]);
  43770. var outlines = [];
  43771. for (i = 0; count && i <= height; i++) {
  43772. var p = i * width1;
  43773. var end = p + width;
  43774. while (p < end && !points[p]) {
  43775. p++;
  43776. }
  43777. if (p === end) {
  43778. continue;
  43779. }
  43780. var coords = [
  43781. p % width1,
  43782. i
  43783. ];
  43784. var type = points[p], p0 = p, pp;
  43785. do {
  43786. var step = steps[type];
  43787. do {
  43788. p += step;
  43789. } while (!points[p]);
  43790. pp = points[p];
  43791. if (pp !== 5 && pp !== 10) {
  43792. type = pp;
  43793. points[p] = 0;
  43794. } else {
  43795. type = pp & 0x33 * type >> 4;
  43796. points[p] &= type >> 2 | type << 2;
  43797. }
  43798. coords.push(p % width1);
  43799. coords.push(p / width1 | 0);
  43800. --count;
  43801. } while (p0 !== p);
  43802. outlines.push(coords);
  43803. --i;
  43804. }
  43805. var drawOutline = function (c) {
  43806. c.save();
  43807. c.scale(1 / width, -1 / height);
  43808. c.translate(0, -height);
  43809. c.beginPath();
  43810. for (var i = 0, ii = outlines.length; i < ii; i++) {
  43811. var o = outlines[i];
  43812. c.moveTo(o[0], o[1]);
  43813. for (var j = 2, jj = o.length; j < jj; j += 2) {
  43814. c.lineTo(o[j], o[j + 1]);
  43815. }
  43816. }
  43817. c.fill();
  43818. c.beginPath();
  43819. c.restore();
  43820. };
  43821. return drawOutline;
  43822. }
  43823. var CanvasExtraState = function CanvasExtraStateClosure() {
  43824. function CanvasExtraState(old) {
  43825. this.alphaIsShape = false;
  43826. this.fontSize = 0;
  43827. this.fontSizeScale = 1;
  43828. this.textMatrix = IDENTITY_MATRIX;
  43829. this.textMatrixScale = 1;
  43830. this.fontMatrix = FONT_IDENTITY_MATRIX;
  43831. this.leading = 0;
  43832. this.x = 0;
  43833. this.y = 0;
  43834. this.lineX = 0;
  43835. this.lineY = 0;
  43836. this.charSpacing = 0;
  43837. this.wordSpacing = 0;
  43838. this.textHScale = 1;
  43839. this.textRenderingMode = TextRenderingMode.FILL;
  43840. this.textRise = 0;
  43841. this.fillColor = '#000000';
  43842. this.strokeColor = '#000000';
  43843. this.patternFill = false;
  43844. this.fillAlpha = 1;
  43845. this.strokeAlpha = 1;
  43846. this.lineWidth = 1;
  43847. this.activeSMask = null;
  43848. this.resumeSMaskCtx = null;
  43849. this.old = old;
  43850. }
  43851. CanvasExtraState.prototype = {
  43852. clone: function CanvasExtraState_clone() {
  43853. return Object.create(this);
  43854. },
  43855. setCurrentPoint: function CanvasExtraState_setCurrentPoint(x, y) {
  43856. this.x = x;
  43857. this.y = y;
  43858. }
  43859. };
  43860. return CanvasExtraState;
  43861. }();
  43862. var CanvasGraphics = function CanvasGraphicsClosure() {
  43863. var EXECUTION_TIME = 15;
  43864. var EXECUTION_STEPS = 10;
  43865. function CanvasGraphics(canvasCtx, commonObjs, objs, imageLayer) {
  43866. this.ctx = canvasCtx;
  43867. this.current = new CanvasExtraState();
  43868. this.stateStack = [];
  43869. this.pendingClip = null;
  43870. this.pendingEOFill = false;
  43871. this.res = null;
  43872. this.xobjs = null;
  43873. this.commonObjs = commonObjs;
  43874. this.objs = objs;
  43875. this.imageLayer = imageLayer;
  43876. this.groupStack = [];
  43877. this.processingType3 = null;
  43878. this.baseTransform = null;
  43879. this.baseTransformStack = [];
  43880. this.groupLevel = 0;
  43881. this.smaskStack = [];
  43882. this.smaskCounter = 0;
  43883. this.tempSMask = null;
  43884. this.cachedCanvases = new CachedCanvases();
  43885. if (canvasCtx) {
  43886. addContextCurrentTransform(canvasCtx);
  43887. }
  43888. this.cachedGetSinglePixelWidth = null;
  43889. }
  43890. function putBinaryImageData(ctx, imgData) {
  43891. if (typeof ImageData !== 'undefined' && imgData instanceof ImageData) {
  43892. ctx.putImageData(imgData, 0, 0);
  43893. return;
  43894. }
  43895. var height = imgData.height, width = imgData.width;
  43896. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  43897. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  43898. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  43899. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  43900. var srcPos = 0, destPos;
  43901. var src = imgData.data;
  43902. var dest = chunkImgData.data;
  43903. var i, j, thisChunkHeight, elemsInThisChunk;
  43904. if (imgData.kind === ImageKind.GRAYSCALE_1BPP) {
  43905. var srcLength = src.byteLength;
  43906. var dest32 = HasCanvasTypedArraysCached.value ? new Uint32Array(dest.buffer) : new Uint32ArrayView(dest);
  43907. var dest32DataLength = dest32.length;
  43908. var fullSrcDiff = width + 7 >> 3;
  43909. var white = 0xFFFFFFFF;
  43910. var black = IsLittleEndianCached.value || !HasCanvasTypedArraysCached.value ? 0xFF000000 : 0x000000FF;
  43911. for (i = 0; i < totalChunks; i++) {
  43912. thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  43913. destPos = 0;
  43914. for (j = 0; j < thisChunkHeight; j++) {
  43915. var srcDiff = srcLength - srcPos;
  43916. var k = 0;
  43917. var kEnd = srcDiff > fullSrcDiff ? width : srcDiff * 8 - 7;
  43918. var kEndUnrolled = kEnd & ~7;
  43919. var mask = 0;
  43920. var srcByte = 0;
  43921. for (; k < kEndUnrolled; k += 8) {
  43922. srcByte = src[srcPos++];
  43923. dest32[destPos++] = srcByte & 128 ? white : black;
  43924. dest32[destPos++] = srcByte & 64 ? white : black;
  43925. dest32[destPos++] = srcByte & 32 ? white : black;
  43926. dest32[destPos++] = srcByte & 16 ? white : black;
  43927. dest32[destPos++] = srcByte & 8 ? white : black;
  43928. dest32[destPos++] = srcByte & 4 ? white : black;
  43929. dest32[destPos++] = srcByte & 2 ? white : black;
  43930. dest32[destPos++] = srcByte & 1 ? white : black;
  43931. }
  43932. for (; k < kEnd; k++) {
  43933. if (mask === 0) {
  43934. srcByte = src[srcPos++];
  43935. mask = 128;
  43936. }
  43937. dest32[destPos++] = srcByte & mask ? white : black;
  43938. mask >>= 1;
  43939. }
  43940. }
  43941. while (destPos < dest32DataLength) {
  43942. dest32[destPos++] = 0;
  43943. }
  43944. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43945. }
  43946. } else if (imgData.kind === ImageKind.RGBA_32BPP) {
  43947. j = 0;
  43948. elemsInThisChunk = width * FULL_CHUNK_HEIGHT * 4;
  43949. for (i = 0; i < fullChunks; i++) {
  43950. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  43951. srcPos += elemsInThisChunk;
  43952. ctx.putImageData(chunkImgData, 0, j);
  43953. j += FULL_CHUNK_HEIGHT;
  43954. }
  43955. if (i < totalChunks) {
  43956. elemsInThisChunk = width * partialChunkHeight * 4;
  43957. dest.set(src.subarray(srcPos, srcPos + elemsInThisChunk));
  43958. ctx.putImageData(chunkImgData, 0, j);
  43959. }
  43960. } else if (imgData.kind === ImageKind.RGB_24BPP) {
  43961. thisChunkHeight = FULL_CHUNK_HEIGHT;
  43962. elemsInThisChunk = width * thisChunkHeight;
  43963. for (i = 0; i < totalChunks; i++) {
  43964. if (i >= fullChunks) {
  43965. thisChunkHeight = partialChunkHeight;
  43966. elemsInThisChunk = width * thisChunkHeight;
  43967. }
  43968. destPos = 0;
  43969. for (j = elemsInThisChunk; j--;) {
  43970. dest[destPos++] = src[srcPos++];
  43971. dest[destPos++] = src[srcPos++];
  43972. dest[destPos++] = src[srcPos++];
  43973. dest[destPos++] = 255;
  43974. }
  43975. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  43976. }
  43977. } else {
  43978. error('bad image kind: ' + imgData.kind);
  43979. }
  43980. }
  43981. function putBinaryImageMask(ctx, imgData) {
  43982. var height = imgData.height, width = imgData.width;
  43983. var partialChunkHeight = height % FULL_CHUNK_HEIGHT;
  43984. var fullChunks = (height - partialChunkHeight) / FULL_CHUNK_HEIGHT;
  43985. var totalChunks = partialChunkHeight === 0 ? fullChunks : fullChunks + 1;
  43986. var chunkImgData = ctx.createImageData(width, FULL_CHUNK_HEIGHT);
  43987. var srcPos = 0;
  43988. var src = imgData.data;
  43989. var dest = chunkImgData.data;
  43990. for (var i = 0; i < totalChunks; i++) {
  43991. var thisChunkHeight = i < fullChunks ? FULL_CHUNK_HEIGHT : partialChunkHeight;
  43992. var destPos = 3;
  43993. for (var j = 0; j < thisChunkHeight; j++) {
  43994. var mask = 0;
  43995. for (var k = 0; k < width; k++) {
  43996. if (!mask) {
  43997. var elem = src[srcPos++];
  43998. mask = 128;
  43999. }
  44000. dest[destPos] = elem & mask ? 0 : 255;
  44001. destPos += 4;
  44002. mask >>= 1;
  44003. }
  44004. }
  44005. ctx.putImageData(chunkImgData, 0, i * FULL_CHUNK_HEIGHT);
  44006. }
  44007. }
  44008. function copyCtxState(sourceCtx, destCtx) {
  44009. var properties = [
  44010. 'strokeStyle',
  44011. 'fillStyle',
  44012. 'fillRule',
  44013. 'globalAlpha',
  44014. 'lineWidth',
  44015. 'lineCap',
  44016. 'lineJoin',
  44017. 'miterLimit',
  44018. 'globalCompositeOperation',
  44019. 'font'
  44020. ];
  44021. for (var i = 0, ii = properties.length; i < ii; i++) {
  44022. var property = properties[i];
  44023. if (sourceCtx[property] !== undefined) {
  44024. destCtx[property] = sourceCtx[property];
  44025. }
  44026. }
  44027. if (sourceCtx.setLineDash !== undefined) {
  44028. destCtx.setLineDash(sourceCtx.getLineDash());
  44029. destCtx.lineDashOffset = sourceCtx.lineDashOffset;
  44030. }
  44031. }
  44032. function composeSMaskBackdrop(bytes, r0, g0, b0) {
  44033. var length = bytes.length;
  44034. for (var i = 3; i < length; i += 4) {
  44035. var alpha = bytes[i];
  44036. if (alpha === 0) {
  44037. bytes[i - 3] = r0;
  44038. bytes[i - 2] = g0;
  44039. bytes[i - 1] = b0;
  44040. } else if (alpha < 255) {
  44041. var alpha_ = 255 - alpha;
  44042. bytes[i - 3] = bytes[i - 3] * alpha + r0 * alpha_ >> 8;
  44043. bytes[i - 2] = bytes[i - 2] * alpha + g0 * alpha_ >> 8;
  44044. bytes[i - 1] = bytes[i - 1] * alpha + b0 * alpha_ >> 8;
  44045. }
  44046. }
  44047. }
  44048. function composeSMaskAlpha(maskData, layerData, transferMap) {
  44049. var length = maskData.length;
  44050. var scale = 1 / 255;
  44051. for (var i = 3; i < length; i += 4) {
  44052. var alpha = transferMap ? transferMap[maskData[i]] : maskData[i];
  44053. layerData[i] = layerData[i] * alpha * scale | 0;
  44054. }
  44055. }
  44056. function composeSMaskLuminosity(maskData, layerData, transferMap) {
  44057. var length = maskData.length;
  44058. for (var i = 3; i < length; i += 4) {
  44059. var y = maskData[i - 3] * 77 + maskData[i - 2] * 152 + maskData[i - 1] * 28;
  44060. layerData[i] = transferMap ? layerData[i] * transferMap[y >> 8] >> 8 : layerData[i] * y >> 16;
  44061. }
  44062. }
  44063. function genericComposeSMask(maskCtx, layerCtx, width, height, subtype, backdrop, transferMap) {
  44064. var hasBackdrop = !!backdrop;
  44065. var r0 = hasBackdrop ? backdrop[0] : 0;
  44066. var g0 = hasBackdrop ? backdrop[1] : 0;
  44067. var b0 = hasBackdrop ? backdrop[2] : 0;
  44068. var composeFn;
  44069. if (subtype === 'Luminosity') {
  44070. composeFn = composeSMaskLuminosity;
  44071. } else {
  44072. composeFn = composeSMaskAlpha;
  44073. }
  44074. var PIXELS_TO_PROCESS = 1048576;
  44075. var chunkSize = Math.min(height, Math.ceil(PIXELS_TO_PROCESS / width));
  44076. for (var row = 0; row < height; row += chunkSize) {
  44077. var chunkHeight = Math.min(chunkSize, height - row);
  44078. var maskData = maskCtx.getImageData(0, row, width, chunkHeight);
  44079. var layerData = layerCtx.getImageData(0, row, width, chunkHeight);
  44080. if (hasBackdrop) {
  44081. composeSMaskBackdrop(maskData.data, r0, g0, b0);
  44082. }
  44083. composeFn(maskData.data, layerData.data, transferMap);
  44084. maskCtx.putImageData(layerData, 0, row);
  44085. }
  44086. }
  44087. function composeSMask(ctx, smask, layerCtx) {
  44088. var mask = smask.canvas;
  44089. var maskCtx = smask.context;
  44090. ctx.setTransform(smask.scaleX, 0, 0, smask.scaleY, smask.offsetX, smask.offsetY);
  44091. var backdrop = smask.backdrop || null;
  44092. if (!smask.transferMap && WebGLUtils.isEnabled) {
  44093. var composed = WebGLUtils.composeSMask(layerCtx.canvas, mask, {
  44094. subtype: smask.subtype,
  44095. backdrop: backdrop
  44096. });
  44097. ctx.setTransform(1, 0, 0, 1, 0, 0);
  44098. ctx.drawImage(composed, smask.offsetX, smask.offsetY);
  44099. return;
  44100. }
  44101. genericComposeSMask(maskCtx, layerCtx, mask.width, mask.height, smask.subtype, backdrop, smask.transferMap);
  44102. ctx.drawImage(mask, 0, 0);
  44103. }
  44104. var LINE_CAP_STYLES = [
  44105. 'butt',
  44106. 'round',
  44107. 'square'
  44108. ];
  44109. var LINE_JOIN_STYLES = [
  44110. 'miter',
  44111. 'round',
  44112. 'bevel'
  44113. ];
  44114. var NORMAL_CLIP = {};
  44115. var EO_CLIP = {};
  44116. CanvasGraphics.prototype = {
  44117. beginDrawing: function CanvasGraphics_beginDrawing(transform, viewport, transparency) {
  44118. var width = this.ctx.canvas.width;
  44119. var height = this.ctx.canvas.height;
  44120. this.ctx.save();
  44121. this.ctx.fillStyle = 'rgb(255, 255, 255)';
  44122. this.ctx.fillRect(0, 0, width, height);
  44123. this.ctx.restore();
  44124. if (transparency) {
  44125. var transparentCanvas = this.cachedCanvases.getCanvas('transparent', width, height, true);
  44126. this.compositeCtx = this.ctx;
  44127. this.transparentCanvas = transparentCanvas.canvas;
  44128. this.ctx = transparentCanvas.context;
  44129. this.ctx.save();
  44130. this.ctx.transform.apply(this.ctx, this.compositeCtx.mozCurrentTransform);
  44131. }
  44132. this.ctx.save();
  44133. if (transform) {
  44134. this.ctx.transform.apply(this.ctx, transform);
  44135. }
  44136. this.ctx.transform.apply(this.ctx, viewport.transform);
  44137. this.baseTransform = this.ctx.mozCurrentTransform.slice();
  44138. if (this.imageLayer) {
  44139. this.imageLayer.beginLayout();
  44140. }
  44141. },
  44142. executeOperatorList: function CanvasGraphics_executeOperatorList(operatorList, executionStartIdx, continueCallback, stepper) {
  44143. var argsArray = operatorList.argsArray;
  44144. var fnArray = operatorList.fnArray;
  44145. var i = executionStartIdx || 0;
  44146. var argsArrayLen = argsArray.length;
  44147. if (argsArrayLen === i) {
  44148. return i;
  44149. }
  44150. var chunkOperations = argsArrayLen - i > EXECUTION_STEPS && typeof continueCallback === 'function';
  44151. var endTime = chunkOperations ? Date.now() + EXECUTION_TIME : 0;
  44152. var steps = 0;
  44153. var commonObjs = this.commonObjs;
  44154. var objs = this.objs;
  44155. var fnId;
  44156. while (true) {
  44157. if (stepper !== undefined && i === stepper.nextBreakPoint) {
  44158. stepper.breakIt(i, continueCallback);
  44159. return i;
  44160. }
  44161. fnId = fnArray[i];
  44162. if (fnId !== OPS.dependency) {
  44163. this[fnId].apply(this, argsArray[i]);
  44164. } else {
  44165. var deps = argsArray[i];
  44166. for (var n = 0, nn = deps.length; n < nn; n++) {
  44167. var depObjId = deps[n];
  44168. var common = depObjId[0] === 'g' && depObjId[1] === '_';
  44169. var objsPool = common ? commonObjs : objs;
  44170. if (!objsPool.isResolved(depObjId)) {
  44171. objsPool.get(depObjId, continueCallback);
  44172. return i;
  44173. }
  44174. }
  44175. }
  44176. i++;
  44177. if (i === argsArrayLen) {
  44178. return i;
  44179. }
  44180. if (chunkOperations && ++steps > EXECUTION_STEPS) {
  44181. if (Date.now() > endTime) {
  44182. continueCallback();
  44183. return i;
  44184. }
  44185. steps = 0;
  44186. }
  44187. }
  44188. },
  44189. endDrawing: function CanvasGraphics_endDrawing() {
  44190. if (this.current.activeSMask !== null) {
  44191. this.endSMaskGroup();
  44192. }
  44193. this.ctx.restore();
  44194. if (this.transparentCanvas) {
  44195. this.ctx = this.compositeCtx;
  44196. this.ctx.save();
  44197. this.ctx.setTransform(1, 0, 0, 1, 0, 0);
  44198. this.ctx.drawImage(this.transparentCanvas, 0, 0);
  44199. this.ctx.restore();
  44200. this.transparentCanvas = null;
  44201. }
  44202. this.cachedCanvases.clear();
  44203. WebGLUtils.clear();
  44204. if (this.imageLayer) {
  44205. this.imageLayer.endLayout();
  44206. }
  44207. },
  44208. setLineWidth: function CanvasGraphics_setLineWidth(width) {
  44209. this.current.lineWidth = width;
  44210. this.ctx.lineWidth = width;
  44211. },
  44212. setLineCap: function CanvasGraphics_setLineCap(style) {
  44213. this.ctx.lineCap = LINE_CAP_STYLES[style];
  44214. },
  44215. setLineJoin: function CanvasGraphics_setLineJoin(style) {
  44216. this.ctx.lineJoin = LINE_JOIN_STYLES[style];
  44217. },
  44218. setMiterLimit: function CanvasGraphics_setMiterLimit(limit) {
  44219. this.ctx.miterLimit = limit;
  44220. },
  44221. setDash: function CanvasGraphics_setDash(dashArray, dashPhase) {
  44222. var ctx = this.ctx;
  44223. if (ctx.setLineDash !== undefined) {
  44224. ctx.setLineDash(dashArray);
  44225. ctx.lineDashOffset = dashPhase;
  44226. }
  44227. },
  44228. setRenderingIntent: function CanvasGraphics_setRenderingIntent(intent) {
  44229. },
  44230. setFlatness: function CanvasGraphics_setFlatness(flatness) {
  44231. },
  44232. setGState: function CanvasGraphics_setGState(states) {
  44233. for (var i = 0, ii = states.length; i < ii; i++) {
  44234. var state = states[i];
  44235. var key = state[0];
  44236. var value = state[1];
  44237. switch (key) {
  44238. case 'LW':
  44239. this.setLineWidth(value);
  44240. break;
  44241. case 'LC':
  44242. this.setLineCap(value);
  44243. break;
  44244. case 'LJ':
  44245. this.setLineJoin(value);
  44246. break;
  44247. case 'ML':
  44248. this.setMiterLimit(value);
  44249. break;
  44250. case 'D':
  44251. this.setDash(value[0], value[1]);
  44252. break;
  44253. case 'RI':
  44254. this.setRenderingIntent(value);
  44255. break;
  44256. case 'FL':
  44257. this.setFlatness(value);
  44258. break;
  44259. case 'Font':
  44260. this.setFont(value[0], value[1]);
  44261. break;
  44262. case 'CA':
  44263. this.current.strokeAlpha = state[1];
  44264. break;
  44265. case 'ca':
  44266. this.current.fillAlpha = state[1];
  44267. this.ctx.globalAlpha = state[1];
  44268. break;
  44269. case 'BM':
  44270. if (value && value.name && value.name !== 'Normal') {
  44271. var mode = value.name.replace(/([A-Z])/g, function (c) {
  44272. return '-' + c.toLowerCase();
  44273. }).substring(1);
  44274. this.ctx.globalCompositeOperation = mode;
  44275. if (this.ctx.globalCompositeOperation !== mode) {
  44276. warn('globalCompositeOperation "' + mode + '" is not supported');
  44277. }
  44278. } else {
  44279. this.ctx.globalCompositeOperation = 'source-over';
  44280. }
  44281. break;
  44282. case 'SMask':
  44283. if (this.current.activeSMask) {
  44284. if (this.stateStack.length > 0 && this.stateStack[this.stateStack.length - 1].activeSMask === this.current.activeSMask) {
  44285. this.suspendSMaskGroup();
  44286. } else {
  44287. this.endSMaskGroup();
  44288. }
  44289. }
  44290. this.current.activeSMask = value ? this.tempSMask : null;
  44291. if (this.current.activeSMask) {
  44292. this.beginSMaskGroup();
  44293. }
  44294. this.tempSMask = null;
  44295. break;
  44296. }
  44297. }
  44298. },
  44299. beginSMaskGroup: function CanvasGraphics_beginSMaskGroup() {
  44300. var activeSMask = this.current.activeSMask;
  44301. var drawnWidth = activeSMask.canvas.width;
  44302. var drawnHeight = activeSMask.canvas.height;
  44303. var cacheId = 'smaskGroupAt' + this.groupLevel;
  44304. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  44305. var currentCtx = this.ctx;
  44306. var currentTransform = currentCtx.mozCurrentTransform;
  44307. this.ctx.save();
  44308. var groupCtx = scratchCanvas.context;
  44309. groupCtx.scale(1 / activeSMask.scaleX, 1 / activeSMask.scaleY);
  44310. groupCtx.translate(-activeSMask.offsetX, -activeSMask.offsetY);
  44311. groupCtx.transform.apply(groupCtx, currentTransform);
  44312. activeSMask.startTransformInverse = groupCtx.mozCurrentTransformInverse;
  44313. copyCtxState(currentCtx, groupCtx);
  44314. this.ctx = groupCtx;
  44315. this.setGState([
  44316. [
  44317. 'BM',
  44318. 'Normal'
  44319. ],
  44320. [
  44321. 'ca',
  44322. 1
  44323. ],
  44324. [
  44325. 'CA',
  44326. 1
  44327. ]
  44328. ]);
  44329. this.groupStack.push(currentCtx);
  44330. this.groupLevel++;
  44331. },
  44332. suspendSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44333. var groupCtx = this.ctx;
  44334. this.groupLevel--;
  44335. this.ctx = this.groupStack.pop();
  44336. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44337. this.ctx.restore();
  44338. this.ctx.save();
  44339. copyCtxState(groupCtx, this.ctx);
  44340. this.current.resumeSMaskCtx = groupCtx;
  44341. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44342. this.ctx.transform.apply(this.ctx, deltaTransform);
  44343. groupCtx.save();
  44344. groupCtx.setTransform(1, 0, 0, 1, 0, 0);
  44345. groupCtx.clearRect(0, 0, groupCtx.canvas.width, groupCtx.canvas.height);
  44346. groupCtx.restore();
  44347. },
  44348. resumeSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44349. var groupCtx = this.current.resumeSMaskCtx;
  44350. var currentCtx = this.ctx;
  44351. this.ctx = groupCtx;
  44352. this.groupStack.push(currentCtx);
  44353. this.groupLevel++;
  44354. },
  44355. endSMaskGroup: function CanvasGraphics_endSMaskGroup() {
  44356. var groupCtx = this.ctx;
  44357. this.groupLevel--;
  44358. this.ctx = this.groupStack.pop();
  44359. composeSMask(this.ctx, this.current.activeSMask, groupCtx);
  44360. this.ctx.restore();
  44361. copyCtxState(groupCtx, this.ctx);
  44362. var deltaTransform = Util.transform(this.current.activeSMask.startTransformInverse, groupCtx.mozCurrentTransform);
  44363. this.ctx.transform.apply(this.ctx, deltaTransform);
  44364. },
  44365. save: function CanvasGraphics_save() {
  44366. this.ctx.save();
  44367. var old = this.current;
  44368. this.stateStack.push(old);
  44369. this.current = old.clone();
  44370. this.current.resumeSMaskCtx = null;
  44371. },
  44372. restore: function CanvasGraphics_restore() {
  44373. if (this.current.resumeSMaskCtx) {
  44374. this.resumeSMaskGroup();
  44375. }
  44376. if (this.current.activeSMask !== null && (this.stateStack.length === 0 || this.stateStack[this.stateStack.length - 1].activeSMask !== this.current.activeSMask)) {
  44377. this.endSMaskGroup();
  44378. }
  44379. if (this.stateStack.length !== 0) {
  44380. this.current = this.stateStack.pop();
  44381. this.ctx.restore();
  44382. this.pendingClip = null;
  44383. this.cachedGetSinglePixelWidth = null;
  44384. }
  44385. },
  44386. transform: function CanvasGraphics_transform(a, b, c, d, e, f) {
  44387. this.ctx.transform(a, b, c, d, e, f);
  44388. this.cachedGetSinglePixelWidth = null;
  44389. },
  44390. constructPath: function CanvasGraphics_constructPath(ops, args) {
  44391. var ctx = this.ctx;
  44392. var current = this.current;
  44393. var x = current.x, y = current.y;
  44394. for (var i = 0, j = 0, ii = ops.length; i < ii; i++) {
  44395. switch (ops[i] | 0) {
  44396. case OPS.rectangle:
  44397. x = args[j++];
  44398. y = args[j++];
  44399. var width = args[j++];
  44400. var height = args[j++];
  44401. if (width === 0) {
  44402. width = this.getSinglePixelWidth();
  44403. }
  44404. if (height === 0) {
  44405. height = this.getSinglePixelWidth();
  44406. }
  44407. var xw = x + width;
  44408. var yh = y + height;
  44409. this.ctx.moveTo(x, y);
  44410. this.ctx.lineTo(xw, y);
  44411. this.ctx.lineTo(xw, yh);
  44412. this.ctx.lineTo(x, yh);
  44413. this.ctx.lineTo(x, y);
  44414. this.ctx.closePath();
  44415. break;
  44416. case OPS.moveTo:
  44417. x = args[j++];
  44418. y = args[j++];
  44419. ctx.moveTo(x, y);
  44420. break;
  44421. case OPS.lineTo:
  44422. x = args[j++];
  44423. y = args[j++];
  44424. ctx.lineTo(x, y);
  44425. break;
  44426. case OPS.curveTo:
  44427. x = args[j + 4];
  44428. y = args[j + 5];
  44429. ctx.bezierCurveTo(args[j], args[j + 1], args[j + 2], args[j + 3], x, y);
  44430. j += 6;
  44431. break;
  44432. case OPS.curveTo2:
  44433. ctx.bezierCurveTo(x, y, args[j], args[j + 1], args[j + 2], args[j + 3]);
  44434. x = args[j + 2];
  44435. y = args[j + 3];
  44436. j += 4;
  44437. break;
  44438. case OPS.curveTo3:
  44439. x = args[j + 2];
  44440. y = args[j + 3];
  44441. ctx.bezierCurveTo(args[j], args[j + 1], x, y, x, y);
  44442. j += 4;
  44443. break;
  44444. case OPS.closePath:
  44445. ctx.closePath();
  44446. break;
  44447. }
  44448. }
  44449. current.setCurrentPoint(x, y);
  44450. },
  44451. closePath: function CanvasGraphics_closePath() {
  44452. this.ctx.closePath();
  44453. },
  44454. stroke: function CanvasGraphics_stroke(consumePath) {
  44455. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44456. var ctx = this.ctx;
  44457. var strokeColor = this.current.strokeColor;
  44458. ctx.lineWidth = Math.max(this.getSinglePixelWidth() * MIN_WIDTH_FACTOR, this.current.lineWidth);
  44459. ctx.globalAlpha = this.current.strokeAlpha;
  44460. if (strokeColor && strokeColor.hasOwnProperty('type') && strokeColor.type === 'Pattern') {
  44461. ctx.save();
  44462. ctx.strokeStyle = strokeColor.getPattern(ctx, this);
  44463. ctx.stroke();
  44464. ctx.restore();
  44465. } else {
  44466. ctx.stroke();
  44467. }
  44468. if (consumePath) {
  44469. this.consumePath();
  44470. }
  44471. ctx.globalAlpha = this.current.fillAlpha;
  44472. },
  44473. closeStroke: function CanvasGraphics_closeStroke() {
  44474. this.closePath();
  44475. this.stroke();
  44476. },
  44477. fill: function CanvasGraphics_fill(consumePath) {
  44478. consumePath = typeof consumePath !== 'undefined' ? consumePath : true;
  44479. var ctx = this.ctx;
  44480. var fillColor = this.current.fillColor;
  44481. var isPatternFill = this.current.patternFill;
  44482. var needRestore = false;
  44483. if (isPatternFill) {
  44484. ctx.save();
  44485. if (this.baseTransform) {
  44486. ctx.setTransform.apply(ctx, this.baseTransform);
  44487. }
  44488. ctx.fillStyle = fillColor.getPattern(ctx, this);
  44489. needRestore = true;
  44490. }
  44491. if (this.pendingEOFill) {
  44492. if (ctx.mozFillRule !== undefined) {
  44493. ctx.mozFillRule = 'evenodd';
  44494. ctx.fill();
  44495. ctx.mozFillRule = 'nonzero';
  44496. } else {
  44497. ctx.fill('evenodd');
  44498. }
  44499. this.pendingEOFill = false;
  44500. } else {
  44501. ctx.fill();
  44502. }
  44503. if (needRestore) {
  44504. ctx.restore();
  44505. }
  44506. if (consumePath) {
  44507. this.consumePath();
  44508. }
  44509. },
  44510. eoFill: function CanvasGraphics_eoFill() {
  44511. this.pendingEOFill = true;
  44512. this.fill();
  44513. },
  44514. fillStroke: function CanvasGraphics_fillStroke() {
  44515. this.fill(false);
  44516. this.stroke(false);
  44517. this.consumePath();
  44518. },
  44519. eoFillStroke: function CanvasGraphics_eoFillStroke() {
  44520. this.pendingEOFill = true;
  44521. this.fillStroke();
  44522. },
  44523. closeFillStroke: function CanvasGraphics_closeFillStroke() {
  44524. this.closePath();
  44525. this.fillStroke();
  44526. },
  44527. closeEOFillStroke: function CanvasGraphics_closeEOFillStroke() {
  44528. this.pendingEOFill = true;
  44529. this.closePath();
  44530. this.fillStroke();
  44531. },
  44532. endPath: function CanvasGraphics_endPath() {
  44533. this.consumePath();
  44534. },
  44535. clip: function CanvasGraphics_clip() {
  44536. this.pendingClip = NORMAL_CLIP;
  44537. },
  44538. eoClip: function CanvasGraphics_eoClip() {
  44539. this.pendingClip = EO_CLIP;
  44540. },
  44541. beginText: function CanvasGraphics_beginText() {
  44542. this.current.textMatrix = IDENTITY_MATRIX;
  44543. this.current.textMatrixScale = 1;
  44544. this.current.x = this.current.lineX = 0;
  44545. this.current.y = this.current.lineY = 0;
  44546. },
  44547. endText: function CanvasGraphics_endText() {
  44548. var paths = this.pendingTextPaths;
  44549. var ctx = this.ctx;
  44550. if (paths === undefined) {
  44551. ctx.beginPath();
  44552. return;
  44553. }
  44554. ctx.save();
  44555. ctx.beginPath();
  44556. for (var i = 0; i < paths.length; i++) {
  44557. var path = paths[i];
  44558. ctx.setTransform.apply(ctx, path.transform);
  44559. ctx.translate(path.x, path.y);
  44560. path.addToPath(ctx, path.fontSize);
  44561. }
  44562. ctx.restore();
  44563. ctx.clip();
  44564. ctx.beginPath();
  44565. delete this.pendingTextPaths;
  44566. },
  44567. setCharSpacing: function CanvasGraphics_setCharSpacing(spacing) {
  44568. this.current.charSpacing = spacing;
  44569. },
  44570. setWordSpacing: function CanvasGraphics_setWordSpacing(spacing) {
  44571. this.current.wordSpacing = spacing;
  44572. },
  44573. setHScale: function CanvasGraphics_setHScale(scale) {
  44574. this.current.textHScale = scale / 100;
  44575. },
  44576. setLeading: function CanvasGraphics_setLeading(leading) {
  44577. this.current.leading = -leading;
  44578. },
  44579. setFont: function CanvasGraphics_setFont(fontRefName, size) {
  44580. var fontObj = this.commonObjs.get(fontRefName);
  44581. var current = this.current;
  44582. if (!fontObj) {
  44583. error('Can\'t find font for ' + fontRefName);
  44584. }
  44585. current.fontMatrix = fontObj.fontMatrix ? fontObj.fontMatrix : FONT_IDENTITY_MATRIX;
  44586. if (current.fontMatrix[0] === 0 || current.fontMatrix[3] === 0) {
  44587. warn('Invalid font matrix for font ' + fontRefName);
  44588. }
  44589. if (size < 0) {
  44590. size = -size;
  44591. current.fontDirection = -1;
  44592. } else {
  44593. current.fontDirection = 1;
  44594. }
  44595. this.current.font = fontObj;
  44596. this.current.fontSize = size;
  44597. if (fontObj.isType3Font) {
  44598. return;
  44599. }
  44600. var name = fontObj.loadedName || 'sans-serif';
  44601. var bold = fontObj.black ? '900' : fontObj.bold ? 'bold' : 'normal';
  44602. var italic = fontObj.italic ? 'italic' : 'normal';
  44603. var typeface = '"' + name + '", ' + fontObj.fallbackName;
  44604. var browserFontSize = size < MIN_FONT_SIZE ? MIN_FONT_SIZE : size > MAX_FONT_SIZE ? MAX_FONT_SIZE : size;
  44605. this.current.fontSizeScale = size / browserFontSize;
  44606. var rule = italic + ' ' + bold + ' ' + browserFontSize + 'px ' + typeface;
  44607. this.ctx.font = rule;
  44608. },
  44609. setTextRenderingMode: function CanvasGraphics_setTextRenderingMode(mode) {
  44610. this.current.textRenderingMode = mode;
  44611. },
  44612. setTextRise: function CanvasGraphics_setTextRise(rise) {
  44613. this.current.textRise = rise;
  44614. },
  44615. moveText: function CanvasGraphics_moveText(x, y) {
  44616. this.current.x = this.current.lineX += x;
  44617. this.current.y = this.current.lineY += y;
  44618. },
  44619. setLeadingMoveText: function CanvasGraphics_setLeadingMoveText(x, y) {
  44620. this.setLeading(-y);
  44621. this.moveText(x, y);
  44622. },
  44623. setTextMatrix: function CanvasGraphics_setTextMatrix(a, b, c, d, e, f) {
  44624. this.current.textMatrix = [
  44625. a,
  44626. b,
  44627. c,
  44628. d,
  44629. e,
  44630. f
  44631. ];
  44632. this.current.textMatrixScale = Math.sqrt(a * a + b * b);
  44633. this.current.x = this.current.lineX = 0;
  44634. this.current.y = this.current.lineY = 0;
  44635. },
  44636. nextLine: function CanvasGraphics_nextLine() {
  44637. this.moveText(0, this.current.leading);
  44638. },
  44639. paintChar: function CanvasGraphics_paintChar(character, x, y) {
  44640. var ctx = this.ctx;
  44641. var current = this.current;
  44642. var font = current.font;
  44643. var textRenderingMode = current.textRenderingMode;
  44644. var fontSize = current.fontSize / current.fontSizeScale;
  44645. var fillStrokeMode = textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44646. var isAddToPathSet = !!(textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  44647. var addToPath;
  44648. if (font.disableFontFace || isAddToPathSet) {
  44649. addToPath = font.getPathGenerator(this.commonObjs, character);
  44650. }
  44651. if (font.disableFontFace) {
  44652. ctx.save();
  44653. ctx.translate(x, y);
  44654. ctx.beginPath();
  44655. addToPath(ctx, fontSize);
  44656. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44657. ctx.fill();
  44658. }
  44659. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44660. ctx.stroke();
  44661. }
  44662. ctx.restore();
  44663. } else {
  44664. if (fillStrokeMode === TextRenderingMode.FILL || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44665. ctx.fillText(character, x, y);
  44666. }
  44667. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44668. ctx.strokeText(character, x, y);
  44669. }
  44670. }
  44671. if (isAddToPathSet) {
  44672. var paths = this.pendingTextPaths || (this.pendingTextPaths = []);
  44673. paths.push({
  44674. transform: ctx.mozCurrentTransform,
  44675. x: x,
  44676. y: y,
  44677. fontSize: fontSize,
  44678. addToPath: addToPath
  44679. });
  44680. }
  44681. },
  44682. get isFontSubpixelAAEnabled() {
  44683. var ctx = document.createElement('canvas').getContext('2d');
  44684. ctx.scale(1.5, 1);
  44685. ctx.fillText('I', 0, 10);
  44686. var data = ctx.getImageData(0, 0, 10, 10).data;
  44687. var enabled = false;
  44688. for (var i = 3; i < data.length; i += 4) {
  44689. if (data[i] > 0 && data[i] < 255) {
  44690. enabled = true;
  44691. break;
  44692. }
  44693. }
  44694. return shadow(this, 'isFontSubpixelAAEnabled', enabled);
  44695. },
  44696. showText: function CanvasGraphics_showText(glyphs) {
  44697. var current = this.current;
  44698. var font = current.font;
  44699. if (font.isType3Font) {
  44700. return this.showType3Text(glyphs);
  44701. }
  44702. var fontSize = current.fontSize;
  44703. if (fontSize === 0) {
  44704. return;
  44705. }
  44706. var ctx = this.ctx;
  44707. var fontSizeScale = current.fontSizeScale;
  44708. var charSpacing = current.charSpacing;
  44709. var wordSpacing = current.wordSpacing;
  44710. var fontDirection = current.fontDirection;
  44711. var textHScale = current.textHScale * fontDirection;
  44712. var glyphsLength = glyphs.length;
  44713. var vertical = font.vertical;
  44714. var spacingDir = vertical ? 1 : -1;
  44715. var defaultVMetrics = font.defaultVMetrics;
  44716. var widthAdvanceScale = fontSize * current.fontMatrix[0];
  44717. var simpleFillText = current.textRenderingMode === TextRenderingMode.FILL && !font.disableFontFace;
  44718. ctx.save();
  44719. ctx.transform.apply(ctx, current.textMatrix);
  44720. ctx.translate(current.x, current.y + current.textRise);
  44721. if (current.patternFill) {
  44722. ctx.fillStyle = current.fillColor.getPattern(ctx, this);
  44723. }
  44724. if (fontDirection > 0) {
  44725. ctx.scale(textHScale, -1);
  44726. } else {
  44727. ctx.scale(textHScale, 1);
  44728. }
  44729. var lineWidth = current.lineWidth;
  44730. var scale = current.textMatrixScale;
  44731. if (scale === 0 || lineWidth === 0) {
  44732. var fillStrokeMode = current.textRenderingMode & TextRenderingMode.FILL_STROKE_MASK;
  44733. if (fillStrokeMode === TextRenderingMode.STROKE || fillStrokeMode === TextRenderingMode.FILL_STROKE) {
  44734. this.cachedGetSinglePixelWidth = null;
  44735. lineWidth = this.getSinglePixelWidth() * MIN_WIDTH_FACTOR;
  44736. }
  44737. } else {
  44738. lineWidth /= scale;
  44739. }
  44740. if (fontSizeScale !== 1.0) {
  44741. ctx.scale(fontSizeScale, fontSizeScale);
  44742. lineWidth /= fontSizeScale;
  44743. }
  44744. ctx.lineWidth = lineWidth;
  44745. var x = 0, i;
  44746. for (i = 0; i < glyphsLength; ++i) {
  44747. var glyph = glyphs[i];
  44748. if (isNum(glyph)) {
  44749. x += spacingDir * glyph * fontSize / 1000;
  44750. continue;
  44751. }
  44752. var restoreNeeded = false;
  44753. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44754. var character = glyph.fontChar;
  44755. var accent = glyph.accent;
  44756. var scaledX, scaledY, scaledAccentX, scaledAccentY;
  44757. var width = glyph.width;
  44758. if (vertical) {
  44759. var vmetric, vx, vy;
  44760. vmetric = glyph.vmetric || defaultVMetrics;
  44761. vx = glyph.vmetric ? vmetric[1] : width * 0.5;
  44762. vx = -vx * widthAdvanceScale;
  44763. vy = vmetric[2] * widthAdvanceScale;
  44764. width = vmetric ? -vmetric[0] : width;
  44765. scaledX = vx / fontSizeScale;
  44766. scaledY = (x + vy) / fontSizeScale;
  44767. } else {
  44768. scaledX = x / fontSizeScale;
  44769. scaledY = 0;
  44770. }
  44771. if (font.remeasure && width > 0) {
  44772. var measuredWidth = ctx.measureText(character).width * 1000 / fontSize * fontSizeScale;
  44773. if (width < measuredWidth && this.isFontSubpixelAAEnabled) {
  44774. var characterScaleX = width / measuredWidth;
  44775. restoreNeeded = true;
  44776. ctx.save();
  44777. ctx.scale(characterScaleX, 1);
  44778. scaledX /= characterScaleX;
  44779. } else if (width !== measuredWidth) {
  44780. scaledX += (width - measuredWidth) / 2000 * fontSize / fontSizeScale;
  44781. }
  44782. }
  44783. if (glyph.isInFont || font.missingFile) {
  44784. if (simpleFillText && !accent) {
  44785. ctx.fillText(character, scaledX, scaledY);
  44786. } else {
  44787. this.paintChar(character, scaledX, scaledY);
  44788. if (accent) {
  44789. scaledAccentX = scaledX + accent.offset.x / fontSizeScale;
  44790. scaledAccentY = scaledY - accent.offset.y / fontSizeScale;
  44791. this.paintChar(accent.fontChar, scaledAccentX, scaledAccentY);
  44792. }
  44793. }
  44794. }
  44795. var charWidth = width * widthAdvanceScale + spacing * fontDirection;
  44796. x += charWidth;
  44797. if (restoreNeeded) {
  44798. ctx.restore();
  44799. }
  44800. }
  44801. if (vertical) {
  44802. current.y -= x * textHScale;
  44803. } else {
  44804. current.x += x * textHScale;
  44805. }
  44806. ctx.restore();
  44807. },
  44808. showType3Text: function CanvasGraphics_showType3Text(glyphs) {
  44809. var ctx = this.ctx;
  44810. var current = this.current;
  44811. var font = current.font;
  44812. var fontSize = current.fontSize;
  44813. var fontDirection = current.fontDirection;
  44814. var spacingDir = font.vertical ? 1 : -1;
  44815. var charSpacing = current.charSpacing;
  44816. var wordSpacing = current.wordSpacing;
  44817. var textHScale = current.textHScale * fontDirection;
  44818. var fontMatrix = current.fontMatrix || FONT_IDENTITY_MATRIX;
  44819. var glyphsLength = glyphs.length;
  44820. var isTextInvisible = current.textRenderingMode === TextRenderingMode.INVISIBLE;
  44821. var i, glyph, width, spacingLength;
  44822. if (isTextInvisible || fontSize === 0) {
  44823. return;
  44824. }
  44825. this.cachedGetSinglePixelWidth = null;
  44826. ctx.save();
  44827. ctx.transform.apply(ctx, current.textMatrix);
  44828. ctx.translate(current.x, current.y);
  44829. ctx.scale(textHScale, fontDirection);
  44830. for (i = 0; i < glyphsLength; ++i) {
  44831. glyph = glyphs[i];
  44832. if (isNum(glyph)) {
  44833. spacingLength = spacingDir * glyph * fontSize / 1000;
  44834. this.ctx.translate(spacingLength, 0);
  44835. current.x += spacingLength * textHScale;
  44836. continue;
  44837. }
  44838. var spacing = (glyph.isSpace ? wordSpacing : 0) + charSpacing;
  44839. var operatorList = font.charProcOperatorList[glyph.operatorListId];
  44840. if (!operatorList) {
  44841. warn('Type3 character \"' + glyph.operatorListId + '\" is not available');
  44842. continue;
  44843. }
  44844. this.processingType3 = glyph;
  44845. this.save();
  44846. ctx.scale(fontSize, fontSize);
  44847. ctx.transform.apply(ctx, fontMatrix);
  44848. this.executeOperatorList(operatorList);
  44849. this.restore();
  44850. var transformed = Util.applyTransform([
  44851. glyph.width,
  44852. 0
  44853. ], fontMatrix);
  44854. width = transformed[0] * fontSize + spacing;
  44855. ctx.translate(width, 0);
  44856. current.x += width * textHScale;
  44857. }
  44858. ctx.restore();
  44859. this.processingType3 = null;
  44860. },
  44861. setCharWidth: function CanvasGraphics_setCharWidth(xWidth, yWidth) {
  44862. },
  44863. setCharWidthAndBounds: function CanvasGraphics_setCharWidthAndBounds(xWidth, yWidth, llx, lly, urx, ury) {
  44864. this.ctx.rect(llx, lly, urx - llx, ury - lly);
  44865. this.clip();
  44866. this.endPath();
  44867. },
  44868. getColorN_Pattern: function CanvasGraphics_getColorN_Pattern(IR) {
  44869. var pattern;
  44870. if (IR[0] === 'TilingPattern') {
  44871. var color = IR[1];
  44872. var baseTransform = this.baseTransform || this.ctx.mozCurrentTransform.slice();
  44873. var self = this;
  44874. var canvasGraphicsFactory = {
  44875. createCanvasGraphics: function (ctx) {
  44876. return new CanvasGraphics(ctx, self.commonObjs, self.objs);
  44877. }
  44878. };
  44879. pattern = new TilingPattern(IR, color, this.ctx, canvasGraphicsFactory, baseTransform);
  44880. } else {
  44881. pattern = getShadingPatternFromIR(IR);
  44882. }
  44883. return pattern;
  44884. },
  44885. setStrokeColorN: function CanvasGraphics_setStrokeColorN()
  44886. {
  44887. this.current.strokeColor = this.getColorN_Pattern(arguments);
  44888. },
  44889. setFillColorN: function CanvasGraphics_setFillColorN()
  44890. {
  44891. this.current.fillColor = this.getColorN_Pattern(arguments);
  44892. this.current.patternFill = true;
  44893. },
  44894. setStrokeRGBColor: function CanvasGraphics_setStrokeRGBColor(r, g, b) {
  44895. var color = Util.makeCssRgb(r, g, b);
  44896. this.ctx.strokeStyle = color;
  44897. this.current.strokeColor = color;
  44898. },
  44899. setFillRGBColor: function CanvasGraphics_setFillRGBColor(r, g, b) {
  44900. var color = Util.makeCssRgb(r, g, b);
  44901. this.ctx.fillStyle = color;
  44902. this.current.fillColor = color;
  44903. this.current.patternFill = false;
  44904. },
  44905. shadingFill: function CanvasGraphics_shadingFill(patternIR) {
  44906. var ctx = this.ctx;
  44907. this.save();
  44908. var pattern = getShadingPatternFromIR(patternIR);
  44909. ctx.fillStyle = pattern.getPattern(ctx, this, true);
  44910. var inv = ctx.mozCurrentTransformInverse;
  44911. if (inv) {
  44912. var canvas = ctx.canvas;
  44913. var width = canvas.width;
  44914. var height = canvas.height;
  44915. var bl = Util.applyTransform([
  44916. 0,
  44917. 0
  44918. ], inv);
  44919. var br = Util.applyTransform([
  44920. 0,
  44921. height
  44922. ], inv);
  44923. var ul = Util.applyTransform([
  44924. width,
  44925. 0
  44926. ], inv);
  44927. var ur = Util.applyTransform([
  44928. width,
  44929. height
  44930. ], inv);
  44931. var x0 = Math.min(bl[0], br[0], ul[0], ur[0]);
  44932. var y0 = Math.min(bl[1], br[1], ul[1], ur[1]);
  44933. var x1 = Math.max(bl[0], br[0], ul[0], ur[0]);
  44934. var y1 = Math.max(bl[1], br[1], ul[1], ur[1]);
  44935. this.ctx.fillRect(x0, y0, x1 - x0, y1 - y0);
  44936. } else {
  44937. this.ctx.fillRect(-1e10, -1e10, 2e10, 2e10);
  44938. }
  44939. this.restore();
  44940. },
  44941. beginInlineImage: function CanvasGraphics_beginInlineImage() {
  44942. error('Should not call beginInlineImage');
  44943. },
  44944. beginImageData: function CanvasGraphics_beginImageData() {
  44945. error('Should not call beginImageData');
  44946. },
  44947. paintFormXObjectBegin: function CanvasGraphics_paintFormXObjectBegin(matrix, bbox) {
  44948. this.save();
  44949. this.baseTransformStack.push(this.baseTransform);
  44950. if (isArray(matrix) && 6 === matrix.length) {
  44951. this.transform.apply(this, matrix);
  44952. }
  44953. this.baseTransform = this.ctx.mozCurrentTransform;
  44954. if (isArray(bbox) && 4 === bbox.length) {
  44955. var width = bbox[2] - bbox[0];
  44956. var height = bbox[3] - bbox[1];
  44957. this.ctx.rect(bbox[0], bbox[1], width, height);
  44958. this.clip();
  44959. this.endPath();
  44960. }
  44961. },
  44962. paintFormXObjectEnd: function CanvasGraphics_paintFormXObjectEnd() {
  44963. this.restore();
  44964. this.baseTransform = this.baseTransformStack.pop();
  44965. },
  44966. beginGroup: function CanvasGraphics_beginGroup(group) {
  44967. this.save();
  44968. var currentCtx = this.ctx;
  44969. if (!group.isolated) {
  44970. info('TODO: Support non-isolated groups.');
  44971. }
  44972. if (group.knockout) {
  44973. warn('Knockout groups not supported.');
  44974. }
  44975. var currentTransform = currentCtx.mozCurrentTransform;
  44976. if (group.matrix) {
  44977. currentCtx.transform.apply(currentCtx, group.matrix);
  44978. }
  44979. assert(group.bbox, 'Bounding box is required.');
  44980. var bounds = Util.getAxialAlignedBoundingBox(group.bbox, currentCtx.mozCurrentTransform);
  44981. var canvasBounds = [
  44982. 0,
  44983. 0,
  44984. currentCtx.canvas.width,
  44985. currentCtx.canvas.height
  44986. ];
  44987. bounds = Util.intersect(bounds, canvasBounds) || [
  44988. 0,
  44989. 0,
  44990. 0,
  44991. 0
  44992. ];
  44993. var offsetX = Math.floor(bounds[0]);
  44994. var offsetY = Math.floor(bounds[1]);
  44995. var drawnWidth = Math.max(Math.ceil(bounds[2]) - offsetX, 1);
  44996. var drawnHeight = Math.max(Math.ceil(bounds[3]) - offsetY, 1);
  44997. var scaleX = 1, scaleY = 1;
  44998. if (drawnWidth > MAX_GROUP_SIZE) {
  44999. scaleX = drawnWidth / MAX_GROUP_SIZE;
  45000. drawnWidth = MAX_GROUP_SIZE;
  45001. }
  45002. if (drawnHeight > MAX_GROUP_SIZE) {
  45003. scaleY = drawnHeight / MAX_GROUP_SIZE;
  45004. drawnHeight = MAX_GROUP_SIZE;
  45005. }
  45006. var cacheId = 'groupAt' + this.groupLevel;
  45007. if (group.smask) {
  45008. cacheId += '_smask_' + this.smaskCounter++ % 2;
  45009. }
  45010. var scratchCanvas = this.cachedCanvases.getCanvas(cacheId, drawnWidth, drawnHeight, true);
  45011. var groupCtx = scratchCanvas.context;
  45012. groupCtx.scale(1 / scaleX, 1 / scaleY);
  45013. groupCtx.translate(-offsetX, -offsetY);
  45014. groupCtx.transform.apply(groupCtx, currentTransform);
  45015. if (group.smask) {
  45016. this.smaskStack.push({
  45017. canvas: scratchCanvas.canvas,
  45018. context: groupCtx,
  45019. offsetX: offsetX,
  45020. offsetY: offsetY,
  45021. scaleX: scaleX,
  45022. scaleY: scaleY,
  45023. subtype: group.smask.subtype,
  45024. backdrop: group.smask.backdrop,
  45025. transferMap: group.smask.transferMap || null,
  45026. startTransformInverse: null
  45027. });
  45028. } else
  45029. {
  45030. currentCtx.setTransform(1, 0, 0, 1, 0, 0);
  45031. currentCtx.translate(offsetX, offsetY);
  45032. currentCtx.scale(scaleX, scaleY);
  45033. }
  45034. copyCtxState(currentCtx, groupCtx);
  45035. this.ctx = groupCtx;
  45036. this.setGState([
  45037. [
  45038. 'BM',
  45039. 'Normal'
  45040. ],
  45041. [
  45042. 'ca',
  45043. 1
  45044. ],
  45045. [
  45046. 'CA',
  45047. 1
  45048. ]
  45049. ]);
  45050. this.groupStack.push(currentCtx);
  45051. this.groupLevel++;
  45052. this.current.activeSMask = null;
  45053. },
  45054. endGroup: function CanvasGraphics_endGroup(group) {
  45055. this.groupLevel--;
  45056. var groupCtx = this.ctx;
  45057. this.ctx = this.groupStack.pop();
  45058. if (this.ctx.imageSmoothingEnabled !== undefined) {
  45059. this.ctx.imageSmoothingEnabled = false;
  45060. } else {
  45061. this.ctx.mozImageSmoothingEnabled = false;
  45062. }
  45063. if (group.smask) {
  45064. this.tempSMask = this.smaskStack.pop();
  45065. } else {
  45066. this.ctx.drawImage(groupCtx.canvas, 0, 0);
  45067. }
  45068. this.restore();
  45069. },
  45070. beginAnnotations: function CanvasGraphics_beginAnnotations() {
  45071. this.save();
  45072. this.current = new CanvasExtraState();
  45073. if (this.baseTransform) {
  45074. this.ctx.setTransform.apply(this.ctx, this.baseTransform);
  45075. }
  45076. },
  45077. endAnnotations: function CanvasGraphics_endAnnotations() {
  45078. this.restore();
  45079. },
  45080. beginAnnotation: function CanvasGraphics_beginAnnotation(rect, transform, matrix) {
  45081. this.save();
  45082. if (isArray(rect) && 4 === rect.length) {
  45083. var width = rect[2] - rect[0];
  45084. var height = rect[3] - rect[1];
  45085. this.ctx.rect(rect[0], rect[1], width, height);
  45086. this.clip();
  45087. this.endPath();
  45088. }
  45089. this.transform.apply(this, transform);
  45090. this.transform.apply(this, matrix);
  45091. },
  45092. endAnnotation: function CanvasGraphics_endAnnotation() {
  45093. this.restore();
  45094. },
  45095. paintJpegXObject: function CanvasGraphics_paintJpegXObject(objId, w, h) {
  45096. var domImage = this.objs.get(objId);
  45097. if (!domImage) {
  45098. warn('Dependent image isn\'t ready yet');
  45099. return;
  45100. }
  45101. this.save();
  45102. var ctx = this.ctx;
  45103. ctx.scale(1 / w, -1 / h);
  45104. ctx.drawImage(domImage, 0, 0, domImage.width, domImage.height, 0, -h, w, h);
  45105. if (this.imageLayer) {
  45106. var currentTransform = ctx.mozCurrentTransformInverse;
  45107. var position = this.getCanvasPosition(0, 0);
  45108. this.imageLayer.appendImage({
  45109. objId: objId,
  45110. left: position[0],
  45111. top: position[1],
  45112. width: w / currentTransform[0],
  45113. height: h / currentTransform[3]
  45114. });
  45115. }
  45116. this.restore();
  45117. },
  45118. paintImageMaskXObject: function CanvasGraphics_paintImageMaskXObject(img) {
  45119. var ctx = this.ctx;
  45120. var width = img.width, height = img.height;
  45121. var fillColor = this.current.fillColor;
  45122. var isPatternFill = this.current.patternFill;
  45123. var glyph = this.processingType3;
  45124. if (COMPILE_TYPE3_GLYPHS && glyph && glyph.compiled === undefined) {
  45125. if (width <= MAX_SIZE_TO_COMPILE && height <= MAX_SIZE_TO_COMPILE) {
  45126. glyph.compiled = compileType3Glyph({
  45127. data: img.data,
  45128. width: width,
  45129. height: height
  45130. });
  45131. } else {
  45132. glyph.compiled = null;
  45133. }
  45134. }
  45135. if (glyph && glyph.compiled) {
  45136. glyph.compiled(ctx);
  45137. return;
  45138. }
  45139. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45140. var maskCtx = maskCanvas.context;
  45141. maskCtx.save();
  45142. putBinaryImageMask(maskCtx, img);
  45143. maskCtx.globalCompositeOperation = 'source-in';
  45144. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45145. maskCtx.fillRect(0, 0, width, height);
  45146. maskCtx.restore();
  45147. this.paintInlineImageXObject(maskCanvas.canvas);
  45148. },
  45149. paintImageMaskXObjectRepeat: function CanvasGraphics_paintImageMaskXObjectRepeat(imgData, scaleX, scaleY, positions) {
  45150. var width = imgData.width;
  45151. var height = imgData.height;
  45152. var fillColor = this.current.fillColor;
  45153. var isPatternFill = this.current.patternFill;
  45154. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45155. var maskCtx = maskCanvas.context;
  45156. maskCtx.save();
  45157. putBinaryImageMask(maskCtx, imgData);
  45158. maskCtx.globalCompositeOperation = 'source-in';
  45159. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45160. maskCtx.fillRect(0, 0, width, height);
  45161. maskCtx.restore();
  45162. var ctx = this.ctx;
  45163. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45164. ctx.save();
  45165. ctx.transform(scaleX, 0, 0, scaleY, positions[i], positions[i + 1]);
  45166. ctx.scale(1, -1);
  45167. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45168. ctx.restore();
  45169. }
  45170. },
  45171. paintImageMaskXObjectGroup: function CanvasGraphics_paintImageMaskXObjectGroup(images) {
  45172. var ctx = this.ctx;
  45173. var fillColor = this.current.fillColor;
  45174. var isPatternFill = this.current.patternFill;
  45175. for (var i = 0, ii = images.length; i < ii; i++) {
  45176. var image = images[i];
  45177. var width = image.width, height = image.height;
  45178. var maskCanvas = this.cachedCanvases.getCanvas('maskCanvas', width, height);
  45179. var maskCtx = maskCanvas.context;
  45180. maskCtx.save();
  45181. putBinaryImageMask(maskCtx, image);
  45182. maskCtx.globalCompositeOperation = 'source-in';
  45183. maskCtx.fillStyle = isPatternFill ? fillColor.getPattern(maskCtx, this) : fillColor;
  45184. maskCtx.fillRect(0, 0, width, height);
  45185. maskCtx.restore();
  45186. ctx.save();
  45187. ctx.transform.apply(ctx, image.transform);
  45188. ctx.scale(1, -1);
  45189. ctx.drawImage(maskCanvas.canvas, 0, 0, width, height, 0, -1, 1, 1);
  45190. ctx.restore();
  45191. }
  45192. },
  45193. paintImageXObject: function CanvasGraphics_paintImageXObject(objId) {
  45194. var imgData = this.objs.get(objId);
  45195. if (!imgData) {
  45196. warn('Dependent image isn\'t ready yet');
  45197. return;
  45198. }
  45199. this.paintInlineImageXObject(imgData);
  45200. },
  45201. paintImageXObjectRepeat: function CanvasGraphics_paintImageXObjectRepeat(objId, scaleX, scaleY, positions) {
  45202. var imgData = this.objs.get(objId);
  45203. if (!imgData) {
  45204. warn('Dependent image isn\'t ready yet');
  45205. return;
  45206. }
  45207. var width = imgData.width;
  45208. var height = imgData.height;
  45209. var map = [];
  45210. for (var i = 0, ii = positions.length; i < ii; i += 2) {
  45211. map.push({
  45212. transform: [
  45213. scaleX,
  45214. 0,
  45215. 0,
  45216. scaleY,
  45217. positions[i],
  45218. positions[i + 1]
  45219. ],
  45220. x: 0,
  45221. y: 0,
  45222. w: width,
  45223. h: height
  45224. });
  45225. }
  45226. this.paintInlineImageXObjectGroup(imgData, map);
  45227. },
  45228. paintInlineImageXObject: function CanvasGraphics_paintInlineImageXObject(imgData) {
  45229. var width = imgData.width;
  45230. var height = imgData.height;
  45231. var ctx = this.ctx;
  45232. this.save();
  45233. ctx.scale(1 / width, -1 / height);
  45234. var currentTransform = ctx.mozCurrentTransformInverse;
  45235. var a = currentTransform[0], b = currentTransform[1];
  45236. var widthScale = Math.max(Math.sqrt(a * a + b * b), 1);
  45237. var c = currentTransform[2], d = currentTransform[3];
  45238. var heightScale = Math.max(Math.sqrt(c * c + d * d), 1);
  45239. var imgToPaint, tmpCanvas;
  45240. if (imgData instanceof HTMLElement || !imgData.data) {
  45241. imgToPaint = imgData;
  45242. } else {
  45243. tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', width, height);
  45244. var tmpCtx = tmpCanvas.context;
  45245. putBinaryImageData(tmpCtx, imgData);
  45246. imgToPaint = tmpCanvas.canvas;
  45247. }
  45248. var paintWidth = width, paintHeight = height;
  45249. var tmpCanvasId = 'prescale1';
  45250. while (widthScale > 2 && paintWidth > 1 || heightScale > 2 && paintHeight > 1) {
  45251. var newWidth = paintWidth, newHeight = paintHeight;
  45252. if (widthScale > 2 && paintWidth > 1) {
  45253. newWidth = Math.ceil(paintWidth / 2);
  45254. widthScale /= paintWidth / newWidth;
  45255. }
  45256. if (heightScale > 2 && paintHeight > 1) {
  45257. newHeight = Math.ceil(paintHeight / 2);
  45258. heightScale /= paintHeight / newHeight;
  45259. }
  45260. tmpCanvas = this.cachedCanvases.getCanvas(tmpCanvasId, newWidth, newHeight);
  45261. tmpCtx = tmpCanvas.context;
  45262. tmpCtx.clearRect(0, 0, newWidth, newHeight);
  45263. tmpCtx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, 0, newWidth, newHeight);
  45264. imgToPaint = tmpCanvas.canvas;
  45265. paintWidth = newWidth;
  45266. paintHeight = newHeight;
  45267. tmpCanvasId = tmpCanvasId === 'prescale1' ? 'prescale2' : 'prescale1';
  45268. }
  45269. ctx.drawImage(imgToPaint, 0, 0, paintWidth, paintHeight, 0, -height, width, height);
  45270. if (this.imageLayer) {
  45271. var position = this.getCanvasPosition(0, -height);
  45272. this.imageLayer.appendImage({
  45273. imgData: imgData,
  45274. left: position[0],
  45275. top: position[1],
  45276. width: width / currentTransform[0],
  45277. height: height / currentTransform[3]
  45278. });
  45279. }
  45280. this.restore();
  45281. },
  45282. paintInlineImageXObjectGroup: function CanvasGraphics_paintInlineImageXObjectGroup(imgData, map) {
  45283. var ctx = this.ctx;
  45284. var w = imgData.width;
  45285. var h = imgData.height;
  45286. var tmpCanvas = this.cachedCanvases.getCanvas('inlineImage', w, h);
  45287. var tmpCtx = tmpCanvas.context;
  45288. putBinaryImageData(tmpCtx, imgData);
  45289. for (var i = 0, ii = map.length; i < ii; i++) {
  45290. var entry = map[i];
  45291. ctx.save();
  45292. ctx.transform.apply(ctx, entry.transform);
  45293. ctx.scale(1, -1);
  45294. ctx.drawImage(tmpCanvas.canvas, entry.x, entry.y, entry.w, entry.h, 0, -1, 1, 1);
  45295. if (this.imageLayer) {
  45296. var position = this.getCanvasPosition(entry.x, entry.y);
  45297. this.imageLayer.appendImage({
  45298. imgData: imgData,
  45299. left: position[0],
  45300. top: position[1],
  45301. width: w,
  45302. height: h
  45303. });
  45304. }
  45305. ctx.restore();
  45306. }
  45307. },
  45308. paintSolidColorImageMask: function CanvasGraphics_paintSolidColorImageMask() {
  45309. this.ctx.fillRect(0, 0, 1, 1);
  45310. },
  45311. paintXObject: function CanvasGraphics_paintXObject() {
  45312. warn('Unsupported \'paintXObject\' command.');
  45313. },
  45314. markPoint: function CanvasGraphics_markPoint(tag) {
  45315. },
  45316. markPointProps: function CanvasGraphics_markPointProps(tag, properties) {
  45317. },
  45318. beginMarkedContent: function CanvasGraphics_beginMarkedContent(tag) {
  45319. },
  45320. beginMarkedContentProps: function CanvasGraphics_beginMarkedContentProps(tag, properties) {
  45321. },
  45322. endMarkedContent: function CanvasGraphics_endMarkedContent() {
  45323. },
  45324. beginCompat: function CanvasGraphics_beginCompat() {
  45325. },
  45326. endCompat: function CanvasGraphics_endCompat() {
  45327. },
  45328. consumePath: function CanvasGraphics_consumePath() {
  45329. var ctx = this.ctx;
  45330. if (this.pendingClip) {
  45331. if (this.pendingClip === EO_CLIP) {
  45332. if (ctx.mozFillRule !== undefined) {
  45333. ctx.mozFillRule = 'evenodd';
  45334. ctx.clip();
  45335. ctx.mozFillRule = 'nonzero';
  45336. } else {
  45337. ctx.clip('evenodd');
  45338. }
  45339. } else {
  45340. ctx.clip();
  45341. }
  45342. this.pendingClip = null;
  45343. }
  45344. ctx.beginPath();
  45345. },
  45346. getSinglePixelWidth: function CanvasGraphics_getSinglePixelWidth(scale) {
  45347. if (this.cachedGetSinglePixelWidth === null) {
  45348. this.ctx.save();
  45349. var inverse = this.ctx.mozCurrentTransformInverse;
  45350. this.ctx.restore();
  45351. this.cachedGetSinglePixelWidth = Math.sqrt(Math.max(inverse[0] * inverse[0] + inverse[1] * inverse[1], inverse[2] * inverse[2] + inverse[3] * inverse[3]));
  45352. }
  45353. return this.cachedGetSinglePixelWidth;
  45354. },
  45355. getCanvasPosition: function CanvasGraphics_getCanvasPosition(x, y) {
  45356. var transform = this.ctx.mozCurrentTransform;
  45357. return [
  45358. transform[0] * x + transform[2] * y + transform[4],
  45359. transform[1] * x + transform[3] * y + transform[5]
  45360. ];
  45361. }
  45362. };
  45363. for (var op in OPS) {
  45364. CanvasGraphics.prototype[OPS[op]] = CanvasGraphics.prototype[op];
  45365. }
  45366. return CanvasGraphics;
  45367. }();
  45368. exports.CanvasGraphics = CanvasGraphics;
  45369. exports.createScratchCanvas = createScratchCanvas;
  45370. }));
  45371. (function (root, factory) {
  45372. factory(root.pdfjsCoreFunction = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePsParser);
  45373. }(this, function (exports, sharedUtil, corePrimitives, corePsParser) {
  45374. var error = sharedUtil.error;
  45375. var info = sharedUtil.info;
  45376. var isArray = sharedUtil.isArray;
  45377. var isBool = sharedUtil.isBool;
  45378. var isDict = corePrimitives.isDict;
  45379. var isStream = corePrimitives.isStream;
  45380. var PostScriptLexer = corePsParser.PostScriptLexer;
  45381. var PostScriptParser = corePsParser.PostScriptParser;
  45382. var PDFFunction = function PDFFunctionClosure() {
  45383. var CONSTRUCT_SAMPLED = 0;
  45384. var CONSTRUCT_INTERPOLATED = 2;
  45385. var CONSTRUCT_STICHED = 3;
  45386. var CONSTRUCT_POSTSCRIPT = 4;
  45387. return {
  45388. getSampleArray: function PDFFunction_getSampleArray(size, outputSize, bps, str) {
  45389. var i, ii;
  45390. var length = 1;
  45391. for (i = 0, ii = size.length; i < ii; i++) {
  45392. length *= size[i];
  45393. }
  45394. length *= outputSize;
  45395. var array = new Array(length);
  45396. var codeSize = 0;
  45397. var codeBuf = 0;
  45398. var sampleMul = 1.0 / (Math.pow(2.0, bps) - 1);
  45399. var strBytes = str.getBytes((length * bps + 7) / 8);
  45400. var strIdx = 0;
  45401. for (i = 0; i < length; i++) {
  45402. while (codeSize < bps) {
  45403. codeBuf <<= 8;
  45404. codeBuf |= strBytes[strIdx++];
  45405. codeSize += 8;
  45406. }
  45407. codeSize -= bps;
  45408. array[i] = (codeBuf >> codeSize) * sampleMul;
  45409. codeBuf &= (1 << codeSize) - 1;
  45410. }
  45411. return array;
  45412. },
  45413. getIR: function PDFFunction_getIR(xref, fn) {
  45414. var dict = fn.dict;
  45415. if (!dict) {
  45416. dict = fn;
  45417. }
  45418. var types = [
  45419. this.constructSampled,
  45420. null,
  45421. this.constructInterpolated,
  45422. this.constructStiched,
  45423. this.constructPostScript
  45424. ];
  45425. var typeNum = dict.get('FunctionType');
  45426. var typeFn = types[typeNum];
  45427. if (!typeFn) {
  45428. error('Unknown type of function');
  45429. }
  45430. return typeFn.call(this, fn, dict, xref);
  45431. },
  45432. fromIR: function PDFFunction_fromIR(IR) {
  45433. var type = IR[0];
  45434. switch (type) {
  45435. case CONSTRUCT_SAMPLED:
  45436. return this.constructSampledFromIR(IR);
  45437. case CONSTRUCT_INTERPOLATED:
  45438. return this.constructInterpolatedFromIR(IR);
  45439. case CONSTRUCT_STICHED:
  45440. return this.constructStichedFromIR(IR);
  45441. default:
  45442. return this.constructPostScriptFromIR(IR);
  45443. }
  45444. },
  45445. parse: function PDFFunction_parse(xref, fn) {
  45446. var IR = this.getIR(xref, fn);
  45447. return this.fromIR(IR);
  45448. },
  45449. parseArray: function PDFFunction_parseArray(xref, fnObj) {
  45450. if (!isArray(fnObj)) {
  45451. return this.parse(xref, fnObj);
  45452. }
  45453. var fnArray = [];
  45454. for (var j = 0, jj = fnObj.length; j < jj; j++) {
  45455. var obj = xref.fetchIfRef(fnObj[j]);
  45456. fnArray.push(PDFFunction.parse(xref, obj));
  45457. }
  45458. return function (src, srcOffset, dest, destOffset) {
  45459. for (var i = 0, ii = fnArray.length; i < ii; i++) {
  45460. fnArray[i](src, srcOffset, dest, destOffset + i);
  45461. }
  45462. };
  45463. },
  45464. constructSampled: function PDFFunction_constructSampled(str, dict) {
  45465. function toMultiArray(arr) {
  45466. var inputLength = arr.length;
  45467. var out = [];
  45468. var index = 0;
  45469. for (var i = 0; i < inputLength; i += 2) {
  45470. out[index] = [
  45471. arr[i],
  45472. arr[i + 1]
  45473. ];
  45474. ++index;
  45475. }
  45476. return out;
  45477. }
  45478. var domain = dict.getArray('Domain');
  45479. var range = dict.getArray('Range');
  45480. if (!domain || !range) {
  45481. error('No domain or range');
  45482. }
  45483. var inputSize = domain.length / 2;
  45484. var outputSize = range.length / 2;
  45485. domain = toMultiArray(domain);
  45486. range = toMultiArray(range);
  45487. var size = dict.get('Size');
  45488. var bps = dict.get('BitsPerSample');
  45489. var order = dict.get('Order') || 1;
  45490. if (order !== 1) {
  45491. info('No support for cubic spline interpolation: ' + order);
  45492. }
  45493. var encode = dict.getArray('Encode');
  45494. if (!encode) {
  45495. encode = [];
  45496. for (var i = 0; i < inputSize; ++i) {
  45497. encode.push(0);
  45498. encode.push(size[i] - 1);
  45499. }
  45500. }
  45501. encode = toMultiArray(encode);
  45502. var decode = dict.getArray('Decode');
  45503. if (!decode) {
  45504. decode = range;
  45505. } else {
  45506. decode = toMultiArray(decode);
  45507. }
  45508. var samples = this.getSampleArray(size, outputSize, bps, str);
  45509. return [
  45510. CONSTRUCT_SAMPLED,
  45511. inputSize,
  45512. domain,
  45513. encode,
  45514. decode,
  45515. samples,
  45516. size,
  45517. outputSize,
  45518. Math.pow(2, bps) - 1,
  45519. range
  45520. ];
  45521. },
  45522. constructSampledFromIR: function PDFFunction_constructSampledFromIR(IR) {
  45523. function interpolate(x, xmin, xmax, ymin, ymax) {
  45524. return ymin + (x - xmin) * ((ymax - ymin) / (xmax - xmin));
  45525. }
  45526. return function constructSampledFromIRResult(src, srcOffset, dest, destOffset) {
  45527. var m = IR[1];
  45528. var domain = IR[2];
  45529. var encode = IR[3];
  45530. var decode = IR[4];
  45531. var samples = IR[5];
  45532. var size = IR[6];
  45533. var n = IR[7];
  45534. var range = IR[9];
  45535. var cubeVertices = 1 << m;
  45536. var cubeN = new Float64Array(cubeVertices);
  45537. var cubeVertex = new Uint32Array(cubeVertices);
  45538. var i, j;
  45539. for (j = 0; j < cubeVertices; j++) {
  45540. cubeN[j] = 1;
  45541. }
  45542. var k = n, pos = 1;
  45543. for (i = 0; i < m; ++i) {
  45544. var domain_2i = domain[i][0];
  45545. var domain_2i_1 = domain[i][1];
  45546. var xi = Math.min(Math.max(src[srcOffset + i], domain_2i), domain_2i_1);
  45547. var e = interpolate(xi, domain_2i, domain_2i_1, encode[i][0], encode[i][1]);
  45548. var size_i = size[i];
  45549. e = Math.min(Math.max(e, 0), size_i - 1);
  45550. var e0 = e < size_i - 1 ? Math.floor(e) : e - 1;
  45551. var n0 = e0 + 1 - e;
  45552. var n1 = e - e0;
  45553. var offset0 = e0 * k;
  45554. var offset1 = offset0 + k;
  45555. for (j = 0; j < cubeVertices; j++) {
  45556. if (j & pos) {
  45557. cubeN[j] *= n1;
  45558. cubeVertex[j] += offset1;
  45559. } else {
  45560. cubeN[j] *= n0;
  45561. cubeVertex[j] += offset0;
  45562. }
  45563. }
  45564. k *= size_i;
  45565. pos <<= 1;
  45566. }
  45567. for (j = 0; j < n; ++j) {
  45568. var rj = 0;
  45569. for (i = 0; i < cubeVertices; i++) {
  45570. rj += samples[cubeVertex[i] + j] * cubeN[i];
  45571. }
  45572. rj = interpolate(rj, 0, 1, decode[j][0], decode[j][1]);
  45573. dest[destOffset + j] = Math.min(Math.max(rj, range[j][0]), range[j][1]);
  45574. }
  45575. };
  45576. },
  45577. constructInterpolated: function PDFFunction_constructInterpolated(str, dict) {
  45578. var c0 = dict.getArray('C0') || [0];
  45579. var c1 = dict.getArray('C1') || [1];
  45580. var n = dict.get('N');
  45581. if (!isArray(c0) || !isArray(c1)) {
  45582. error('Illegal dictionary for interpolated function');
  45583. }
  45584. var length = c0.length;
  45585. var diff = [];
  45586. for (var i = 0; i < length; ++i) {
  45587. diff.push(c1[i] - c0[i]);
  45588. }
  45589. return [
  45590. CONSTRUCT_INTERPOLATED,
  45591. c0,
  45592. diff,
  45593. n
  45594. ];
  45595. },
  45596. constructInterpolatedFromIR: function PDFFunction_constructInterpolatedFromIR(IR) {
  45597. var c0 = IR[1];
  45598. var diff = IR[2];
  45599. var n = IR[3];
  45600. var length = diff.length;
  45601. return function constructInterpolatedFromIRResult(src, srcOffset, dest, destOffset) {
  45602. var x = n === 1 ? src[srcOffset] : Math.pow(src[srcOffset], n);
  45603. for (var j = 0; j < length; ++j) {
  45604. dest[destOffset + j] = c0[j] + x * diff[j];
  45605. }
  45606. };
  45607. },
  45608. constructStiched: function PDFFunction_constructStiched(fn, dict, xref) {
  45609. var domain = dict.getArray('Domain');
  45610. if (!domain) {
  45611. error('No domain');
  45612. }
  45613. var inputSize = domain.length / 2;
  45614. if (inputSize !== 1) {
  45615. error('Bad domain for stiched function');
  45616. }
  45617. var fnRefs = dict.get('Functions');
  45618. var fns = [];
  45619. for (var i = 0, ii = fnRefs.length; i < ii; ++i) {
  45620. fns.push(PDFFunction.getIR(xref, xref.fetchIfRef(fnRefs[i])));
  45621. }
  45622. var bounds = dict.getArray('Bounds');
  45623. var encode = dict.getArray('Encode');
  45624. return [
  45625. CONSTRUCT_STICHED,
  45626. domain,
  45627. bounds,
  45628. encode,
  45629. fns
  45630. ];
  45631. },
  45632. constructStichedFromIR: function PDFFunction_constructStichedFromIR(IR) {
  45633. var domain = IR[1];
  45634. var bounds = IR[2];
  45635. var encode = IR[3];
  45636. var fnsIR = IR[4];
  45637. var fns = [];
  45638. var tmpBuf = new Float32Array(1);
  45639. for (var i = 0, ii = fnsIR.length; i < ii; i++) {
  45640. fns.push(PDFFunction.fromIR(fnsIR[i]));
  45641. }
  45642. return function constructStichedFromIRResult(src, srcOffset, dest, destOffset) {
  45643. var clip = function constructStichedFromIRClip(v, min, max) {
  45644. if (v > max) {
  45645. v = max;
  45646. } else if (v < min) {
  45647. v = min;
  45648. }
  45649. return v;
  45650. };
  45651. var v = clip(src[srcOffset], domain[0], domain[1]);
  45652. for (var i = 0, ii = bounds.length; i < ii; ++i) {
  45653. if (v < bounds[i]) {
  45654. break;
  45655. }
  45656. }
  45657. var dmin = domain[0];
  45658. if (i > 0) {
  45659. dmin = bounds[i - 1];
  45660. }
  45661. var dmax = domain[1];
  45662. if (i < bounds.length) {
  45663. dmax = bounds[i];
  45664. }
  45665. var rmin = encode[2 * i];
  45666. var rmax = encode[2 * i + 1];
  45667. tmpBuf[0] = dmin === dmax ? rmin : rmin + (v - dmin) * (rmax - rmin) / (dmax - dmin);
  45668. fns[i](tmpBuf, 0, dest, destOffset);
  45669. };
  45670. },
  45671. constructPostScript: function PDFFunction_constructPostScript(fn, dict, xref) {
  45672. var domain = dict.getArray('Domain');
  45673. var range = dict.getArray('Range');
  45674. if (!domain) {
  45675. error('No domain.');
  45676. }
  45677. if (!range) {
  45678. error('No range.');
  45679. }
  45680. var lexer = new PostScriptLexer(fn);
  45681. var parser = new PostScriptParser(lexer);
  45682. var code = parser.parse();
  45683. return [
  45684. CONSTRUCT_POSTSCRIPT,
  45685. domain,
  45686. range,
  45687. code
  45688. ];
  45689. },
  45690. constructPostScriptFromIR: function PDFFunction_constructPostScriptFromIR(IR) {
  45691. var domain = IR[1];
  45692. var range = IR[2];
  45693. var code = IR[3];
  45694. var compiled = new PostScriptCompiler().compile(code, domain, range);
  45695. if (compiled) {
  45696. return new Function('src', 'srcOffset', 'dest', 'destOffset', compiled);
  45697. }
  45698. info('Unable to compile PS function');
  45699. var numOutputs = range.length >> 1;
  45700. var numInputs = domain.length >> 1;
  45701. var evaluator = new PostScriptEvaluator(code);
  45702. var cache = Object.create(null);
  45703. var MAX_CACHE_SIZE = 2048 * 4;
  45704. var cache_available = MAX_CACHE_SIZE;
  45705. var tmpBuf = new Float32Array(numInputs);
  45706. return function constructPostScriptFromIRResult(src, srcOffset, dest, destOffset) {
  45707. var i, value;
  45708. var key = '';
  45709. var input = tmpBuf;
  45710. for (i = 0; i < numInputs; i++) {
  45711. value = src[srcOffset + i];
  45712. input[i] = value;
  45713. key += value + '_';
  45714. }
  45715. var cachedValue = cache[key];
  45716. if (cachedValue !== undefined) {
  45717. dest.set(cachedValue, destOffset);
  45718. return;
  45719. }
  45720. var output = new Float32Array(numOutputs);
  45721. var stack = evaluator.execute(input);
  45722. var stackIndex = stack.length - numOutputs;
  45723. for (i = 0; i < numOutputs; i++) {
  45724. value = stack[stackIndex + i];
  45725. var bound = range[i * 2];
  45726. if (value < bound) {
  45727. value = bound;
  45728. } else {
  45729. bound = range[i * 2 + 1];
  45730. if (value > bound) {
  45731. value = bound;
  45732. }
  45733. }
  45734. output[i] = value;
  45735. }
  45736. if (cache_available > 0) {
  45737. cache_available--;
  45738. cache[key] = output;
  45739. }
  45740. dest.set(output, destOffset);
  45741. };
  45742. }
  45743. };
  45744. }();
  45745. function isPDFFunction(v) {
  45746. var fnDict;
  45747. if (typeof v !== 'object') {
  45748. return false;
  45749. } else if (isDict(v)) {
  45750. fnDict = v;
  45751. } else if (isStream(v)) {
  45752. fnDict = v.dict;
  45753. } else {
  45754. return false;
  45755. }
  45756. return fnDict.has('FunctionType');
  45757. }
  45758. var PostScriptStack = function PostScriptStackClosure() {
  45759. var MAX_STACK_SIZE = 100;
  45760. function PostScriptStack(initialStack) {
  45761. this.stack = !initialStack ? [] : Array.prototype.slice.call(initialStack, 0);
  45762. }
  45763. PostScriptStack.prototype = {
  45764. push: function PostScriptStack_push(value) {
  45765. if (this.stack.length >= MAX_STACK_SIZE) {
  45766. error('PostScript function stack overflow.');
  45767. }
  45768. this.stack.push(value);
  45769. },
  45770. pop: function PostScriptStack_pop() {
  45771. if (this.stack.length <= 0) {
  45772. error('PostScript function stack underflow.');
  45773. }
  45774. return this.stack.pop();
  45775. },
  45776. copy: function PostScriptStack_copy(n) {
  45777. if (this.stack.length + n >= MAX_STACK_SIZE) {
  45778. error('PostScript function stack overflow.');
  45779. }
  45780. var stack = this.stack;
  45781. for (var i = stack.length - n, j = n - 1; j >= 0; j--, i++) {
  45782. stack.push(stack[i]);
  45783. }
  45784. },
  45785. index: function PostScriptStack_index(n) {
  45786. this.push(this.stack[this.stack.length - n - 1]);
  45787. },
  45788. roll: function PostScriptStack_roll(n, p) {
  45789. var stack = this.stack;
  45790. var l = stack.length - n;
  45791. var r = stack.length - 1, c = l + (p - Math.floor(p / n) * n), i, j, t;
  45792. for (i = l, j = r; i < j; i++, j--) {
  45793. t = stack[i];
  45794. stack[i] = stack[j];
  45795. stack[j] = t;
  45796. }
  45797. for (i = l, j = c - 1; i < j; i++, j--) {
  45798. t = stack[i];
  45799. stack[i] = stack[j];
  45800. stack[j] = t;
  45801. }
  45802. for (i = c, j = r; i < j; i++, j--) {
  45803. t = stack[i];
  45804. stack[i] = stack[j];
  45805. stack[j] = t;
  45806. }
  45807. }
  45808. };
  45809. return PostScriptStack;
  45810. }();
  45811. var PostScriptEvaluator = function PostScriptEvaluatorClosure() {
  45812. function PostScriptEvaluator(operators) {
  45813. this.operators = operators;
  45814. }
  45815. PostScriptEvaluator.prototype = {
  45816. execute: function PostScriptEvaluator_execute(initialStack) {
  45817. var stack = new PostScriptStack(initialStack);
  45818. var counter = 0;
  45819. var operators = this.operators;
  45820. var length = operators.length;
  45821. var operator, a, b;
  45822. while (counter < length) {
  45823. operator = operators[counter++];
  45824. if (typeof operator === 'number') {
  45825. stack.push(operator);
  45826. continue;
  45827. }
  45828. switch (operator) {
  45829. case 'jz':
  45830. b = stack.pop();
  45831. a = stack.pop();
  45832. if (!a) {
  45833. counter = b;
  45834. }
  45835. break;
  45836. case 'j':
  45837. a = stack.pop();
  45838. counter = a;
  45839. break;
  45840. case 'abs':
  45841. a = stack.pop();
  45842. stack.push(Math.abs(a));
  45843. break;
  45844. case 'add':
  45845. b = stack.pop();
  45846. a = stack.pop();
  45847. stack.push(a + b);
  45848. break;
  45849. case 'and':
  45850. b = stack.pop();
  45851. a = stack.pop();
  45852. if (isBool(a) && isBool(b)) {
  45853. stack.push(a && b);
  45854. } else {
  45855. stack.push(a & b);
  45856. }
  45857. break;
  45858. case 'atan':
  45859. a = stack.pop();
  45860. stack.push(Math.atan(a));
  45861. break;
  45862. case 'bitshift':
  45863. b = stack.pop();
  45864. a = stack.pop();
  45865. if (a > 0) {
  45866. stack.push(a << b);
  45867. } else {
  45868. stack.push(a >> b);
  45869. }
  45870. break;
  45871. case 'ceiling':
  45872. a = stack.pop();
  45873. stack.push(Math.ceil(a));
  45874. break;
  45875. case 'copy':
  45876. a = stack.pop();
  45877. stack.copy(a);
  45878. break;
  45879. case 'cos':
  45880. a = stack.pop();
  45881. stack.push(Math.cos(a));
  45882. break;
  45883. case 'cvi':
  45884. a = stack.pop() | 0;
  45885. stack.push(a);
  45886. break;
  45887. case 'cvr':
  45888. break;
  45889. case 'div':
  45890. b = stack.pop();
  45891. a = stack.pop();
  45892. stack.push(a / b);
  45893. break;
  45894. case 'dup':
  45895. stack.copy(1);
  45896. break;
  45897. case 'eq':
  45898. b = stack.pop();
  45899. a = stack.pop();
  45900. stack.push(a === b);
  45901. break;
  45902. case 'exch':
  45903. stack.roll(2, 1);
  45904. break;
  45905. case 'exp':
  45906. b = stack.pop();
  45907. a = stack.pop();
  45908. stack.push(Math.pow(a, b));
  45909. break;
  45910. case 'false':
  45911. stack.push(false);
  45912. break;
  45913. case 'floor':
  45914. a = stack.pop();
  45915. stack.push(Math.floor(a));
  45916. break;
  45917. case 'ge':
  45918. b = stack.pop();
  45919. a = stack.pop();
  45920. stack.push(a >= b);
  45921. break;
  45922. case 'gt':
  45923. b = stack.pop();
  45924. a = stack.pop();
  45925. stack.push(a > b);
  45926. break;
  45927. case 'idiv':
  45928. b = stack.pop();
  45929. a = stack.pop();
  45930. stack.push(a / b | 0);
  45931. break;
  45932. case 'index':
  45933. a = stack.pop();
  45934. stack.index(a);
  45935. break;
  45936. case 'le':
  45937. b = stack.pop();
  45938. a = stack.pop();
  45939. stack.push(a <= b);
  45940. break;
  45941. case 'ln':
  45942. a = stack.pop();
  45943. stack.push(Math.log(a));
  45944. break;
  45945. case 'log':
  45946. a = stack.pop();
  45947. stack.push(Math.log(a) / Math.LN10);
  45948. break;
  45949. case 'lt':
  45950. b = stack.pop();
  45951. a = stack.pop();
  45952. stack.push(a < b);
  45953. break;
  45954. case 'mod':
  45955. b = stack.pop();
  45956. a = stack.pop();
  45957. stack.push(a % b);
  45958. break;
  45959. case 'mul':
  45960. b = stack.pop();
  45961. a = stack.pop();
  45962. stack.push(a * b);
  45963. break;
  45964. case 'ne':
  45965. b = stack.pop();
  45966. a = stack.pop();
  45967. stack.push(a !== b);
  45968. break;
  45969. case 'neg':
  45970. a = stack.pop();
  45971. stack.push(-a);
  45972. break;
  45973. case 'not':
  45974. a = stack.pop();
  45975. if (isBool(a)) {
  45976. stack.push(!a);
  45977. } else {
  45978. stack.push(~a);
  45979. }
  45980. break;
  45981. case 'or':
  45982. b = stack.pop();
  45983. a = stack.pop();
  45984. if (isBool(a) && isBool(b)) {
  45985. stack.push(a || b);
  45986. } else {
  45987. stack.push(a | b);
  45988. }
  45989. break;
  45990. case 'pop':
  45991. stack.pop();
  45992. break;
  45993. case 'roll':
  45994. b = stack.pop();
  45995. a = stack.pop();
  45996. stack.roll(a, b);
  45997. break;
  45998. case 'round':
  45999. a = stack.pop();
  46000. stack.push(Math.round(a));
  46001. break;
  46002. case 'sin':
  46003. a = stack.pop();
  46004. stack.push(Math.sin(a));
  46005. break;
  46006. case 'sqrt':
  46007. a = stack.pop();
  46008. stack.push(Math.sqrt(a));
  46009. break;
  46010. case 'sub':
  46011. b = stack.pop();
  46012. a = stack.pop();
  46013. stack.push(a - b);
  46014. break;
  46015. case 'true':
  46016. stack.push(true);
  46017. break;
  46018. case 'truncate':
  46019. a = stack.pop();
  46020. a = a < 0 ? Math.ceil(a) : Math.floor(a);
  46021. stack.push(a);
  46022. break;
  46023. case 'xor':
  46024. b = stack.pop();
  46025. a = stack.pop();
  46026. if (isBool(a) && isBool(b)) {
  46027. stack.push(a !== b);
  46028. } else {
  46029. stack.push(a ^ b);
  46030. }
  46031. break;
  46032. default:
  46033. error('Unknown operator ' + operator);
  46034. break;
  46035. }
  46036. }
  46037. return stack.stack;
  46038. }
  46039. };
  46040. return PostScriptEvaluator;
  46041. }();
  46042. var PostScriptCompiler = function PostScriptCompilerClosure() {
  46043. function AstNode(type) {
  46044. this.type = type;
  46045. }
  46046. AstNode.prototype.visit = function (visitor) {
  46047. throw new Error('abstract method');
  46048. };
  46049. function AstArgument(index, min, max) {
  46050. AstNode.call(this, 'args');
  46051. this.index = index;
  46052. this.min = min;
  46053. this.max = max;
  46054. }
  46055. AstArgument.prototype = Object.create(AstNode.prototype);
  46056. AstArgument.prototype.visit = function (visitor) {
  46057. visitor.visitArgument(this);
  46058. };
  46059. function AstLiteral(number) {
  46060. AstNode.call(this, 'literal');
  46061. this.number = number;
  46062. this.min = number;
  46063. this.max = number;
  46064. }
  46065. AstLiteral.prototype = Object.create(AstNode.prototype);
  46066. AstLiteral.prototype.visit = function (visitor) {
  46067. visitor.visitLiteral(this);
  46068. };
  46069. function AstBinaryOperation(op, arg1, arg2, min, max) {
  46070. AstNode.call(this, 'binary');
  46071. this.op = op;
  46072. this.arg1 = arg1;
  46073. this.arg2 = arg2;
  46074. this.min = min;
  46075. this.max = max;
  46076. }
  46077. AstBinaryOperation.prototype = Object.create(AstNode.prototype);
  46078. AstBinaryOperation.prototype.visit = function (visitor) {
  46079. visitor.visitBinaryOperation(this);
  46080. };
  46081. function AstMin(arg, max) {
  46082. AstNode.call(this, 'max');
  46083. this.arg = arg;
  46084. this.min = arg.min;
  46085. this.max = max;
  46086. }
  46087. AstMin.prototype = Object.create(AstNode.prototype);
  46088. AstMin.prototype.visit = function (visitor) {
  46089. visitor.visitMin(this);
  46090. };
  46091. function AstVariable(index, min, max) {
  46092. AstNode.call(this, 'var');
  46093. this.index = index;
  46094. this.min = min;
  46095. this.max = max;
  46096. }
  46097. AstVariable.prototype = Object.create(AstNode.prototype);
  46098. AstVariable.prototype.visit = function (visitor) {
  46099. visitor.visitVariable(this);
  46100. };
  46101. function AstVariableDefinition(variable, arg) {
  46102. AstNode.call(this, 'definition');
  46103. this.variable = variable;
  46104. this.arg = arg;
  46105. }
  46106. AstVariableDefinition.prototype = Object.create(AstNode.prototype);
  46107. AstVariableDefinition.prototype.visit = function (visitor) {
  46108. visitor.visitVariableDefinition(this);
  46109. };
  46110. function ExpressionBuilderVisitor() {
  46111. this.parts = [];
  46112. }
  46113. ExpressionBuilderVisitor.prototype = {
  46114. visitArgument: function (arg) {
  46115. this.parts.push('Math.max(', arg.min, ', Math.min(', arg.max, ', src[srcOffset + ', arg.index, ']))');
  46116. },
  46117. visitVariable: function (variable) {
  46118. this.parts.push('v', variable.index);
  46119. },
  46120. visitLiteral: function (literal) {
  46121. this.parts.push(literal.number);
  46122. },
  46123. visitBinaryOperation: function (operation) {
  46124. this.parts.push('(');
  46125. operation.arg1.visit(this);
  46126. this.parts.push(' ', operation.op, ' ');
  46127. operation.arg2.visit(this);
  46128. this.parts.push(')');
  46129. },
  46130. visitVariableDefinition: function (definition) {
  46131. this.parts.push('var ');
  46132. definition.variable.visit(this);
  46133. this.parts.push(' = ');
  46134. definition.arg.visit(this);
  46135. this.parts.push(';');
  46136. },
  46137. visitMin: function (max) {
  46138. this.parts.push('Math.min(');
  46139. max.arg.visit(this);
  46140. this.parts.push(', ', max.max, ')');
  46141. },
  46142. toString: function () {
  46143. return this.parts.join('');
  46144. }
  46145. };
  46146. function buildAddOperation(num1, num2) {
  46147. if (num2.type === 'literal' && num2.number === 0) {
  46148. return num1;
  46149. }
  46150. if (num1.type === 'literal' && num1.number === 0) {
  46151. return num2;
  46152. }
  46153. if (num2.type === 'literal' && num1.type === 'literal') {
  46154. return new AstLiteral(num1.number + num2.number);
  46155. }
  46156. return new AstBinaryOperation('+', num1, num2, num1.min + num2.min, num1.max + num2.max);
  46157. }
  46158. function buildMulOperation(num1, num2) {
  46159. if (num2.type === 'literal') {
  46160. if (num2.number === 0) {
  46161. return new AstLiteral(0);
  46162. } else if (num2.number === 1) {
  46163. return num1;
  46164. } else if (num1.type === 'literal') {
  46165. return new AstLiteral(num1.number * num2.number);
  46166. }
  46167. }
  46168. if (num1.type === 'literal') {
  46169. if (num1.number === 0) {
  46170. return new AstLiteral(0);
  46171. } else if (num1.number === 1) {
  46172. return num2;
  46173. }
  46174. }
  46175. var min = Math.min(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46176. var max = Math.max(num1.min * num2.min, num1.min * num2.max, num1.max * num2.min, num1.max * num2.max);
  46177. return new AstBinaryOperation('*', num1, num2, min, max);
  46178. }
  46179. function buildSubOperation(num1, num2) {
  46180. if (num2.type === 'literal') {
  46181. if (num2.number === 0) {
  46182. return num1;
  46183. } else if (num1.type === 'literal') {
  46184. return new AstLiteral(num1.number - num2.number);
  46185. }
  46186. }
  46187. if (num2.type === 'binary' && num2.op === '-' && num1.type === 'literal' && num1.number === 1 && num2.arg1.type === 'literal' && num2.arg1.number === 1) {
  46188. return num2.arg2;
  46189. }
  46190. return new AstBinaryOperation('-', num1, num2, num1.min - num2.max, num1.max - num2.min);
  46191. }
  46192. function buildMinOperation(num1, max) {
  46193. if (num1.min >= max) {
  46194. return new AstLiteral(max);
  46195. } else if (num1.max <= max) {
  46196. return num1;
  46197. }
  46198. return new AstMin(num1, max);
  46199. }
  46200. function PostScriptCompiler() {
  46201. }
  46202. PostScriptCompiler.prototype = {
  46203. compile: function PostScriptCompiler_compile(code, domain, range) {
  46204. var stack = [];
  46205. var i, ii;
  46206. var instructions = [];
  46207. var inputSize = domain.length >> 1, outputSize = range.length >> 1;
  46208. var lastRegister = 0;
  46209. var n, j;
  46210. var num1, num2, ast1, ast2, tmpVar, item;
  46211. for (i = 0; i < inputSize; i++) {
  46212. stack.push(new AstArgument(i, domain[i * 2], domain[i * 2 + 1]));
  46213. }
  46214. for (i = 0, ii = code.length; i < ii; i++) {
  46215. item = code[i];
  46216. if (typeof item === 'number') {
  46217. stack.push(new AstLiteral(item));
  46218. continue;
  46219. }
  46220. switch (item) {
  46221. case 'add':
  46222. if (stack.length < 2) {
  46223. return null;
  46224. }
  46225. num2 = stack.pop();
  46226. num1 = stack.pop();
  46227. stack.push(buildAddOperation(num1, num2));
  46228. break;
  46229. case 'cvr':
  46230. if (stack.length < 1) {
  46231. return null;
  46232. }
  46233. break;
  46234. case 'mul':
  46235. if (stack.length < 2) {
  46236. return null;
  46237. }
  46238. num2 = stack.pop();
  46239. num1 = stack.pop();
  46240. stack.push(buildMulOperation(num1, num2));
  46241. break;
  46242. case 'sub':
  46243. if (stack.length < 2) {
  46244. return null;
  46245. }
  46246. num2 = stack.pop();
  46247. num1 = stack.pop();
  46248. stack.push(buildSubOperation(num1, num2));
  46249. break;
  46250. case 'exch':
  46251. if (stack.length < 2) {
  46252. return null;
  46253. }
  46254. ast1 = stack.pop();
  46255. ast2 = stack.pop();
  46256. stack.push(ast1, ast2);
  46257. break;
  46258. case 'pop':
  46259. if (stack.length < 1) {
  46260. return null;
  46261. }
  46262. stack.pop();
  46263. break;
  46264. case 'index':
  46265. if (stack.length < 1) {
  46266. return null;
  46267. }
  46268. num1 = stack.pop();
  46269. if (num1.type !== 'literal') {
  46270. return null;
  46271. }
  46272. n = num1.number;
  46273. if (n < 0 || (n | 0) !== n || stack.length < n) {
  46274. return null;
  46275. }
  46276. ast1 = stack[stack.length - n - 1];
  46277. if (ast1.type === 'literal' || ast1.type === 'var') {
  46278. stack.push(ast1);
  46279. break;
  46280. }
  46281. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46282. stack[stack.length - n - 1] = tmpVar;
  46283. stack.push(tmpVar);
  46284. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46285. break;
  46286. case 'dup':
  46287. if (stack.length < 1) {
  46288. return null;
  46289. }
  46290. 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]) {
  46291. num1 = stack.pop();
  46292. stack.push(buildMinOperation(num1, code[i + 1]));
  46293. i += 6;
  46294. break;
  46295. }
  46296. ast1 = stack[stack.length - 1];
  46297. if (ast1.type === 'literal' || ast1.type === 'var') {
  46298. stack.push(ast1);
  46299. break;
  46300. }
  46301. tmpVar = new AstVariable(lastRegister++, ast1.min, ast1.max);
  46302. stack[stack.length - 1] = tmpVar;
  46303. stack.push(tmpVar);
  46304. instructions.push(new AstVariableDefinition(tmpVar, ast1));
  46305. break;
  46306. case 'roll':
  46307. if (stack.length < 2) {
  46308. return null;
  46309. }
  46310. num2 = stack.pop();
  46311. num1 = stack.pop();
  46312. if (num2.type !== 'literal' || num1.type !== 'literal') {
  46313. return null;
  46314. }
  46315. j = num2.number;
  46316. n = num1.number;
  46317. if (n <= 0 || (n | 0) !== n || (j | 0) !== j || stack.length < n) {
  46318. return null;
  46319. }
  46320. j = (j % n + n) % n;
  46321. if (j === 0) {
  46322. break;
  46323. }
  46324. Array.prototype.push.apply(stack, stack.splice(stack.length - n, n - j));
  46325. break;
  46326. default:
  46327. return null;
  46328. }
  46329. }
  46330. if (stack.length !== outputSize) {
  46331. return null;
  46332. }
  46333. var result = [];
  46334. instructions.forEach(function (instruction) {
  46335. var statementBuilder = new ExpressionBuilderVisitor();
  46336. instruction.visit(statementBuilder);
  46337. result.push(statementBuilder.toString());
  46338. });
  46339. stack.forEach(function (expr, i) {
  46340. var statementBuilder = new ExpressionBuilderVisitor();
  46341. expr.visit(statementBuilder);
  46342. var min = range[i * 2], max = range[i * 2 + 1];
  46343. var out = [statementBuilder.toString()];
  46344. if (min > expr.min) {
  46345. out.unshift('Math.max(', min, ', ');
  46346. out.push(')');
  46347. }
  46348. if (max < expr.max) {
  46349. out.unshift('Math.min(', max, ', ');
  46350. out.push(')');
  46351. }
  46352. out.unshift('dest[destOffset + ', i, '] = ');
  46353. out.push(';');
  46354. result.push(out.join(''));
  46355. });
  46356. return result.join('\n');
  46357. }
  46358. };
  46359. return PostScriptCompiler;
  46360. }();
  46361. exports.isPDFFunction = isPDFFunction;
  46362. exports.PDFFunction = PDFFunction;
  46363. exports.PostScriptEvaluator = PostScriptEvaluator;
  46364. exports.PostScriptCompiler = PostScriptCompiler;
  46365. }));
  46366. (function (root, factory) {
  46367. factory(root.pdfjsDisplayAPI = {}, root.pdfjsSharedUtil, root.pdfjsDisplayFontLoader, root.pdfjsDisplayCanvas, root.pdfjsDisplayMetadata, root.pdfjsDisplayDOMUtils);
  46368. }(this, function (exports, sharedUtil, displayFontLoader, displayCanvas, displayMetadata, displayDOMUtils, amdRequire) {
  46369. var InvalidPDFException = sharedUtil.InvalidPDFException;
  46370. var MessageHandler = sharedUtil.MessageHandler;
  46371. var MissingPDFException = sharedUtil.MissingPDFException;
  46372. var PageViewport = sharedUtil.PageViewport;
  46373. var PasswordResponses = sharedUtil.PasswordResponses;
  46374. var PasswordException = sharedUtil.PasswordException;
  46375. var StatTimer = sharedUtil.StatTimer;
  46376. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  46377. var UnknownErrorException = sharedUtil.UnknownErrorException;
  46378. var Util = sharedUtil.Util;
  46379. var createPromiseCapability = sharedUtil.createPromiseCapability;
  46380. var error = sharedUtil.error;
  46381. var deprecated = sharedUtil.deprecated;
  46382. var getVerbosityLevel = sharedUtil.getVerbosityLevel;
  46383. var info = sharedUtil.info;
  46384. var isInt = sharedUtil.isInt;
  46385. var isArray = sharedUtil.isArray;
  46386. var isArrayBuffer = sharedUtil.isArrayBuffer;
  46387. var isSameOrigin = sharedUtil.isSameOrigin;
  46388. var loadJpegStream = sharedUtil.loadJpegStream;
  46389. var stringToBytes = sharedUtil.stringToBytes;
  46390. var globalScope = sharedUtil.globalScope;
  46391. var warn = sharedUtil.warn;
  46392. var FontFaceObject = displayFontLoader.FontFaceObject;
  46393. var FontLoader = displayFontLoader.FontLoader;
  46394. var CanvasGraphics = displayCanvas.CanvasGraphics;
  46395. var createScratchCanvas = displayCanvas.createScratchCanvas;
  46396. var Metadata = displayMetadata.Metadata;
  46397. var getDefaultSetting = displayDOMUtils.getDefaultSetting;
  46398. var DEFAULT_RANGE_CHUNK_SIZE = 65536;
  46399. var isWorkerDisabled = false;
  46400. var workerSrc;
  46401. var isPostMessageTransfersDisabled = false;
  46402. var fakeWorkerFilesLoader = null;
  46403. var useRequireEnsure = false;
  46404. function getDocument(src, pdfDataRangeTransport, passwordCallback, progressCallback) {
  46405. var task = new PDFDocumentLoadingTask();
  46406. if (arguments.length > 1) {
  46407. deprecated('getDocument is called with pdfDataRangeTransport, ' + 'passwordCallback or progressCallback argument');
  46408. }
  46409. if (pdfDataRangeTransport) {
  46410. if (!(pdfDataRangeTransport instanceof PDFDataRangeTransport)) {
  46411. pdfDataRangeTransport = Object.create(pdfDataRangeTransport);
  46412. pdfDataRangeTransport.length = src.length;
  46413. pdfDataRangeTransport.initialData = src.initialData;
  46414. if (!pdfDataRangeTransport.abort) {
  46415. pdfDataRangeTransport.abort = function () {
  46416. };
  46417. }
  46418. }
  46419. src = Object.create(src);
  46420. src.range = pdfDataRangeTransport;
  46421. }
  46422. task.onPassword = passwordCallback || null;
  46423. task.onProgress = progressCallback || null;
  46424. var source;
  46425. if (typeof src === 'string') {
  46426. source = { url: src };
  46427. } else if (isArrayBuffer(src)) {
  46428. source = { data: src };
  46429. } else if (src instanceof PDFDataRangeTransport) {
  46430. source = { range: src };
  46431. } else {
  46432. if (typeof src !== 'object') {
  46433. error('Invalid parameter in getDocument, need either Uint8Array, ' + 'string or a parameter object');
  46434. }
  46435. if (!src.url && !src.data && !src.range) {
  46436. error('Invalid parameter object: need either .data, .range or .url');
  46437. }
  46438. source = src;
  46439. }
  46440. var params = {};
  46441. var rangeTransport = null;
  46442. var worker = null;
  46443. for (var key in source) {
  46444. if (key === 'url' && typeof window !== 'undefined') {
  46445. params[key] = new URL(source[key], window.location).href;
  46446. continue;
  46447. } else if (key === 'range') {
  46448. rangeTransport = source[key];
  46449. continue;
  46450. } else if (key === 'worker') {
  46451. worker = source[key];
  46452. continue;
  46453. } else if (key === 'data' && !(source[key] instanceof Uint8Array)) {
  46454. var pdfBytes = source[key];
  46455. if (typeof pdfBytes === 'string') {
  46456. params[key] = stringToBytes(pdfBytes);
  46457. } else if (typeof pdfBytes === 'object' && pdfBytes !== null && !isNaN(pdfBytes.length)) {
  46458. params[key] = new Uint8Array(pdfBytes);
  46459. } else if (isArrayBuffer(pdfBytes)) {
  46460. params[key] = new Uint8Array(pdfBytes);
  46461. } else {
  46462. error('Invalid PDF binary data: either typed array, string or ' + 'array-like object is expected in the data property.');
  46463. }
  46464. continue;
  46465. }
  46466. params[key] = source[key];
  46467. }
  46468. params.rangeChunkSize = params.rangeChunkSize || DEFAULT_RANGE_CHUNK_SIZE;
  46469. if (!worker) {
  46470. worker = new PDFWorker();
  46471. task._worker = worker;
  46472. }
  46473. var docId = task.docId;
  46474. worker.promise.then(function () {
  46475. if (task.destroyed) {
  46476. throw new Error('Loading aborted');
  46477. }
  46478. return _fetchDocument(worker, params, rangeTransport, docId).then(function (workerId) {
  46479. if (task.destroyed) {
  46480. throw new Error('Loading aborted');
  46481. }
  46482. var messageHandler = new MessageHandler(docId, workerId, worker.port);
  46483. var transport = new WorkerTransport(messageHandler, task, rangeTransport);
  46484. task._transport = transport;
  46485. messageHandler.send('Ready', null);
  46486. });
  46487. }).catch(task._capability.reject);
  46488. return task;
  46489. }
  46490. function _fetchDocument(worker, source, pdfDataRangeTransport, docId) {
  46491. if (worker.destroyed) {
  46492. return Promise.reject(new Error('Worker was destroyed'));
  46493. }
  46494. source.disableAutoFetch = getDefaultSetting('disableAutoFetch');
  46495. source.disableStream = getDefaultSetting('disableStream');
  46496. source.chunkedViewerLoading = !!pdfDataRangeTransport;
  46497. if (pdfDataRangeTransport) {
  46498. source.length = pdfDataRangeTransport.length;
  46499. source.initialData = pdfDataRangeTransport.initialData;
  46500. }
  46501. return worker.messageHandler.sendWithPromise('GetDocRequest', {
  46502. docId: docId,
  46503. source: source,
  46504. disableRange: getDefaultSetting('disableRange'),
  46505. maxImageSize: getDefaultSetting('maxImageSize'),
  46506. cMapUrl: getDefaultSetting('cMapUrl'),
  46507. cMapPacked: getDefaultSetting('cMapPacked'),
  46508. disableFontFace: getDefaultSetting('disableFontFace'),
  46509. disableCreateObjectURL: getDefaultSetting('disableCreateObjectURL'),
  46510. postMessageTransfers: getDefaultSetting('postMessageTransfers') && !isPostMessageTransfersDisabled,
  46511. docBaseUrl: source.docBaseUrl
  46512. }).then(function (workerId) {
  46513. if (worker.destroyed) {
  46514. throw new Error('Worker was destroyed');
  46515. }
  46516. return workerId;
  46517. });
  46518. }
  46519. var PDFDocumentLoadingTask = function PDFDocumentLoadingTaskClosure() {
  46520. var nextDocumentId = 0;
  46521. function PDFDocumentLoadingTask() {
  46522. this._capability = createPromiseCapability();
  46523. this._transport = null;
  46524. this._worker = null;
  46525. this.docId = 'd' + nextDocumentId++;
  46526. this.destroyed = false;
  46527. this.onPassword = null;
  46528. this.onProgress = null;
  46529. this.onUnsupportedFeature = null;
  46530. }
  46531. PDFDocumentLoadingTask.prototype = {
  46532. get promise() {
  46533. return this._capability.promise;
  46534. },
  46535. destroy: function () {
  46536. this.destroyed = true;
  46537. var transportDestroyed = !this._transport ? Promise.resolve() : this._transport.destroy();
  46538. return transportDestroyed.then(function () {
  46539. this._transport = null;
  46540. if (this._worker) {
  46541. this._worker.destroy();
  46542. this._worker = null;
  46543. }
  46544. }.bind(this));
  46545. },
  46546. then: function PDFDocumentLoadingTask_then(onFulfilled, onRejected) {
  46547. return this.promise.then.apply(this.promise, arguments);
  46548. }
  46549. };
  46550. return PDFDocumentLoadingTask;
  46551. }();
  46552. var PDFDataRangeTransport = function pdfDataRangeTransportClosure() {
  46553. function PDFDataRangeTransport(length, initialData) {
  46554. this.length = length;
  46555. this.initialData = initialData;
  46556. this._rangeListeners = [];
  46557. this._progressListeners = [];
  46558. this._progressiveReadListeners = [];
  46559. this._readyCapability = createPromiseCapability();
  46560. }
  46561. PDFDataRangeTransport.prototype = {
  46562. addRangeListener: function PDFDataRangeTransport_addRangeListener(listener) {
  46563. this._rangeListeners.push(listener);
  46564. },
  46565. addProgressListener: function PDFDataRangeTransport_addProgressListener(listener) {
  46566. this._progressListeners.push(listener);
  46567. },
  46568. addProgressiveReadListener: function PDFDataRangeTransport_addProgressiveReadListener(listener) {
  46569. this._progressiveReadListeners.push(listener);
  46570. },
  46571. onDataRange: function PDFDataRangeTransport_onDataRange(begin, chunk) {
  46572. var listeners = this._rangeListeners;
  46573. for (var i = 0, n = listeners.length; i < n; ++i) {
  46574. listeners[i](begin, chunk);
  46575. }
  46576. },
  46577. onDataProgress: function PDFDataRangeTransport_onDataProgress(loaded) {
  46578. this._readyCapability.promise.then(function () {
  46579. var listeners = this._progressListeners;
  46580. for (var i = 0, n = listeners.length; i < n; ++i) {
  46581. listeners[i](loaded);
  46582. }
  46583. }.bind(this));
  46584. },
  46585. onDataProgressiveRead: function PDFDataRangeTransport_onDataProgress(chunk) {
  46586. this._readyCapability.promise.then(function () {
  46587. var listeners = this._progressiveReadListeners;
  46588. for (var i = 0, n = listeners.length; i < n; ++i) {
  46589. listeners[i](chunk);
  46590. }
  46591. }.bind(this));
  46592. },
  46593. transportReady: function PDFDataRangeTransport_transportReady() {
  46594. this._readyCapability.resolve();
  46595. },
  46596. requestDataRange: function PDFDataRangeTransport_requestDataRange(begin, end) {
  46597. throw new Error('Abstract method PDFDataRangeTransport.requestDataRange');
  46598. },
  46599. abort: function PDFDataRangeTransport_abort() {
  46600. }
  46601. };
  46602. return PDFDataRangeTransport;
  46603. }();
  46604. var PDFDocumentProxy = function PDFDocumentProxyClosure() {
  46605. function PDFDocumentProxy(pdfInfo, transport, loadingTask) {
  46606. this.pdfInfo = pdfInfo;
  46607. this.transport = transport;
  46608. this.loadingTask = loadingTask;
  46609. }
  46610. PDFDocumentProxy.prototype = {
  46611. get numPages() {
  46612. return this.pdfInfo.numPages;
  46613. },
  46614. get fingerprint() {
  46615. return this.pdfInfo.fingerprint;
  46616. },
  46617. getPage: function PDFDocumentProxy_getPage(pageNumber) {
  46618. return this.transport.getPage(pageNumber);
  46619. },
  46620. getPageIndex: function PDFDocumentProxy_getPageIndex(ref) {
  46621. return this.transport.getPageIndex(ref);
  46622. },
  46623. getDestinations: function PDFDocumentProxy_getDestinations() {
  46624. return this.transport.getDestinations();
  46625. },
  46626. getDestination: function PDFDocumentProxy_getDestination(id) {
  46627. return this.transport.getDestination(id);
  46628. },
  46629. getPageLabels: function PDFDocumentProxy_getPageLabels() {
  46630. return this.transport.getPageLabels();
  46631. },
  46632. getAttachments: function PDFDocumentProxy_getAttachments() {
  46633. return this.transport.getAttachments();
  46634. },
  46635. getJavaScript: function PDFDocumentProxy_getJavaScript() {
  46636. return this.transport.getJavaScript();
  46637. },
  46638. getOutline: function PDFDocumentProxy_getOutline() {
  46639. return this.transport.getOutline();
  46640. },
  46641. getMetadata: function PDFDocumentProxy_getMetadata() {
  46642. return this.transport.getMetadata();
  46643. },
  46644. getData: function PDFDocumentProxy_getData() {
  46645. return this.transport.getData();
  46646. },
  46647. getDownloadInfo: function PDFDocumentProxy_getDownloadInfo() {
  46648. return this.transport.downloadInfoCapability.promise;
  46649. },
  46650. getStats: function PDFDocumentProxy_getStats() {
  46651. return this.transport.getStats();
  46652. },
  46653. cleanup: function PDFDocumentProxy_cleanup() {
  46654. this.transport.startCleanup();
  46655. },
  46656. destroy: function PDFDocumentProxy_destroy() {
  46657. return this.loadingTask.destroy();
  46658. }
  46659. };
  46660. return PDFDocumentProxy;
  46661. }();
  46662. var PDFPageProxy = function PDFPageProxyClosure() {
  46663. function PDFPageProxy(pageIndex, pageInfo, transport) {
  46664. this.pageIndex = pageIndex;
  46665. this.pageInfo = pageInfo;
  46666. this.transport = transport;
  46667. this.stats = new StatTimer();
  46668. this.stats.enabled = getDefaultSetting('enableStats');
  46669. this.commonObjs = transport.commonObjs;
  46670. this.objs = new PDFObjects();
  46671. this.cleanupAfterRender = false;
  46672. this.pendingCleanup = false;
  46673. this.intentStates = Object.create(null);
  46674. this.destroyed = false;
  46675. }
  46676. PDFPageProxy.prototype = {
  46677. get pageNumber() {
  46678. return this.pageIndex + 1;
  46679. },
  46680. get rotate() {
  46681. return this.pageInfo.rotate;
  46682. },
  46683. get ref() {
  46684. return this.pageInfo.ref;
  46685. },
  46686. get userUnit() {
  46687. return this.pageInfo.userUnit;
  46688. },
  46689. get view() {
  46690. return this.pageInfo.view;
  46691. },
  46692. getViewport: function PDFPageProxy_getViewport(scale, rotate) {
  46693. if (arguments.length < 2) {
  46694. rotate = this.rotate;
  46695. }
  46696. return new PageViewport(this.view, scale, rotate, 0, 0);
  46697. },
  46698. getAnnotations: function PDFPageProxy_getAnnotations(params) {
  46699. var intent = params && params.intent || null;
  46700. if (!this.annotationsPromise || this.annotationsIntent !== intent) {
  46701. this.annotationsPromise = this.transport.getAnnotations(this.pageIndex, intent);
  46702. this.annotationsIntent = intent;
  46703. }
  46704. return this.annotationsPromise;
  46705. },
  46706. render: function PDFPageProxy_render(params) {
  46707. var stats = this.stats;
  46708. stats.time('Overall');
  46709. this.pendingCleanup = false;
  46710. var renderingIntent = params.intent === 'print' ? 'print' : 'display';
  46711. var renderInteractiveForms = params.renderInteractiveForms === true ? true : false;
  46712. if (!this.intentStates[renderingIntent]) {
  46713. this.intentStates[renderingIntent] = Object.create(null);
  46714. }
  46715. var intentState = this.intentStates[renderingIntent];
  46716. if (!intentState.displayReadyCapability) {
  46717. intentState.receivingOperatorList = true;
  46718. intentState.displayReadyCapability = createPromiseCapability();
  46719. intentState.operatorList = {
  46720. fnArray: [],
  46721. argsArray: [],
  46722. lastChunk: false
  46723. };
  46724. this.stats.time('Page Request');
  46725. this.transport.messageHandler.send('RenderPageRequest', {
  46726. pageIndex: this.pageNumber - 1,
  46727. intent: renderingIntent,
  46728. renderInteractiveForms: renderInteractiveForms
  46729. });
  46730. }
  46731. var internalRenderTask = new InternalRenderTask(complete, params, this.objs, this.commonObjs, intentState.operatorList, this.pageNumber);
  46732. internalRenderTask.useRequestAnimationFrame = renderingIntent !== 'print';
  46733. if (!intentState.renderTasks) {
  46734. intentState.renderTasks = [];
  46735. }
  46736. intentState.renderTasks.push(internalRenderTask);
  46737. var renderTask = internalRenderTask.task;
  46738. if (params.continueCallback) {
  46739. deprecated('render is used with continueCallback parameter');
  46740. renderTask.onContinue = params.continueCallback;
  46741. }
  46742. var self = this;
  46743. intentState.displayReadyCapability.promise.then(function pageDisplayReadyPromise(transparency) {
  46744. if (self.pendingCleanup) {
  46745. complete();
  46746. return;
  46747. }
  46748. stats.time('Rendering');
  46749. internalRenderTask.initializeGraphics(transparency);
  46750. internalRenderTask.operatorListChanged();
  46751. }, function pageDisplayReadPromiseError(reason) {
  46752. complete(reason);
  46753. });
  46754. function complete(error) {
  46755. var i = intentState.renderTasks.indexOf(internalRenderTask);
  46756. if (i >= 0) {
  46757. intentState.renderTasks.splice(i, 1);
  46758. }
  46759. if (self.cleanupAfterRender) {
  46760. self.pendingCleanup = true;
  46761. }
  46762. self._tryCleanup();
  46763. if (error) {
  46764. internalRenderTask.capability.reject(error);
  46765. } else {
  46766. internalRenderTask.capability.resolve();
  46767. }
  46768. stats.timeEnd('Rendering');
  46769. stats.timeEnd('Overall');
  46770. }
  46771. return renderTask;
  46772. },
  46773. getOperatorList: function PDFPageProxy_getOperatorList() {
  46774. function operatorListChanged() {
  46775. if (intentState.operatorList.lastChunk) {
  46776. intentState.opListReadCapability.resolve(intentState.operatorList);
  46777. var i = intentState.renderTasks.indexOf(opListTask);
  46778. if (i >= 0) {
  46779. intentState.renderTasks.splice(i, 1);
  46780. }
  46781. }
  46782. }
  46783. var renderingIntent = 'oplist';
  46784. if (!this.intentStates[renderingIntent]) {
  46785. this.intentStates[renderingIntent] = Object.create(null);
  46786. }
  46787. var intentState = this.intentStates[renderingIntent];
  46788. var opListTask;
  46789. if (!intentState.opListReadCapability) {
  46790. opListTask = {};
  46791. opListTask.operatorListChanged = operatorListChanged;
  46792. intentState.receivingOperatorList = true;
  46793. intentState.opListReadCapability = createPromiseCapability();
  46794. intentState.renderTasks = [];
  46795. intentState.renderTasks.push(opListTask);
  46796. intentState.operatorList = {
  46797. fnArray: [],
  46798. argsArray: [],
  46799. lastChunk: false
  46800. };
  46801. this.transport.messageHandler.send('RenderPageRequest', {
  46802. pageIndex: this.pageIndex,
  46803. intent: renderingIntent
  46804. });
  46805. }
  46806. return intentState.opListReadCapability.promise;
  46807. },
  46808. getTextContent: function PDFPageProxy_getTextContent(params) {
  46809. return this.transport.messageHandler.sendWithPromise('GetTextContent', {
  46810. pageIndex: this.pageNumber - 1,
  46811. normalizeWhitespace: params && params.normalizeWhitespace === true ? true : false,
  46812. combineTextItems: params && params.disableCombineTextItems === true ? false : true
  46813. });
  46814. },
  46815. _destroy: function PDFPageProxy_destroy() {
  46816. this.destroyed = true;
  46817. this.transport.pageCache[this.pageIndex] = null;
  46818. var waitOn = [];
  46819. Object.keys(this.intentStates).forEach(function (intent) {
  46820. if (intent === 'oplist') {
  46821. return;
  46822. }
  46823. var intentState = this.intentStates[intent];
  46824. intentState.renderTasks.forEach(function (renderTask) {
  46825. var renderCompleted = renderTask.capability.promise.catch(function () {
  46826. });
  46827. waitOn.push(renderCompleted);
  46828. renderTask.cancel();
  46829. });
  46830. }, this);
  46831. this.objs.clear();
  46832. this.annotationsPromise = null;
  46833. this.pendingCleanup = false;
  46834. return Promise.all(waitOn);
  46835. },
  46836. destroy: function () {
  46837. deprecated('page destroy method, use cleanup() instead');
  46838. this.cleanup();
  46839. },
  46840. cleanup: function PDFPageProxy_cleanup() {
  46841. this.pendingCleanup = true;
  46842. this._tryCleanup();
  46843. },
  46844. _tryCleanup: function PDFPageProxy_tryCleanup() {
  46845. if (!this.pendingCleanup || Object.keys(this.intentStates).some(function (intent) {
  46846. var intentState = this.intentStates[intent];
  46847. return intentState.renderTasks.length !== 0 || intentState.receivingOperatorList;
  46848. }, this)) {
  46849. return;
  46850. }
  46851. Object.keys(this.intentStates).forEach(function (intent) {
  46852. delete this.intentStates[intent];
  46853. }, this);
  46854. this.objs.clear();
  46855. this.annotationsPromise = null;
  46856. this.pendingCleanup = false;
  46857. },
  46858. _startRenderPage: function PDFPageProxy_startRenderPage(transparency, intent) {
  46859. var intentState = this.intentStates[intent];
  46860. if (intentState.displayReadyCapability) {
  46861. intentState.displayReadyCapability.resolve(transparency);
  46862. }
  46863. },
  46864. _renderPageChunk: function PDFPageProxy_renderPageChunk(operatorListChunk, intent) {
  46865. var intentState = this.intentStates[intent];
  46866. var i, ii;
  46867. for (i = 0, ii = operatorListChunk.length; i < ii; i++) {
  46868. intentState.operatorList.fnArray.push(operatorListChunk.fnArray[i]);
  46869. intentState.operatorList.argsArray.push(operatorListChunk.argsArray[i]);
  46870. }
  46871. intentState.operatorList.lastChunk = operatorListChunk.lastChunk;
  46872. for (i = 0; i < intentState.renderTasks.length; i++) {
  46873. intentState.renderTasks[i].operatorListChanged();
  46874. }
  46875. if (operatorListChunk.lastChunk) {
  46876. intentState.receivingOperatorList = false;
  46877. this._tryCleanup();
  46878. }
  46879. }
  46880. };
  46881. return PDFPageProxy;
  46882. }();
  46883. var PDFWorker = function PDFWorkerClosure() {
  46884. var nextFakeWorkerId = 0;
  46885. function getWorkerSrc() {
  46886. if (typeof workerSrc !== 'undefined') {
  46887. return workerSrc;
  46888. }
  46889. if (getDefaultSetting('workerSrc')) {
  46890. return getDefaultSetting('workerSrc');
  46891. }
  46892. if (pdfjsFilePath) {
  46893. return pdfjsFilePath.replace(/\.js$/i, '.worker.js');
  46894. }
  46895. error('No PDFJS.workerSrc specified');
  46896. }
  46897. var fakeWorkerFilesLoadedCapability;
  46898. function setupFakeWorkerGlobal() {
  46899. var WorkerMessageHandler;
  46900. if (fakeWorkerFilesLoadedCapability) {
  46901. return fakeWorkerFilesLoadedCapability.promise;
  46902. }
  46903. fakeWorkerFilesLoadedCapability = createPromiseCapability();
  46904. WorkerMessageHandler = pdfjsLibs.pdfjsCoreWorker.WorkerMessageHandler;
  46905. fakeWorkerFilesLoadedCapability.resolve(WorkerMessageHandler);
  46906. return fakeWorkerFilesLoadedCapability.promise;
  46907. }
  46908. function FakeWorkerPort(defer) {
  46909. this._listeners = [];
  46910. this._defer = defer;
  46911. this._deferred = Promise.resolve(undefined);
  46912. }
  46913. FakeWorkerPort.prototype = {
  46914. postMessage: function (obj, transfers) {
  46915. function cloneValue(value) {
  46916. if (typeof value !== 'object' || value === null) {
  46917. return value;
  46918. }
  46919. if (cloned.has(value)) {
  46920. return cloned.get(value);
  46921. }
  46922. var result;
  46923. var buffer;
  46924. if ((buffer = value.buffer) && isArrayBuffer(buffer)) {
  46925. var transferable = transfers && transfers.indexOf(buffer) >= 0;
  46926. if (value === buffer) {
  46927. result = value;
  46928. } else if (transferable) {
  46929. result = new value.constructor(buffer, value.byteOffset, value.byteLength);
  46930. } else {
  46931. result = new value.constructor(value);
  46932. }
  46933. cloned.set(value, result);
  46934. return result;
  46935. }
  46936. result = isArray(value) ? [] : {};
  46937. cloned.set(value, result);
  46938. for (var i in value) {
  46939. var desc, p = value;
  46940. while (!(desc = Object.getOwnPropertyDescriptor(p, i))) {
  46941. p = Object.getPrototypeOf(p);
  46942. }
  46943. if (typeof desc.value === 'undefined' || typeof desc.value === 'function') {
  46944. continue;
  46945. }
  46946. result[i] = cloneValue(desc.value);
  46947. }
  46948. return result;
  46949. }
  46950. if (!this._defer) {
  46951. this._listeners.forEach(function (listener) {
  46952. listener.call(this, { data: obj });
  46953. }, this);
  46954. return;
  46955. }
  46956. var cloned = new WeakMap();
  46957. var e = { data: cloneValue(obj) };
  46958. this._deferred.then(function () {
  46959. this._listeners.forEach(function (listener) {
  46960. listener.call(this, e);
  46961. }, this);
  46962. }.bind(this));
  46963. },
  46964. addEventListener: function (name, listener) {
  46965. this._listeners.push(listener);
  46966. },
  46967. removeEventListener: function (name, listener) {
  46968. var i = this._listeners.indexOf(listener);
  46969. this._listeners.splice(i, 1);
  46970. },
  46971. terminate: function () {
  46972. this._listeners = [];
  46973. }
  46974. };
  46975. function createCDNWrapper(url) {
  46976. var wrapper = 'importScripts(\'' + url + '\');';
  46977. return URL.createObjectURL(new Blob([wrapper]));
  46978. }
  46979. function PDFWorker(name) {
  46980. this.name = name;
  46981. this.destroyed = false;
  46982. this._readyCapability = createPromiseCapability();
  46983. this._port = null;
  46984. this._webWorker = null;
  46985. this._messageHandler = null;
  46986. this._initialize();
  46987. }
  46988. PDFWorker.prototype = {
  46989. get promise() {
  46990. return this._readyCapability.promise;
  46991. },
  46992. get port() {
  46993. return this._port;
  46994. },
  46995. get messageHandler() {
  46996. return this._messageHandler;
  46997. },
  46998. _initialize: function PDFWorker_initialize() {
  46999. this._setupFakeWorker();
  47000. },
  47001. _setupFakeWorker: function PDFWorker_setupFakeWorker() {
  47002. if (!isWorkerDisabled && !getDefaultSetting('disableWorker')) {
  47003. warn('Setting up fake worker.');
  47004. isWorkerDisabled = true;
  47005. }
  47006. setupFakeWorkerGlobal().then(function (WorkerMessageHandler) {
  47007. if (this.destroyed) {
  47008. this._readyCapability.reject(new Error('Worker was destroyed'));
  47009. return;
  47010. }
  47011. var isTypedArraysPresent = Uint8Array !== Float32Array;
  47012. var port = new FakeWorkerPort(isTypedArraysPresent);
  47013. this._port = port;
  47014. var id = 'fake' + nextFakeWorkerId++;
  47015. var workerHandler = new MessageHandler(id + '_worker', id, port);
  47016. WorkerMessageHandler.setup(workerHandler, port);
  47017. var messageHandler = new MessageHandler(id, id + '_worker', port);
  47018. this._messageHandler = messageHandler;
  47019. this._readyCapability.resolve();
  47020. }.bind(this));
  47021. },
  47022. destroy: function PDFWorker_destroy() {
  47023. this.destroyed = true;
  47024. if (this._webWorker) {
  47025. this._webWorker.terminate();
  47026. this._webWorker = null;
  47027. }
  47028. this._port = null;
  47029. if (this._messageHandler) {
  47030. this._messageHandler.destroy();
  47031. this._messageHandler = null;
  47032. }
  47033. }
  47034. };
  47035. return PDFWorker;
  47036. }();
  47037. var WorkerTransport = function WorkerTransportClosure() {
  47038. function WorkerTransport(messageHandler, loadingTask, pdfDataRangeTransport) {
  47039. this.messageHandler = messageHandler;
  47040. this.loadingTask = loadingTask;
  47041. this.pdfDataRangeTransport = pdfDataRangeTransport;
  47042. this.commonObjs = new PDFObjects();
  47043. this.fontLoader = new FontLoader(loadingTask.docId);
  47044. this.destroyed = false;
  47045. this.destroyCapability = null;
  47046. this.pageCache = [];
  47047. this.pagePromises = [];
  47048. this.downloadInfoCapability = createPromiseCapability();
  47049. this.setupMessageHandler();
  47050. }
  47051. WorkerTransport.prototype = {
  47052. destroy: function WorkerTransport_destroy() {
  47053. if (this.destroyCapability) {
  47054. return this.destroyCapability.promise;
  47055. }
  47056. this.destroyed = true;
  47057. this.destroyCapability = createPromiseCapability();
  47058. var waitOn = [];
  47059. this.pageCache.forEach(function (page) {
  47060. if (page) {
  47061. waitOn.push(page._destroy());
  47062. }
  47063. });
  47064. this.pageCache = [];
  47065. this.pagePromises = [];
  47066. var self = this;
  47067. var terminated = this.messageHandler.sendWithPromise('Terminate', null);
  47068. waitOn.push(terminated);
  47069. Promise.all(waitOn).then(function () {
  47070. self.fontLoader.clear();
  47071. if (self.pdfDataRangeTransport) {
  47072. self.pdfDataRangeTransport.abort();
  47073. self.pdfDataRangeTransport = null;
  47074. }
  47075. if (self.messageHandler) {
  47076. self.messageHandler.destroy();
  47077. self.messageHandler = null;
  47078. }
  47079. self.destroyCapability.resolve();
  47080. }, this.destroyCapability.reject);
  47081. return this.destroyCapability.promise;
  47082. },
  47083. setupMessageHandler: function WorkerTransport_setupMessageHandler() {
  47084. var messageHandler = this.messageHandler;
  47085. function updatePassword(password) {
  47086. messageHandler.send('UpdatePassword', password);
  47087. }
  47088. var pdfDataRangeTransport = this.pdfDataRangeTransport;
  47089. if (pdfDataRangeTransport) {
  47090. pdfDataRangeTransport.addRangeListener(function (begin, chunk) {
  47091. messageHandler.send('OnDataRange', {
  47092. begin: begin,
  47093. chunk: chunk
  47094. });
  47095. });
  47096. pdfDataRangeTransport.addProgressListener(function (loaded) {
  47097. messageHandler.send('OnDataProgress', { loaded: loaded });
  47098. });
  47099. pdfDataRangeTransport.addProgressiveReadListener(function (chunk) {
  47100. messageHandler.send('OnDataRange', { chunk: chunk });
  47101. });
  47102. messageHandler.on('RequestDataRange', function transportDataRange(data) {
  47103. pdfDataRangeTransport.requestDataRange(data.begin, data.end);
  47104. }, this);
  47105. }
  47106. messageHandler.on('GetDoc', function transportDoc(data) {
  47107. var pdfInfo = data.pdfInfo;
  47108. this.numPages = data.pdfInfo.numPages;
  47109. var loadingTask = this.loadingTask;
  47110. var pdfDocument = new PDFDocumentProxy(pdfInfo, this, loadingTask);
  47111. this.pdfDocument = pdfDocument;
  47112. loadingTask._capability.resolve(pdfDocument);
  47113. }, this);
  47114. messageHandler.on('NeedPassword', function transportNeedPassword(exception) {
  47115. var loadingTask = this.loadingTask;
  47116. if (loadingTask.onPassword) {
  47117. return loadingTask.onPassword(updatePassword, PasswordResponses.NEED_PASSWORD);
  47118. }
  47119. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47120. }, this);
  47121. messageHandler.on('IncorrectPassword', function transportIncorrectPassword(exception) {
  47122. var loadingTask = this.loadingTask;
  47123. if (loadingTask.onPassword) {
  47124. return loadingTask.onPassword(updatePassword, PasswordResponses.INCORRECT_PASSWORD);
  47125. }
  47126. loadingTask._capability.reject(new PasswordException(exception.message, exception.code));
  47127. }, this);
  47128. messageHandler.on('InvalidPDF', function transportInvalidPDF(exception) {
  47129. this.loadingTask._capability.reject(new InvalidPDFException(exception.message));
  47130. }, this);
  47131. messageHandler.on('MissingPDF', function transportMissingPDF(exception) {
  47132. this.loadingTask._capability.reject(new MissingPDFException(exception.message));
  47133. }, this);
  47134. messageHandler.on('UnexpectedResponse', function transportUnexpectedResponse(exception) {
  47135. this.loadingTask._capability.reject(new UnexpectedResponseException(exception.message, exception.status));
  47136. }, this);
  47137. messageHandler.on('UnknownError', function transportUnknownError(exception) {
  47138. this.loadingTask._capability.reject(new UnknownErrorException(exception.message, exception.details));
  47139. }, this);
  47140. messageHandler.on('DataLoaded', function transportPage(data) {
  47141. this.downloadInfoCapability.resolve(data);
  47142. }, this);
  47143. messageHandler.on('PDFManagerReady', function transportPage(data) {
  47144. if (this.pdfDataRangeTransport) {
  47145. this.pdfDataRangeTransport.transportReady();
  47146. }
  47147. }, this);
  47148. messageHandler.on('StartRenderPage', function transportRender(data) {
  47149. if (this.destroyed) {
  47150. return;
  47151. }
  47152. var page = this.pageCache[data.pageIndex];
  47153. page.stats.timeEnd('Page Request');
  47154. page._startRenderPage(data.transparency, data.intent);
  47155. }, this);
  47156. messageHandler.on('RenderPageChunk', function transportRender(data) {
  47157. if (this.destroyed) {
  47158. return;
  47159. }
  47160. var page = this.pageCache[data.pageIndex];
  47161. page._renderPageChunk(data.operatorList, data.intent);
  47162. }, this);
  47163. messageHandler.on('commonobj', function transportObj(data) {
  47164. if (this.destroyed) {
  47165. return;
  47166. }
  47167. var id = data[0];
  47168. var type = data[1];
  47169. if (this.commonObjs.hasData(id)) {
  47170. return;
  47171. }
  47172. switch (type) {
  47173. case 'Font':
  47174. var exportedData = data[2];
  47175. if ('error' in exportedData) {
  47176. var exportedError = exportedData.error;
  47177. warn('Error during font loading: ' + exportedError);
  47178. this.commonObjs.resolve(id, exportedError);
  47179. break;
  47180. }
  47181. var fontRegistry = null;
  47182. if (getDefaultSetting('pdfBug') && globalScope.FontInspector && globalScope['FontInspector'].enabled) {
  47183. fontRegistry = {
  47184. registerFont: function (font, url) {
  47185. globalScope['FontInspector'].fontAdded(font, url);
  47186. }
  47187. };
  47188. }
  47189. var font = new FontFaceObject(exportedData, {
  47190. isEvalSuported: getDefaultSetting('isEvalSupported'),
  47191. disableFontFace: getDefaultSetting('disableFontFace'),
  47192. fontRegistry: fontRegistry
  47193. });
  47194. this.fontLoader.bind([font], function fontReady(fontObjs) {
  47195. this.commonObjs.resolve(id, font);
  47196. }.bind(this));
  47197. break;
  47198. case 'FontPath':
  47199. this.commonObjs.resolve(id, data[2]);
  47200. break;
  47201. default:
  47202. error('Got unknown common object type ' + type);
  47203. }
  47204. }, this);
  47205. messageHandler.on('obj', function transportObj(data) {
  47206. if (this.destroyed) {
  47207. return;
  47208. }
  47209. var id = data[0];
  47210. var pageIndex = data[1];
  47211. var type = data[2];
  47212. var pageProxy = this.pageCache[pageIndex];
  47213. var imageData;
  47214. if (pageProxy.objs.hasData(id)) {
  47215. return;
  47216. }
  47217. switch (type) {
  47218. case 'JpegStream':
  47219. imageData = data[3];
  47220. loadJpegStream(id, imageData, pageProxy.objs);
  47221. break;
  47222. case 'Image':
  47223. imageData = data[3];
  47224. pageProxy.objs.resolve(id, imageData);
  47225. var MAX_IMAGE_SIZE_TO_STORE = 8000000;
  47226. if (imageData && 'data' in imageData && imageData.data.length > MAX_IMAGE_SIZE_TO_STORE) {
  47227. pageProxy.cleanupAfterRender = true;
  47228. }
  47229. break;
  47230. default:
  47231. error('Got unknown object type ' + type);
  47232. }
  47233. }, this);
  47234. messageHandler.on('DocProgress', function transportDocProgress(data) {
  47235. if (this.destroyed) {
  47236. return;
  47237. }
  47238. var loadingTask = this.loadingTask;
  47239. if (loadingTask.onProgress) {
  47240. loadingTask.onProgress({
  47241. loaded: data.loaded,
  47242. total: data.total
  47243. });
  47244. }
  47245. }, this);
  47246. messageHandler.on('PageError', function transportError(data) {
  47247. if (this.destroyed) {
  47248. return;
  47249. }
  47250. var page = this.pageCache[data.pageNum - 1];
  47251. var intentState = page.intentStates[data.intent];
  47252. if (intentState.displayReadyCapability) {
  47253. intentState.displayReadyCapability.reject(data.error);
  47254. } else {
  47255. error(data.error);
  47256. }
  47257. if (intentState.operatorList) {
  47258. intentState.operatorList.lastChunk = true;
  47259. for (var i = 0; i < intentState.renderTasks.length; i++) {
  47260. intentState.renderTasks[i].operatorListChanged();
  47261. }
  47262. }
  47263. }, this);
  47264. messageHandler.on('UnsupportedFeature', function transportUnsupportedFeature(data) {
  47265. if (this.destroyed) {
  47266. return;
  47267. }
  47268. var featureId = data.featureId;
  47269. var loadingTask = this.loadingTask;
  47270. if (loadingTask.onUnsupportedFeature) {
  47271. loadingTask.onUnsupportedFeature(featureId);
  47272. }
  47273. _UnsupportedManager.notify(featureId);
  47274. }, this);
  47275. messageHandler.on('JpegDecode', function (data) {
  47276. if (this.destroyed) {
  47277. return Promise.reject(new Error('Worker was destroyed'));
  47278. }
  47279. var imageUrl = data[0];
  47280. var components = data[1];
  47281. if (components !== 3 && components !== 1) {
  47282. return Promise.reject(new Error('Only 3 components or 1 component can be returned'));
  47283. }
  47284. return new Promise(function (resolve, reject) {
  47285. var img = new Image();
  47286. img.onload = function () {
  47287. var width = img.width;
  47288. var height = img.height;
  47289. var size = width * height;
  47290. var rgbaLength = size * 4;
  47291. var buf = new Uint8Array(size * components);
  47292. var tmpCanvas = createScratchCanvas(width, height);
  47293. var tmpCtx = tmpCanvas.getContext('2d');
  47294. tmpCtx.drawImage(img, 0, 0);
  47295. var data = tmpCtx.getImageData(0, 0, width, height).data;
  47296. var i, j;
  47297. if (components === 3) {
  47298. for (i = 0, j = 0; i < rgbaLength; i += 4, j += 3) {
  47299. buf[j] = data[i];
  47300. buf[j + 1] = data[i + 1];
  47301. buf[j + 2] = data[i + 2];
  47302. }
  47303. } else if (components === 1) {
  47304. for (i = 0, j = 0; i < rgbaLength; i += 4, j++) {
  47305. buf[j] = data[i];
  47306. }
  47307. }
  47308. resolve({
  47309. data: buf,
  47310. width: width,
  47311. height: height
  47312. });
  47313. };
  47314. img.onerror = function () {
  47315. reject(new Error('JpegDecode failed to load image'));
  47316. };
  47317. img.src = imageUrl;
  47318. });
  47319. }, this);
  47320. },
  47321. getData: function WorkerTransport_getData() {
  47322. return this.messageHandler.sendWithPromise('GetData', null);
  47323. },
  47324. getPage: function WorkerTransport_getPage(pageNumber, capability) {
  47325. if (!isInt(pageNumber) || pageNumber <= 0 || pageNumber > this.numPages) {
  47326. return Promise.reject(new Error('Invalid page request'));
  47327. }
  47328. var pageIndex = pageNumber - 1;
  47329. if (pageIndex in this.pagePromises) {
  47330. return this.pagePromises[pageIndex];
  47331. }
  47332. var promise = this.messageHandler.sendWithPromise('GetPage', { pageIndex: pageIndex }).then(function (pageInfo) {
  47333. if (this.destroyed) {
  47334. throw new Error('Transport destroyed');
  47335. }
  47336. var page = new PDFPageProxy(pageIndex, pageInfo, this);
  47337. this.pageCache[pageIndex] = page;
  47338. return page;
  47339. }.bind(this));
  47340. this.pagePromises[pageIndex] = promise;
  47341. return promise;
  47342. },
  47343. getPageIndex: function WorkerTransport_getPageIndexByRef(ref) {
  47344. return this.messageHandler.sendWithPromise('GetPageIndex', { ref: ref }).catch(function (reason) {
  47345. return Promise.reject(new Error(reason));
  47346. });
  47347. },
  47348. getAnnotations: function WorkerTransport_getAnnotations(pageIndex, intent) {
  47349. return this.messageHandler.sendWithPromise('GetAnnotations', {
  47350. pageIndex: pageIndex,
  47351. intent: intent
  47352. });
  47353. },
  47354. getDestinations: function WorkerTransport_getDestinations() {
  47355. return this.messageHandler.sendWithPromise('GetDestinations', null);
  47356. },
  47357. getDestination: function WorkerTransport_getDestination(id) {
  47358. return this.messageHandler.sendWithPromise('GetDestination', { id: id });
  47359. },
  47360. getPageLabels: function WorkerTransport_getPageLabels() {
  47361. return this.messageHandler.sendWithPromise('GetPageLabels', null);
  47362. },
  47363. getAttachments: function WorkerTransport_getAttachments() {
  47364. return this.messageHandler.sendWithPromise('GetAttachments', null);
  47365. },
  47366. getJavaScript: function WorkerTransport_getJavaScript() {
  47367. return this.messageHandler.sendWithPromise('GetJavaScript', null);
  47368. },
  47369. getOutline: function WorkerTransport_getOutline() {
  47370. return this.messageHandler.sendWithPromise('GetOutline', null);
  47371. },
  47372. getMetadata: function WorkerTransport_getMetadata() {
  47373. return this.messageHandler.sendWithPromise('GetMetadata', null).then(function transportMetadata(results) {
  47374. return {
  47375. info: results[0],
  47376. metadata: results[1] ? new Metadata(results[1]) : null
  47377. };
  47378. });
  47379. },
  47380. getStats: function WorkerTransport_getStats() {
  47381. return this.messageHandler.sendWithPromise('GetStats', null);
  47382. },
  47383. startCleanup: function WorkerTransport_startCleanup() {
  47384. this.messageHandler.sendWithPromise('Cleanup', null).then(function endCleanup() {
  47385. for (var i = 0, ii = this.pageCache.length; i < ii; i++) {
  47386. var page = this.pageCache[i];
  47387. if (page) {
  47388. page.cleanup();
  47389. }
  47390. }
  47391. this.commonObjs.clear();
  47392. this.fontLoader.clear();
  47393. }.bind(this));
  47394. }
  47395. };
  47396. return WorkerTransport;
  47397. }();
  47398. var PDFObjects = function PDFObjectsClosure() {
  47399. function PDFObjects() {
  47400. this.objs = Object.create(null);
  47401. }
  47402. PDFObjects.prototype = {
  47403. ensureObj: function PDFObjects_ensureObj(objId) {
  47404. if (this.objs[objId]) {
  47405. return this.objs[objId];
  47406. }
  47407. var obj = {
  47408. capability: createPromiseCapability(),
  47409. data: null,
  47410. resolved: false
  47411. };
  47412. this.objs[objId] = obj;
  47413. return obj;
  47414. },
  47415. get: function PDFObjects_get(objId, callback) {
  47416. if (callback) {
  47417. this.ensureObj(objId).capability.promise.then(callback);
  47418. return null;
  47419. }
  47420. var obj = this.objs[objId];
  47421. if (!obj || !obj.resolved) {
  47422. error('Requesting object that isn\'t resolved yet ' + objId);
  47423. }
  47424. return obj.data;
  47425. },
  47426. resolve: function PDFObjects_resolve(objId, data) {
  47427. var obj = this.ensureObj(objId);
  47428. obj.resolved = true;
  47429. obj.data = data;
  47430. obj.capability.resolve(data);
  47431. },
  47432. isResolved: function PDFObjects_isResolved(objId) {
  47433. var objs = this.objs;
  47434. if (!objs[objId]) {
  47435. return false;
  47436. } else {
  47437. return objs[objId].resolved;
  47438. }
  47439. },
  47440. hasData: function PDFObjects_hasData(objId) {
  47441. return this.isResolved(objId);
  47442. },
  47443. getData: function PDFObjects_getData(objId) {
  47444. var objs = this.objs;
  47445. if (!objs[objId] || !objs[objId].resolved) {
  47446. return null;
  47447. } else {
  47448. return objs[objId].data;
  47449. }
  47450. },
  47451. clear: function PDFObjects_clear() {
  47452. this.objs = Object.create(null);
  47453. }
  47454. };
  47455. return PDFObjects;
  47456. }();
  47457. var RenderTask = function RenderTaskClosure() {
  47458. function RenderTask(internalRenderTask) {
  47459. this._internalRenderTask = internalRenderTask;
  47460. this.onContinue = null;
  47461. }
  47462. RenderTask.prototype = {
  47463. get promise() {
  47464. return this._internalRenderTask.capability.promise;
  47465. },
  47466. cancel: function RenderTask_cancel() {
  47467. this._internalRenderTask.cancel();
  47468. },
  47469. then: function RenderTask_then(onFulfilled, onRejected) {
  47470. return this.promise.then.apply(this.promise, arguments);
  47471. }
  47472. };
  47473. return RenderTask;
  47474. }();
  47475. var InternalRenderTask = function InternalRenderTaskClosure() {
  47476. function InternalRenderTask(callback, params, objs, commonObjs, operatorList, pageNumber) {
  47477. this.callback = callback;
  47478. this.params = params;
  47479. this.objs = objs;
  47480. this.commonObjs = commonObjs;
  47481. this.operatorListIdx = null;
  47482. this.operatorList = operatorList;
  47483. this.pageNumber = pageNumber;
  47484. this.running = false;
  47485. this.graphicsReadyCallback = null;
  47486. this.graphicsReady = false;
  47487. this.useRequestAnimationFrame = false;
  47488. this.cancelled = false;
  47489. this.capability = createPromiseCapability();
  47490. this.task = new RenderTask(this);
  47491. this._continueBound = this._continue.bind(this);
  47492. this._scheduleNextBound = this._scheduleNext.bind(this);
  47493. this._nextBound = this._next.bind(this);
  47494. }
  47495. InternalRenderTask.prototype = {
  47496. initializeGraphics: function InternalRenderTask_initializeGraphics(transparency) {
  47497. if (this.cancelled) {
  47498. return;
  47499. }
  47500. if (getDefaultSetting('pdfBug') && globalScope.StepperManager && globalScope.StepperManager.enabled) {
  47501. this.stepper = globalScope.StepperManager.create(this.pageNumber - 1);
  47502. this.stepper.init(this.operatorList);
  47503. this.stepper.nextBreakPoint = this.stepper.getNextBreakPoint();
  47504. }
  47505. var params = this.params;
  47506. this.gfx = new CanvasGraphics(params.canvasContext, this.commonObjs, this.objs, params.imageLayer);
  47507. this.gfx.beginDrawing(params.transform, params.viewport, transparency);
  47508. this.operatorListIdx = 0;
  47509. this.graphicsReady = true;
  47510. if (this.graphicsReadyCallback) {
  47511. this.graphicsReadyCallback();
  47512. }
  47513. },
  47514. cancel: function InternalRenderTask_cancel() {
  47515. this.running = false;
  47516. this.cancelled = true;
  47517. this.callback('cancelled');
  47518. },
  47519. operatorListChanged: function InternalRenderTask_operatorListChanged() {
  47520. if (!this.graphicsReady) {
  47521. if (!this.graphicsReadyCallback) {
  47522. this.graphicsReadyCallback = this._continueBound;
  47523. }
  47524. return;
  47525. }
  47526. if (this.stepper) {
  47527. this.stepper.updateOperatorList(this.operatorList);
  47528. }
  47529. if (this.running) {
  47530. return;
  47531. }
  47532. this._continue();
  47533. },
  47534. _continue: function InternalRenderTask__continue() {
  47535. this.running = true;
  47536. if (this.cancelled) {
  47537. return;
  47538. }
  47539. if (this.task.onContinue) {
  47540. this.task.onContinue.call(this.task, this._scheduleNextBound);
  47541. } else {
  47542. this._scheduleNext();
  47543. }
  47544. },
  47545. _scheduleNext: function InternalRenderTask__scheduleNext() {
  47546. if (this.useRequestAnimationFrame && typeof window !== 'undefined') {
  47547. window.requestAnimationFrame(this._nextBound);
  47548. } else {
  47549. Promise.resolve(undefined).then(this._nextBound);
  47550. }
  47551. },
  47552. _next: function InternalRenderTask__next() {
  47553. if (this.cancelled) {
  47554. return;
  47555. }
  47556. this.operatorListIdx = this.gfx.executeOperatorList(this.operatorList, this.operatorListIdx, this._continueBound, this.stepper);
  47557. if (this.operatorListIdx === this.operatorList.argsArray.length) {
  47558. this.running = false;
  47559. if (this.operatorList.lastChunk) {
  47560. this.gfx.endDrawing();
  47561. this.callback();
  47562. }
  47563. }
  47564. }
  47565. };
  47566. return InternalRenderTask;
  47567. }();
  47568. var _UnsupportedManager = function UnsupportedManagerClosure() {
  47569. var listeners = [];
  47570. return {
  47571. listen: function (cb) {
  47572. deprecated('Global UnsupportedManager.listen is used: ' + ' use PDFDocumentLoadingTask.onUnsupportedFeature instead');
  47573. listeners.push(cb);
  47574. },
  47575. notify: function (featureId) {
  47576. for (var i = 0, ii = listeners.length; i < ii; i++) {
  47577. listeners[i](featureId);
  47578. }
  47579. }
  47580. };
  47581. }();
  47582. if (typeof pdfjsVersion !== 'undefined') {
  47583. exports.version = pdfjsVersion;
  47584. }
  47585. if (typeof pdfjsBuild !== 'undefined') {
  47586. exports.build = pdfjsBuild;
  47587. }
  47588. exports.getDocument = getDocument;
  47589. exports.PDFDataRangeTransport = PDFDataRangeTransport;
  47590. exports.PDFWorker = PDFWorker;
  47591. exports.PDFDocumentProxy = PDFDocumentProxy;
  47592. exports.PDFPageProxy = PDFPageProxy;
  47593. exports._UnsupportedManager = _UnsupportedManager;
  47594. }));
  47595. (function (root, factory) {
  47596. factory(root.pdfjsCoreColorSpace = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction);
  47597. }(this, function (exports, sharedUtil, corePrimitives, coreFunction) {
  47598. var error = sharedUtil.error;
  47599. var info = sharedUtil.info;
  47600. var isArray = sharedUtil.isArray;
  47601. var isString = sharedUtil.isString;
  47602. var shadow = sharedUtil.shadow;
  47603. var warn = sharedUtil.warn;
  47604. var isDict = corePrimitives.isDict;
  47605. var isName = corePrimitives.isName;
  47606. var isStream = corePrimitives.isStream;
  47607. var PDFFunction = coreFunction.PDFFunction;
  47608. var ColorSpace = function ColorSpaceClosure() {
  47609. function resizeRgbImage(src, bpc, w1, h1, w2, h2, alpha01, dest) {
  47610. var COMPONENTS = 3;
  47611. alpha01 = alpha01 !== 1 ? 0 : alpha01;
  47612. var xRatio = w1 / w2;
  47613. var yRatio = h1 / h2;
  47614. var i, j, py, newIndex = 0, oldIndex;
  47615. var xScaled = new Uint16Array(w2);
  47616. var w1Scanline = w1 * COMPONENTS;
  47617. for (i = 0; i < w2; i++) {
  47618. xScaled[i] = Math.floor(i * xRatio) * COMPONENTS;
  47619. }
  47620. for (i = 0; i < h2; i++) {
  47621. py = Math.floor(i * yRatio) * w1Scanline;
  47622. for (j = 0; j < w2; j++) {
  47623. oldIndex = py + xScaled[j];
  47624. dest[newIndex++] = src[oldIndex++];
  47625. dest[newIndex++] = src[oldIndex++];
  47626. dest[newIndex++] = src[oldIndex++];
  47627. newIndex += alpha01;
  47628. }
  47629. }
  47630. }
  47631. function ColorSpace() {
  47632. error('should not call ColorSpace constructor');
  47633. }
  47634. ColorSpace.prototype = {
  47635. getRgb: function ColorSpace_getRgb(src, srcOffset) {
  47636. var rgb = new Uint8Array(3);
  47637. this.getRgbItem(src, srcOffset, rgb, 0);
  47638. return rgb;
  47639. },
  47640. getRgbItem: function ColorSpace_getRgbItem(src, srcOffset, dest, destOffset) {
  47641. error('Should not call ColorSpace.getRgbItem');
  47642. },
  47643. getRgbBuffer: function ColorSpace_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47644. error('Should not call ColorSpace.getRgbBuffer');
  47645. },
  47646. getOutputLength: function ColorSpace_getOutputLength(inputLength, alpha01) {
  47647. error('Should not call ColorSpace.getOutputLength');
  47648. },
  47649. isPassthrough: function ColorSpace_isPassthrough(bits) {
  47650. return false;
  47651. },
  47652. fillRgb: function ColorSpace_fillRgb(dest, originalWidth, originalHeight, width, height, actualHeight, bpc, comps, alpha01) {
  47653. var count = originalWidth * originalHeight;
  47654. var rgbBuf = null;
  47655. var numComponentColors = 1 << bpc;
  47656. var needsResizing = originalHeight !== height || originalWidth !== width;
  47657. var i, ii;
  47658. if (this.isPassthrough(bpc)) {
  47659. rgbBuf = comps;
  47660. } else if (this.numComps === 1 && count > numComponentColors && this.name !== 'DeviceGray' && this.name !== 'DeviceRGB') {
  47661. var allColors = bpc <= 8 ? new Uint8Array(numComponentColors) : new Uint16Array(numComponentColors);
  47662. var key;
  47663. for (i = 0; i < numComponentColors; i++) {
  47664. allColors[i] = i;
  47665. }
  47666. var colorMap = new Uint8Array(numComponentColors * 3);
  47667. this.getRgbBuffer(allColors, 0, numComponentColors, colorMap, 0, bpc, 0);
  47668. var destPos, rgbPos;
  47669. if (!needsResizing) {
  47670. destPos = 0;
  47671. for (i = 0; i < count; ++i) {
  47672. key = comps[i] * 3;
  47673. dest[destPos++] = colorMap[key];
  47674. dest[destPos++] = colorMap[key + 1];
  47675. dest[destPos++] = colorMap[key + 2];
  47676. destPos += alpha01;
  47677. }
  47678. } else {
  47679. rgbBuf = new Uint8Array(count * 3);
  47680. rgbPos = 0;
  47681. for (i = 0; i < count; ++i) {
  47682. key = comps[i] * 3;
  47683. rgbBuf[rgbPos++] = colorMap[key];
  47684. rgbBuf[rgbPos++] = colorMap[key + 1];
  47685. rgbBuf[rgbPos++] = colorMap[key + 2];
  47686. }
  47687. }
  47688. } else {
  47689. if (!needsResizing) {
  47690. this.getRgbBuffer(comps, 0, width * actualHeight, dest, 0, bpc, alpha01);
  47691. } else {
  47692. rgbBuf = new Uint8Array(count * 3);
  47693. this.getRgbBuffer(comps, 0, count, rgbBuf, 0, bpc, 0);
  47694. }
  47695. }
  47696. if (rgbBuf) {
  47697. if (needsResizing) {
  47698. resizeRgbImage(rgbBuf, bpc, originalWidth, originalHeight, width, height, alpha01, dest);
  47699. } else {
  47700. rgbPos = 0;
  47701. destPos = 0;
  47702. for (i = 0, ii = width * actualHeight; i < ii; i++) {
  47703. dest[destPos++] = rgbBuf[rgbPos++];
  47704. dest[destPos++] = rgbBuf[rgbPos++];
  47705. dest[destPos++] = rgbBuf[rgbPos++];
  47706. destPos += alpha01;
  47707. }
  47708. }
  47709. }
  47710. },
  47711. usesZeroToOneRange: true
  47712. };
  47713. ColorSpace.parse = function ColorSpace_parse(cs, xref, res) {
  47714. var IR = ColorSpace.parseToIR(cs, xref, res);
  47715. if (IR instanceof AlternateCS) {
  47716. return IR;
  47717. }
  47718. return ColorSpace.fromIR(IR);
  47719. };
  47720. ColorSpace.fromIR = function ColorSpace_fromIR(IR) {
  47721. var name = isArray(IR) ? IR[0] : IR;
  47722. var whitePoint, blackPoint, gamma;
  47723. switch (name) {
  47724. case 'DeviceGrayCS':
  47725. return this.singletons.gray;
  47726. case 'DeviceRgbCS':
  47727. return this.singletons.rgb;
  47728. case 'DeviceCmykCS':
  47729. return this.singletons.cmyk;
  47730. case 'CalGrayCS':
  47731. whitePoint = IR[1];
  47732. blackPoint = IR[2];
  47733. gamma = IR[3];
  47734. return new CalGrayCS(whitePoint, blackPoint, gamma);
  47735. case 'CalRGBCS':
  47736. whitePoint = IR[1];
  47737. blackPoint = IR[2];
  47738. gamma = IR[3];
  47739. var matrix = IR[4];
  47740. return new CalRGBCS(whitePoint, blackPoint, gamma, matrix);
  47741. case 'PatternCS':
  47742. var basePatternCS = IR[1];
  47743. if (basePatternCS) {
  47744. basePatternCS = ColorSpace.fromIR(basePatternCS);
  47745. }
  47746. return new PatternCS(basePatternCS);
  47747. case 'IndexedCS':
  47748. var baseIndexedCS = IR[1];
  47749. var hiVal = IR[2];
  47750. var lookup = IR[3];
  47751. return new IndexedCS(ColorSpace.fromIR(baseIndexedCS), hiVal, lookup);
  47752. case 'AlternateCS':
  47753. var numComps = IR[1];
  47754. var alt = IR[2];
  47755. var tintFnIR = IR[3];
  47756. return new AlternateCS(numComps, ColorSpace.fromIR(alt), PDFFunction.fromIR(tintFnIR));
  47757. case 'LabCS':
  47758. whitePoint = IR[1];
  47759. blackPoint = IR[2];
  47760. var range = IR[3];
  47761. return new LabCS(whitePoint, blackPoint, range);
  47762. default:
  47763. error('Unknown name ' + name);
  47764. }
  47765. return null;
  47766. };
  47767. ColorSpace.parseToIR = function ColorSpace_parseToIR(cs, xref, res) {
  47768. if (isName(cs)) {
  47769. var colorSpaces = res.get('ColorSpace');
  47770. if (isDict(colorSpaces)) {
  47771. var refcs = colorSpaces.get(cs.name);
  47772. if (refcs) {
  47773. cs = refcs;
  47774. }
  47775. }
  47776. }
  47777. cs = xref.fetchIfRef(cs);
  47778. if (isName(cs)) {
  47779. switch (cs.name) {
  47780. case 'DeviceGray':
  47781. case 'G':
  47782. return 'DeviceGrayCS';
  47783. case 'DeviceRGB':
  47784. case 'RGB':
  47785. return 'DeviceRgbCS';
  47786. case 'DeviceCMYK':
  47787. case 'CMYK':
  47788. return 'DeviceCmykCS';
  47789. case 'Pattern':
  47790. return [
  47791. 'PatternCS',
  47792. null
  47793. ];
  47794. default:
  47795. error('unrecognized colorspace ' + cs.name);
  47796. }
  47797. } else if (isArray(cs)) {
  47798. var mode = xref.fetchIfRef(cs[0]).name;
  47799. var numComps, params, alt, whitePoint, blackPoint, gamma;
  47800. switch (mode) {
  47801. case 'DeviceGray':
  47802. case 'G':
  47803. return 'DeviceGrayCS';
  47804. case 'DeviceRGB':
  47805. case 'RGB':
  47806. return 'DeviceRgbCS';
  47807. case 'DeviceCMYK':
  47808. case 'CMYK':
  47809. return 'DeviceCmykCS';
  47810. case 'CalGray':
  47811. params = xref.fetchIfRef(cs[1]);
  47812. whitePoint = params.getArray('WhitePoint');
  47813. blackPoint = params.getArray('BlackPoint');
  47814. gamma = params.get('Gamma');
  47815. return [
  47816. 'CalGrayCS',
  47817. whitePoint,
  47818. blackPoint,
  47819. gamma
  47820. ];
  47821. case 'CalRGB':
  47822. params = xref.fetchIfRef(cs[1]);
  47823. whitePoint = params.getArray('WhitePoint');
  47824. blackPoint = params.getArray('BlackPoint');
  47825. gamma = params.getArray('Gamma');
  47826. var matrix = params.getArray('Matrix');
  47827. return [
  47828. 'CalRGBCS',
  47829. whitePoint,
  47830. blackPoint,
  47831. gamma,
  47832. matrix
  47833. ];
  47834. case 'ICCBased':
  47835. var stream = xref.fetchIfRef(cs[1]);
  47836. var dict = stream.dict;
  47837. numComps = dict.get('N');
  47838. alt = dict.get('Alternate');
  47839. if (alt) {
  47840. var altIR = ColorSpace.parseToIR(alt, xref, res);
  47841. var altCS = ColorSpace.fromIR(altIR);
  47842. if (altCS.numComps === numComps) {
  47843. return altIR;
  47844. }
  47845. warn('ICCBased color space: Ignoring incorrect /Alternate entry.');
  47846. }
  47847. if (numComps === 1) {
  47848. return 'DeviceGrayCS';
  47849. } else if (numComps === 3) {
  47850. return 'DeviceRgbCS';
  47851. } else if (numComps === 4) {
  47852. return 'DeviceCmykCS';
  47853. }
  47854. break;
  47855. case 'Pattern':
  47856. var basePatternCS = cs[1] || null;
  47857. if (basePatternCS) {
  47858. basePatternCS = ColorSpace.parseToIR(basePatternCS, xref, res);
  47859. }
  47860. return [
  47861. 'PatternCS',
  47862. basePatternCS
  47863. ];
  47864. case 'Indexed':
  47865. case 'I':
  47866. var baseIndexedCS = ColorSpace.parseToIR(cs[1], xref, res);
  47867. var hiVal = xref.fetchIfRef(cs[2]) + 1;
  47868. var lookup = xref.fetchIfRef(cs[3]);
  47869. if (isStream(lookup)) {
  47870. lookup = lookup.getBytes();
  47871. }
  47872. return [
  47873. 'IndexedCS',
  47874. baseIndexedCS,
  47875. hiVal,
  47876. lookup
  47877. ];
  47878. case 'Separation':
  47879. case 'DeviceN':
  47880. var name = xref.fetchIfRef(cs[1]);
  47881. numComps = isArray(name) ? name.length : 1;
  47882. alt = ColorSpace.parseToIR(cs[2], xref, res);
  47883. var tintFnIR = PDFFunction.getIR(xref, xref.fetchIfRef(cs[3]));
  47884. return [
  47885. 'AlternateCS',
  47886. numComps,
  47887. alt,
  47888. tintFnIR
  47889. ];
  47890. case 'Lab':
  47891. params = xref.fetchIfRef(cs[1]);
  47892. whitePoint = params.getArray('WhitePoint');
  47893. blackPoint = params.getArray('BlackPoint');
  47894. var range = params.getArray('Range');
  47895. return [
  47896. 'LabCS',
  47897. whitePoint,
  47898. blackPoint,
  47899. range
  47900. ];
  47901. default:
  47902. error('unimplemented color space object "' + mode + '"');
  47903. }
  47904. } else {
  47905. error('unrecognized color space object: "' + cs + '"');
  47906. }
  47907. return null;
  47908. };
  47909. ColorSpace.isDefaultDecode = function ColorSpace_isDefaultDecode(decode, n) {
  47910. if (!isArray(decode)) {
  47911. return true;
  47912. }
  47913. if (n * 2 !== decode.length) {
  47914. warn('The decode map is not the correct length');
  47915. return true;
  47916. }
  47917. for (var i = 0, ii = decode.length; i < ii; i += 2) {
  47918. if (decode[i] !== 0 || decode[i + 1] !== 1) {
  47919. return false;
  47920. }
  47921. }
  47922. return true;
  47923. };
  47924. ColorSpace.singletons = {
  47925. get gray() {
  47926. return shadow(this, 'gray', new DeviceGrayCS());
  47927. },
  47928. get rgb() {
  47929. return shadow(this, 'rgb', new DeviceRgbCS());
  47930. },
  47931. get cmyk() {
  47932. return shadow(this, 'cmyk', new DeviceCmykCS());
  47933. }
  47934. };
  47935. return ColorSpace;
  47936. }();
  47937. var AlternateCS = function AlternateCSClosure() {
  47938. function AlternateCS(numComps, base, tintFn) {
  47939. this.name = 'Alternate';
  47940. this.numComps = numComps;
  47941. this.defaultColor = new Float32Array(numComps);
  47942. for (var i = 0; i < numComps; ++i) {
  47943. this.defaultColor[i] = 1;
  47944. }
  47945. this.base = base;
  47946. this.tintFn = tintFn;
  47947. this.tmpBuf = new Float32Array(base.numComps);
  47948. }
  47949. AlternateCS.prototype = {
  47950. getRgb: ColorSpace.prototype.getRgb,
  47951. getRgbItem: function AlternateCS_getRgbItem(src, srcOffset, dest, destOffset) {
  47952. var tmpBuf = this.tmpBuf;
  47953. this.tintFn(src, srcOffset, tmpBuf, 0);
  47954. this.base.getRgbItem(tmpBuf, 0, dest, destOffset);
  47955. },
  47956. getRgbBuffer: function AlternateCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  47957. var tintFn = this.tintFn;
  47958. var base = this.base;
  47959. var scale = 1 / ((1 << bits) - 1);
  47960. var baseNumComps = base.numComps;
  47961. var usesZeroToOneRange = base.usesZeroToOneRange;
  47962. var isPassthrough = (base.isPassthrough(8) || !usesZeroToOneRange) && alpha01 === 0;
  47963. var pos = isPassthrough ? destOffset : 0;
  47964. var baseBuf = isPassthrough ? dest : new Uint8Array(baseNumComps * count);
  47965. var numComps = this.numComps;
  47966. var scaled = new Float32Array(numComps);
  47967. var tinted = new Float32Array(baseNumComps);
  47968. var i, j;
  47969. for (i = 0; i < count; i++) {
  47970. for (j = 0; j < numComps; j++) {
  47971. scaled[j] = src[srcOffset++] * scale;
  47972. }
  47973. tintFn(scaled, 0, tinted, 0);
  47974. if (usesZeroToOneRange) {
  47975. for (j = 0; j < baseNumComps; j++) {
  47976. baseBuf[pos++] = tinted[j] * 255;
  47977. }
  47978. } else {
  47979. base.getRgbItem(tinted, 0, baseBuf, pos);
  47980. pos += baseNumComps;
  47981. }
  47982. }
  47983. if (!isPassthrough) {
  47984. base.getRgbBuffer(baseBuf, 0, count, dest, destOffset, 8, alpha01);
  47985. }
  47986. },
  47987. getOutputLength: function AlternateCS_getOutputLength(inputLength, alpha01) {
  47988. return this.base.getOutputLength(inputLength * this.base.numComps / this.numComps, alpha01);
  47989. },
  47990. isPassthrough: ColorSpace.prototype.isPassthrough,
  47991. fillRgb: ColorSpace.prototype.fillRgb,
  47992. isDefaultDecode: function AlternateCS_isDefaultDecode(decodeMap) {
  47993. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  47994. },
  47995. usesZeroToOneRange: true
  47996. };
  47997. return AlternateCS;
  47998. }();
  47999. var PatternCS = function PatternCSClosure() {
  48000. function PatternCS(baseCS) {
  48001. this.name = 'Pattern';
  48002. this.base = baseCS;
  48003. }
  48004. PatternCS.prototype = {};
  48005. return PatternCS;
  48006. }();
  48007. var IndexedCS = function IndexedCSClosure() {
  48008. function IndexedCS(base, highVal, lookup) {
  48009. this.name = 'Indexed';
  48010. this.numComps = 1;
  48011. this.defaultColor = new Uint8Array(this.numComps);
  48012. this.base = base;
  48013. this.highVal = highVal;
  48014. var baseNumComps = base.numComps;
  48015. var length = baseNumComps * highVal;
  48016. if (isStream(lookup)) {
  48017. this.lookup = new Uint8Array(length);
  48018. var bytes = lookup.getBytes(length);
  48019. this.lookup.set(bytes);
  48020. } else if (isString(lookup)) {
  48021. this.lookup = new Uint8Array(length);
  48022. for (var i = 0; i < length; ++i) {
  48023. this.lookup[i] = lookup.charCodeAt(i);
  48024. }
  48025. } else if (lookup instanceof Uint8Array || lookup instanceof Array) {
  48026. this.lookup = lookup;
  48027. } else {
  48028. error('Unrecognized lookup table: ' + lookup);
  48029. }
  48030. }
  48031. IndexedCS.prototype = {
  48032. getRgb: ColorSpace.prototype.getRgb,
  48033. getRgbItem: function IndexedCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48034. var numComps = this.base.numComps;
  48035. var start = src[srcOffset] * numComps;
  48036. this.base.getRgbItem(this.lookup, start, dest, destOffset);
  48037. },
  48038. getRgbBuffer: function IndexedCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48039. var base = this.base;
  48040. var numComps = base.numComps;
  48041. var outputDelta = base.getOutputLength(numComps, alpha01);
  48042. var lookup = this.lookup;
  48043. for (var i = 0; i < count; ++i) {
  48044. var lookupPos = src[srcOffset++] * numComps;
  48045. base.getRgbBuffer(lookup, lookupPos, 1, dest, destOffset, 8, alpha01);
  48046. destOffset += outputDelta;
  48047. }
  48048. },
  48049. getOutputLength: function IndexedCS_getOutputLength(inputLength, alpha01) {
  48050. return this.base.getOutputLength(inputLength * this.base.numComps, alpha01);
  48051. },
  48052. isPassthrough: ColorSpace.prototype.isPassthrough,
  48053. fillRgb: ColorSpace.prototype.fillRgb,
  48054. isDefaultDecode: function IndexedCS_isDefaultDecode(decodeMap) {
  48055. return true;
  48056. },
  48057. usesZeroToOneRange: true
  48058. };
  48059. return IndexedCS;
  48060. }();
  48061. var DeviceGrayCS = function DeviceGrayCSClosure() {
  48062. function DeviceGrayCS() {
  48063. this.name = 'DeviceGray';
  48064. this.numComps = 1;
  48065. this.defaultColor = new Float32Array(this.numComps);
  48066. }
  48067. DeviceGrayCS.prototype = {
  48068. getRgb: ColorSpace.prototype.getRgb,
  48069. getRgbItem: function DeviceGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48070. var c = src[srcOffset] * 255 | 0;
  48071. c = c < 0 ? 0 : c > 255 ? 255 : c;
  48072. dest[destOffset] = dest[destOffset + 1] = dest[destOffset + 2] = c;
  48073. },
  48074. getRgbBuffer: function DeviceGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48075. var scale = 255 / ((1 << bits) - 1);
  48076. var j = srcOffset, q = destOffset;
  48077. for (var i = 0; i < count; ++i) {
  48078. var c = scale * src[j++] | 0;
  48079. dest[q++] = c;
  48080. dest[q++] = c;
  48081. dest[q++] = c;
  48082. q += alpha01;
  48083. }
  48084. },
  48085. getOutputLength: function DeviceGrayCS_getOutputLength(inputLength, alpha01) {
  48086. return inputLength * (3 + alpha01);
  48087. },
  48088. isPassthrough: ColorSpace.prototype.isPassthrough,
  48089. fillRgb: ColorSpace.prototype.fillRgb,
  48090. isDefaultDecode: function DeviceGrayCS_isDefaultDecode(decodeMap) {
  48091. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48092. },
  48093. usesZeroToOneRange: true
  48094. };
  48095. return DeviceGrayCS;
  48096. }();
  48097. var DeviceRgbCS = function DeviceRgbCSClosure() {
  48098. function DeviceRgbCS() {
  48099. this.name = 'DeviceRGB';
  48100. this.numComps = 3;
  48101. this.defaultColor = new Float32Array(this.numComps);
  48102. }
  48103. DeviceRgbCS.prototype = {
  48104. getRgb: ColorSpace.prototype.getRgb,
  48105. getRgbItem: function DeviceRgbCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48106. var r = src[srcOffset] * 255 | 0;
  48107. var g = src[srcOffset + 1] * 255 | 0;
  48108. var b = src[srcOffset + 2] * 255 | 0;
  48109. dest[destOffset] = r < 0 ? 0 : r > 255 ? 255 : r;
  48110. dest[destOffset + 1] = g < 0 ? 0 : g > 255 ? 255 : g;
  48111. dest[destOffset + 2] = b < 0 ? 0 : b > 255 ? 255 : b;
  48112. },
  48113. getRgbBuffer: function DeviceRgbCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48114. if (bits === 8 && alpha01 === 0) {
  48115. dest.set(src.subarray(srcOffset, srcOffset + count * 3), destOffset);
  48116. return;
  48117. }
  48118. var scale = 255 / ((1 << bits) - 1);
  48119. var j = srcOffset, q = destOffset;
  48120. for (var i = 0; i < count; ++i) {
  48121. dest[q++] = scale * src[j++] | 0;
  48122. dest[q++] = scale * src[j++] | 0;
  48123. dest[q++] = scale * src[j++] | 0;
  48124. q += alpha01;
  48125. }
  48126. },
  48127. getOutputLength: function DeviceRgbCS_getOutputLength(inputLength, alpha01) {
  48128. return inputLength * (3 + alpha01) / 3 | 0;
  48129. },
  48130. isPassthrough: function DeviceRgbCS_isPassthrough(bits) {
  48131. return bits === 8;
  48132. },
  48133. fillRgb: ColorSpace.prototype.fillRgb,
  48134. isDefaultDecode: function DeviceRgbCS_isDefaultDecode(decodeMap) {
  48135. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48136. },
  48137. usesZeroToOneRange: true
  48138. };
  48139. return DeviceRgbCS;
  48140. }();
  48141. var DeviceCmykCS = function DeviceCmykCSClosure() {
  48142. function convertToRgb(src, srcOffset, srcScale, dest, destOffset) {
  48143. var c = src[srcOffset + 0] * srcScale;
  48144. var m = src[srcOffset + 1] * srcScale;
  48145. var y = src[srcOffset + 2] * srcScale;
  48146. var k = src[srcOffset + 3] * srcScale;
  48147. 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;
  48148. 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;
  48149. 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;
  48150. dest[destOffset] = r > 255 ? 255 : r < 0 ? 0 : r;
  48151. dest[destOffset + 1] = g > 255 ? 255 : g < 0 ? 0 : g;
  48152. dest[destOffset + 2] = b > 255 ? 255 : b < 0 ? 0 : b;
  48153. }
  48154. function DeviceCmykCS() {
  48155. this.name = 'DeviceCMYK';
  48156. this.numComps = 4;
  48157. this.defaultColor = new Float32Array(this.numComps);
  48158. this.defaultColor[3] = 1;
  48159. }
  48160. DeviceCmykCS.prototype = {
  48161. getRgb: ColorSpace.prototype.getRgb,
  48162. getRgbItem: function DeviceCmykCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48163. convertToRgb(src, srcOffset, 1, dest, destOffset);
  48164. },
  48165. getRgbBuffer: function DeviceCmykCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48166. var scale = 1 / ((1 << bits) - 1);
  48167. for (var i = 0; i < count; i++) {
  48168. convertToRgb(src, srcOffset, scale, dest, destOffset);
  48169. srcOffset += 4;
  48170. destOffset += 3 + alpha01;
  48171. }
  48172. },
  48173. getOutputLength: function DeviceCmykCS_getOutputLength(inputLength, alpha01) {
  48174. return inputLength / 4 * (3 + alpha01) | 0;
  48175. },
  48176. isPassthrough: ColorSpace.prototype.isPassthrough,
  48177. fillRgb: ColorSpace.prototype.fillRgb,
  48178. isDefaultDecode: function DeviceCmykCS_isDefaultDecode(decodeMap) {
  48179. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48180. },
  48181. usesZeroToOneRange: true
  48182. };
  48183. return DeviceCmykCS;
  48184. }();
  48185. var CalGrayCS = function CalGrayCSClosure() {
  48186. function CalGrayCS(whitePoint, blackPoint, gamma) {
  48187. this.name = 'CalGray';
  48188. this.numComps = 1;
  48189. this.defaultColor = new Float32Array(this.numComps);
  48190. if (!whitePoint) {
  48191. error('WhitePoint missing - required for color space CalGray');
  48192. }
  48193. blackPoint = blackPoint || [
  48194. 0,
  48195. 0,
  48196. 0
  48197. ];
  48198. gamma = gamma || 1;
  48199. this.XW = whitePoint[0];
  48200. this.YW = whitePoint[1];
  48201. this.ZW = whitePoint[2];
  48202. this.XB = blackPoint[0];
  48203. this.YB = blackPoint[1];
  48204. this.ZB = blackPoint[2];
  48205. this.G = gamma;
  48206. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48207. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48208. }
  48209. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48210. info('Invalid BlackPoint for ' + this.name + ', falling back to default');
  48211. this.XB = this.YB = this.ZB = 0;
  48212. }
  48213. if (this.XB !== 0 || this.YB !== 0 || this.ZB !== 0) {
  48214. warn(this.name + ', BlackPoint: XB: ' + this.XB + ', YB: ' + this.YB + ', ZB: ' + this.ZB + ', only default values are supported.');
  48215. }
  48216. if (this.G < 1) {
  48217. info('Invalid Gamma: ' + this.G + ' for ' + this.name + ', falling back to default');
  48218. this.G = 1;
  48219. }
  48220. }
  48221. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48222. var A = src[srcOffset] * scale;
  48223. var AG = Math.pow(A, cs.G);
  48224. var L = cs.YW * AG;
  48225. var val = Math.max(295.8 * Math.pow(L, 0.333333333333333333) - 40.8, 0) | 0;
  48226. dest[destOffset] = val;
  48227. dest[destOffset + 1] = val;
  48228. dest[destOffset + 2] = val;
  48229. }
  48230. CalGrayCS.prototype = {
  48231. getRgb: ColorSpace.prototype.getRgb,
  48232. getRgbItem: function CalGrayCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48233. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48234. },
  48235. getRgbBuffer: function CalGrayCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48236. var scale = 1 / ((1 << bits) - 1);
  48237. for (var i = 0; i < count; ++i) {
  48238. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48239. srcOffset += 1;
  48240. destOffset += 3 + alpha01;
  48241. }
  48242. },
  48243. getOutputLength: function CalGrayCS_getOutputLength(inputLength, alpha01) {
  48244. return inputLength * (3 + alpha01);
  48245. },
  48246. isPassthrough: ColorSpace.prototype.isPassthrough,
  48247. fillRgb: ColorSpace.prototype.fillRgb,
  48248. isDefaultDecode: function CalGrayCS_isDefaultDecode(decodeMap) {
  48249. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48250. },
  48251. usesZeroToOneRange: true
  48252. };
  48253. return CalGrayCS;
  48254. }();
  48255. var CalRGBCS = function CalRGBCSClosure() {
  48256. var BRADFORD_SCALE_MATRIX = new Float32Array([
  48257. 0.8951,
  48258. 0.2664,
  48259. -0.1614,
  48260. -0.7502,
  48261. 1.7135,
  48262. 0.0367,
  48263. 0.0389,
  48264. -0.0685,
  48265. 1.0296
  48266. ]);
  48267. var BRADFORD_SCALE_INVERSE_MATRIX = new Float32Array([
  48268. 0.9869929,
  48269. -0.1470543,
  48270. 0.1599627,
  48271. 0.4323053,
  48272. 0.5183603,
  48273. 0.0492912,
  48274. -0.0085287,
  48275. 0.0400428,
  48276. 0.9684867
  48277. ]);
  48278. var SRGB_D65_XYZ_TO_RGB_MATRIX = new Float32Array([
  48279. 3.2404542,
  48280. -1.5371385,
  48281. -0.4985314,
  48282. -0.9692660,
  48283. 1.8760108,
  48284. 0.0415560,
  48285. 0.0556434,
  48286. -0.2040259,
  48287. 1.0572252
  48288. ]);
  48289. var FLAT_WHITEPOINT_MATRIX = new Float32Array([
  48290. 1,
  48291. 1,
  48292. 1
  48293. ]);
  48294. var tempNormalizeMatrix = new Float32Array(3);
  48295. var tempConvertMatrix1 = new Float32Array(3);
  48296. var tempConvertMatrix2 = new Float32Array(3);
  48297. var DECODE_L_CONSTANT = Math.pow((8 + 16) / 116, 3) / 8.0;
  48298. function CalRGBCS(whitePoint, blackPoint, gamma, matrix) {
  48299. this.name = 'CalRGB';
  48300. this.numComps = 3;
  48301. this.defaultColor = new Float32Array(this.numComps);
  48302. if (!whitePoint) {
  48303. error('WhitePoint missing - required for color space CalRGB');
  48304. }
  48305. blackPoint = blackPoint || new Float32Array(3);
  48306. gamma = gamma || new Float32Array([
  48307. 1,
  48308. 1,
  48309. 1
  48310. ]);
  48311. matrix = matrix || new Float32Array([
  48312. 1,
  48313. 0,
  48314. 0,
  48315. 0,
  48316. 1,
  48317. 0,
  48318. 0,
  48319. 0,
  48320. 1
  48321. ]);
  48322. var XW = whitePoint[0];
  48323. var YW = whitePoint[1];
  48324. var ZW = whitePoint[2];
  48325. this.whitePoint = whitePoint;
  48326. var XB = blackPoint[0];
  48327. var YB = blackPoint[1];
  48328. var ZB = blackPoint[2];
  48329. this.blackPoint = blackPoint;
  48330. this.GR = gamma[0];
  48331. this.GG = gamma[1];
  48332. this.GB = gamma[2];
  48333. this.MXA = matrix[0];
  48334. this.MYA = matrix[1];
  48335. this.MZA = matrix[2];
  48336. this.MXB = matrix[3];
  48337. this.MYB = matrix[4];
  48338. this.MZB = matrix[5];
  48339. this.MXC = matrix[6];
  48340. this.MYC = matrix[7];
  48341. this.MZC = matrix[8];
  48342. if (XW < 0 || ZW < 0 || YW !== 1) {
  48343. error('Invalid WhitePoint components for ' + this.name + ', no fallback available');
  48344. }
  48345. if (XB < 0 || YB < 0 || ZB < 0) {
  48346. info('Invalid BlackPoint for ' + this.name + ' [' + XB + ', ' + YB + ', ' + ZB + '], falling back to default');
  48347. this.blackPoint = new Float32Array(3);
  48348. }
  48349. if (this.GR < 0 || this.GG < 0 || this.GB < 0) {
  48350. info('Invalid Gamma [' + this.GR + ', ' + this.GG + ', ' + this.GB + '] for ' + this.name + ', falling back to default');
  48351. this.GR = this.GG = this.GB = 1;
  48352. }
  48353. 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) {
  48354. 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');
  48355. this.MXA = this.MYB = this.MZC = 1;
  48356. this.MXB = this.MYA = this.MZA = this.MXC = this.MYC = this.MZB = 0;
  48357. }
  48358. }
  48359. function matrixProduct(a, b, result) {
  48360. result[0] = a[0] * b[0] + a[1] * b[1] + a[2] * b[2];
  48361. result[1] = a[3] * b[0] + a[4] * b[1] + a[5] * b[2];
  48362. result[2] = a[6] * b[0] + a[7] * b[1] + a[8] * b[2];
  48363. }
  48364. function convertToFlat(sourceWhitePoint, LMS, result) {
  48365. result[0] = LMS[0] * 1 / sourceWhitePoint[0];
  48366. result[1] = LMS[1] * 1 / sourceWhitePoint[1];
  48367. result[2] = LMS[2] * 1 / sourceWhitePoint[2];
  48368. }
  48369. function convertToD65(sourceWhitePoint, LMS, result) {
  48370. var D65X = 0.95047;
  48371. var D65Y = 1;
  48372. var D65Z = 1.08883;
  48373. result[0] = LMS[0] * D65X / sourceWhitePoint[0];
  48374. result[1] = LMS[1] * D65Y / sourceWhitePoint[1];
  48375. result[2] = LMS[2] * D65Z / sourceWhitePoint[2];
  48376. }
  48377. function sRGBTransferFunction(color) {
  48378. if (color <= 0.0031308) {
  48379. return adjustToRange(0, 1, 12.92 * color);
  48380. }
  48381. return adjustToRange(0, 1, (1 + 0.055) * Math.pow(color, 1 / 2.4) - 0.055);
  48382. }
  48383. function adjustToRange(min, max, value) {
  48384. return Math.max(min, Math.min(max, value));
  48385. }
  48386. function decodeL(L) {
  48387. if (L < 0) {
  48388. return -decodeL(-L);
  48389. }
  48390. if (L > 8.0) {
  48391. return Math.pow((L + 16) / 116, 3);
  48392. }
  48393. return L * DECODE_L_CONSTANT;
  48394. }
  48395. function compensateBlackPoint(sourceBlackPoint, XYZ_Flat, result) {
  48396. if (sourceBlackPoint[0] === 0 && sourceBlackPoint[1] === 0 && sourceBlackPoint[2] === 0) {
  48397. result[0] = XYZ_Flat[0];
  48398. result[1] = XYZ_Flat[1];
  48399. result[2] = XYZ_Flat[2];
  48400. return;
  48401. }
  48402. var zeroDecodeL = decodeL(0);
  48403. var X_DST = zeroDecodeL;
  48404. var X_SRC = decodeL(sourceBlackPoint[0]);
  48405. var Y_DST = zeroDecodeL;
  48406. var Y_SRC = decodeL(sourceBlackPoint[1]);
  48407. var Z_DST = zeroDecodeL;
  48408. var Z_SRC = decodeL(sourceBlackPoint[2]);
  48409. var X_Scale = (1 - X_DST) / (1 - X_SRC);
  48410. var X_Offset = 1 - X_Scale;
  48411. var Y_Scale = (1 - Y_DST) / (1 - Y_SRC);
  48412. var Y_Offset = 1 - Y_Scale;
  48413. var Z_Scale = (1 - Z_DST) / (1 - Z_SRC);
  48414. var Z_Offset = 1 - Z_Scale;
  48415. result[0] = XYZ_Flat[0] * X_Scale + X_Offset;
  48416. result[1] = XYZ_Flat[1] * Y_Scale + Y_Offset;
  48417. result[2] = XYZ_Flat[2] * Z_Scale + Z_Offset;
  48418. }
  48419. function normalizeWhitePointToFlat(sourceWhitePoint, XYZ_In, result) {
  48420. if (sourceWhitePoint[0] === 1 && sourceWhitePoint[2] === 1) {
  48421. result[0] = XYZ_In[0];
  48422. result[1] = XYZ_In[1];
  48423. result[2] = XYZ_In[2];
  48424. return;
  48425. }
  48426. var LMS = result;
  48427. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48428. var LMS_Flat = tempNormalizeMatrix;
  48429. convertToFlat(sourceWhitePoint, LMS, LMS_Flat);
  48430. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_Flat, result);
  48431. }
  48432. function normalizeWhitePointToD65(sourceWhitePoint, XYZ_In, result) {
  48433. var LMS = result;
  48434. matrixProduct(BRADFORD_SCALE_MATRIX, XYZ_In, LMS);
  48435. var LMS_D65 = tempNormalizeMatrix;
  48436. convertToD65(sourceWhitePoint, LMS, LMS_D65);
  48437. matrixProduct(BRADFORD_SCALE_INVERSE_MATRIX, LMS_D65, result);
  48438. }
  48439. function convertToRgb(cs, src, srcOffset, dest, destOffset, scale) {
  48440. var A = adjustToRange(0, 1, src[srcOffset] * scale);
  48441. var B = adjustToRange(0, 1, src[srcOffset + 1] * scale);
  48442. var C = adjustToRange(0, 1, src[srcOffset + 2] * scale);
  48443. var AGR = Math.pow(A, cs.GR);
  48444. var BGG = Math.pow(B, cs.GG);
  48445. var CGB = Math.pow(C, cs.GB);
  48446. var X = cs.MXA * AGR + cs.MXB * BGG + cs.MXC * CGB;
  48447. var Y = cs.MYA * AGR + cs.MYB * BGG + cs.MYC * CGB;
  48448. var Z = cs.MZA * AGR + cs.MZB * BGG + cs.MZC * CGB;
  48449. var XYZ = tempConvertMatrix1;
  48450. XYZ[0] = X;
  48451. XYZ[1] = Y;
  48452. XYZ[2] = Z;
  48453. var XYZ_Flat = tempConvertMatrix2;
  48454. normalizeWhitePointToFlat(cs.whitePoint, XYZ, XYZ_Flat);
  48455. var XYZ_Black = tempConvertMatrix1;
  48456. compensateBlackPoint(cs.blackPoint, XYZ_Flat, XYZ_Black);
  48457. var XYZ_D65 = tempConvertMatrix2;
  48458. normalizeWhitePointToD65(FLAT_WHITEPOINT_MATRIX, XYZ_Black, XYZ_D65);
  48459. var SRGB = tempConvertMatrix1;
  48460. matrixProduct(SRGB_D65_XYZ_TO_RGB_MATRIX, XYZ_D65, SRGB);
  48461. var sR = sRGBTransferFunction(SRGB[0]);
  48462. var sG = sRGBTransferFunction(SRGB[1]);
  48463. var sB = sRGBTransferFunction(SRGB[2]);
  48464. dest[destOffset] = Math.round(sR * 255);
  48465. dest[destOffset + 1] = Math.round(sG * 255);
  48466. dest[destOffset + 2] = Math.round(sB * 255);
  48467. }
  48468. CalRGBCS.prototype = {
  48469. getRgb: function CalRGBCS_getRgb(src, srcOffset) {
  48470. var rgb = new Uint8Array(3);
  48471. this.getRgbItem(src, srcOffset, rgb, 0);
  48472. return rgb;
  48473. },
  48474. getRgbItem: function CalRGBCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48475. convertToRgb(this, src, srcOffset, dest, destOffset, 1);
  48476. },
  48477. getRgbBuffer: function CalRGBCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48478. var scale = 1 / ((1 << bits) - 1);
  48479. for (var i = 0; i < count; ++i) {
  48480. convertToRgb(this, src, srcOffset, dest, destOffset, scale);
  48481. srcOffset += 3;
  48482. destOffset += 3 + alpha01;
  48483. }
  48484. },
  48485. getOutputLength: function CalRGBCS_getOutputLength(inputLength, alpha01) {
  48486. return inputLength * (3 + alpha01) / 3 | 0;
  48487. },
  48488. isPassthrough: ColorSpace.prototype.isPassthrough,
  48489. fillRgb: ColorSpace.prototype.fillRgb,
  48490. isDefaultDecode: function CalRGBCS_isDefaultDecode(decodeMap) {
  48491. return ColorSpace.isDefaultDecode(decodeMap, this.numComps);
  48492. },
  48493. usesZeroToOneRange: true
  48494. };
  48495. return CalRGBCS;
  48496. }();
  48497. var LabCS = function LabCSClosure() {
  48498. function LabCS(whitePoint, blackPoint, range) {
  48499. this.name = 'Lab';
  48500. this.numComps = 3;
  48501. this.defaultColor = new Float32Array(this.numComps);
  48502. if (!whitePoint) {
  48503. error('WhitePoint missing - required for color space Lab');
  48504. }
  48505. blackPoint = blackPoint || [
  48506. 0,
  48507. 0,
  48508. 0
  48509. ];
  48510. range = range || [
  48511. -100,
  48512. 100,
  48513. -100,
  48514. 100
  48515. ];
  48516. this.XW = whitePoint[0];
  48517. this.YW = whitePoint[1];
  48518. this.ZW = whitePoint[2];
  48519. this.amin = range[0];
  48520. this.amax = range[1];
  48521. this.bmin = range[2];
  48522. this.bmax = range[3];
  48523. this.XB = blackPoint[0];
  48524. this.YB = blackPoint[1];
  48525. this.ZB = blackPoint[2];
  48526. if (this.XW < 0 || this.ZW < 0 || this.YW !== 1) {
  48527. error('Invalid WhitePoint components, no fallback available');
  48528. }
  48529. if (this.XB < 0 || this.YB < 0 || this.ZB < 0) {
  48530. info('Invalid BlackPoint, falling back to default');
  48531. this.XB = this.YB = this.ZB = 0;
  48532. }
  48533. if (this.amin > this.amax || this.bmin > this.bmax) {
  48534. info('Invalid Range, falling back to defaults');
  48535. this.amin = -100;
  48536. this.amax = 100;
  48537. this.bmin = -100;
  48538. this.bmax = 100;
  48539. }
  48540. }
  48541. function fn_g(x) {
  48542. if (x >= 6 / 29) {
  48543. return x * x * x;
  48544. } else {
  48545. return 108 / 841 * (x - 4 / 29);
  48546. }
  48547. }
  48548. function decode(value, high1, low2, high2) {
  48549. return low2 + value * (high2 - low2) / high1;
  48550. }
  48551. function convertToRgb(cs, src, srcOffset, maxVal, dest, destOffset) {
  48552. var Ls = src[srcOffset];
  48553. var as = src[srcOffset + 1];
  48554. var bs = src[srcOffset + 2];
  48555. if (maxVal !== false) {
  48556. Ls = decode(Ls, maxVal, 0, 100);
  48557. as = decode(as, maxVal, cs.amin, cs.amax);
  48558. bs = decode(bs, maxVal, cs.bmin, cs.bmax);
  48559. }
  48560. as = as > cs.amax ? cs.amax : as < cs.amin ? cs.amin : as;
  48561. bs = bs > cs.bmax ? cs.bmax : bs < cs.bmin ? cs.bmin : bs;
  48562. var M = (Ls + 16) / 116;
  48563. var L = M + as / 500;
  48564. var N = M - bs / 200;
  48565. var X = cs.XW * fn_g(L);
  48566. var Y = cs.YW * fn_g(M);
  48567. var Z = cs.ZW * fn_g(N);
  48568. var r, g, b;
  48569. if (cs.ZW < 1) {
  48570. r = X * 3.1339 + Y * -1.6170 + Z * -0.4906;
  48571. g = X * -0.9785 + Y * 1.9160 + Z * 0.0333;
  48572. b = X * 0.0720 + Y * -0.2290 + Z * 1.4057;
  48573. } else {
  48574. r = X * 3.2406 + Y * -1.5372 + Z * -0.4986;
  48575. g = X * -0.9689 + Y * 1.8758 + Z * 0.0415;
  48576. b = X * 0.0557 + Y * -0.2040 + Z * 1.0570;
  48577. }
  48578. dest[destOffset] = r <= 0 ? 0 : r >= 1 ? 255 : Math.sqrt(r) * 255 | 0;
  48579. dest[destOffset + 1] = g <= 0 ? 0 : g >= 1 ? 255 : Math.sqrt(g) * 255 | 0;
  48580. dest[destOffset + 2] = b <= 0 ? 0 : b >= 1 ? 255 : Math.sqrt(b) * 255 | 0;
  48581. }
  48582. LabCS.prototype = {
  48583. getRgb: ColorSpace.prototype.getRgb,
  48584. getRgbItem: function LabCS_getRgbItem(src, srcOffset, dest, destOffset) {
  48585. convertToRgb(this, src, srcOffset, false, dest, destOffset);
  48586. },
  48587. getRgbBuffer: function LabCS_getRgbBuffer(src, srcOffset, count, dest, destOffset, bits, alpha01) {
  48588. var maxVal = (1 << bits) - 1;
  48589. for (var i = 0; i < count; i++) {
  48590. convertToRgb(this, src, srcOffset, maxVal, dest, destOffset);
  48591. srcOffset += 3;
  48592. destOffset += 3 + alpha01;
  48593. }
  48594. },
  48595. getOutputLength: function LabCS_getOutputLength(inputLength, alpha01) {
  48596. return inputLength * (3 + alpha01) / 3 | 0;
  48597. },
  48598. isPassthrough: ColorSpace.prototype.isPassthrough,
  48599. fillRgb: ColorSpace.prototype.fillRgb,
  48600. isDefaultDecode: function LabCS_isDefaultDecode(decodeMap) {
  48601. return true;
  48602. },
  48603. usesZeroToOneRange: false
  48604. };
  48605. return LabCS;
  48606. }();
  48607. exports.ColorSpace = ColorSpace;
  48608. }));
  48609. (function (root, factory) {
  48610. factory(root.pdfjsDisplayGlobal = {}, root.pdfjsSharedUtil, root.pdfjsDisplayDOMUtils, root.pdfjsDisplayAPI, root.pdfjsDisplayAnnotationLayer, root.pdfjsDisplayTextLayer, root.pdfjsDisplayMetadata, root.pdfjsDisplaySVG);
  48611. }(this, function (exports, sharedUtil, displayDOMUtils, displayAPI, displayAnnotationLayer, displayTextLayer, displayMetadata, displaySVG) {
  48612. var globalScope = sharedUtil.globalScope;
  48613. var deprecated = sharedUtil.deprecated;
  48614. var warn = sharedUtil.warn;
  48615. var LinkTarget = displayDOMUtils.LinkTarget;
  48616. var isWorker = typeof window === 'undefined';
  48617. if (!globalScope.PDFJS) {
  48618. globalScope.PDFJS = {};
  48619. }
  48620. var PDFJS = globalScope.PDFJS;
  48621. if (typeof pdfjsVersion !== 'undefined') {
  48622. PDFJS.version = pdfjsVersion;
  48623. }
  48624. if (typeof pdfjsBuild !== 'undefined') {
  48625. PDFJS.build = pdfjsBuild;
  48626. }
  48627. PDFJS.pdfBug = false;
  48628. if (PDFJS.verbosity !== undefined) {
  48629. sharedUtil.setVerbosityLevel(PDFJS.verbosity);
  48630. }
  48631. delete PDFJS.verbosity;
  48632. Object.defineProperty(PDFJS, 'verbosity', {
  48633. get: function () {
  48634. return sharedUtil.getVerbosityLevel();
  48635. },
  48636. set: function (level) {
  48637. sharedUtil.setVerbosityLevel(level);
  48638. },
  48639. enumerable: true,
  48640. configurable: true
  48641. });
  48642. PDFJS.VERBOSITY_LEVELS = sharedUtil.VERBOSITY_LEVELS;
  48643. PDFJS.OPS = sharedUtil.OPS;
  48644. PDFJS.UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  48645. PDFJS.isValidUrl = displayDOMUtils.isValidUrl;
  48646. PDFJS.shadow = sharedUtil.shadow;
  48647. PDFJS.createBlob = sharedUtil.createBlob;
  48648. PDFJS.createObjectURL = function PDFJS_createObjectURL(data, contentType) {
  48649. return sharedUtil.createObjectURL(data, contentType, PDFJS.disableCreateObjectURL);
  48650. };
  48651. Object.defineProperty(PDFJS, 'isLittleEndian', {
  48652. configurable: true,
  48653. get: function PDFJS_isLittleEndian() {
  48654. var value = sharedUtil.isLittleEndian();
  48655. return sharedUtil.shadow(PDFJS, 'isLittleEndian', value);
  48656. }
  48657. });
  48658. PDFJS.removeNullCharacters = sharedUtil.removeNullCharacters;
  48659. PDFJS.PasswordResponses = sharedUtil.PasswordResponses;
  48660. PDFJS.PasswordException = sharedUtil.PasswordException;
  48661. PDFJS.UnknownErrorException = sharedUtil.UnknownErrorException;
  48662. PDFJS.InvalidPDFException = sharedUtil.InvalidPDFException;
  48663. PDFJS.MissingPDFException = sharedUtil.MissingPDFException;
  48664. PDFJS.UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  48665. PDFJS.Util = sharedUtil.Util;
  48666. PDFJS.PageViewport = sharedUtil.PageViewport;
  48667. PDFJS.createPromiseCapability = sharedUtil.createPromiseCapability;
  48668. PDFJS.maxImageSize = PDFJS.maxImageSize === undefined ? -1 : PDFJS.maxImageSize;
  48669. PDFJS.cMapUrl = PDFJS.cMapUrl === undefined ? null : PDFJS.cMapUrl;
  48670. PDFJS.cMapPacked = PDFJS.cMapPacked === undefined ? false : PDFJS.cMapPacked;
  48671. PDFJS.disableFontFace = PDFJS.disableFontFace === undefined ? false : PDFJS.disableFontFace;
  48672. PDFJS.imageResourcesPath = PDFJS.imageResourcesPath === undefined ? '' : PDFJS.imageResourcesPath;
  48673. PDFJS.disableWorker = PDFJS.disableWorker === undefined ? false : PDFJS.disableWorker;
  48674. PDFJS.workerSrc = PDFJS.workerSrc === undefined ? null : PDFJS.workerSrc;
  48675. PDFJS.disableRange = PDFJS.disableRange === undefined ? false : PDFJS.disableRange;
  48676. PDFJS.disableStream = PDFJS.disableStream === undefined ? false : PDFJS.disableStream;
  48677. PDFJS.disableAutoFetch = PDFJS.disableAutoFetch === undefined ? false : PDFJS.disableAutoFetch;
  48678. PDFJS.pdfBug = PDFJS.pdfBug === undefined ? false : PDFJS.pdfBug;
  48679. PDFJS.postMessageTransfers = PDFJS.postMessageTransfers === undefined ? true : PDFJS.postMessageTransfers;
  48680. PDFJS.disableCreateObjectURL = PDFJS.disableCreateObjectURL === undefined ? false : PDFJS.disableCreateObjectURL;
  48681. PDFJS.disableWebGL = PDFJS.disableWebGL === undefined ? true : PDFJS.disableWebGL;
  48682. PDFJS.externalLinkTarget = PDFJS.externalLinkTarget === undefined ? LinkTarget.NONE : PDFJS.externalLinkTarget;
  48683. PDFJS.externalLinkRel = PDFJS.externalLinkRel === undefined ? 'noreferrer' : PDFJS.externalLinkRel;
  48684. PDFJS.isEvalSupported = PDFJS.isEvalSupported === undefined ? true : PDFJS.isEvalSupported;
  48685. var savedOpenExternalLinksInNewWindow = PDFJS.openExternalLinksInNewWindow;
  48686. delete PDFJS.openExternalLinksInNewWindow;
  48687. Object.defineProperty(PDFJS, 'openExternalLinksInNewWindow', {
  48688. get: function () {
  48689. return PDFJS.externalLinkTarget === LinkTarget.BLANK;
  48690. },
  48691. set: function (value) {
  48692. if (value) {
  48693. deprecated('PDFJS.openExternalLinksInNewWindow, please use ' + '"PDFJS.externalLinkTarget = PDFJS.LinkTarget.BLANK" instead.');
  48694. }
  48695. if (PDFJS.externalLinkTarget !== LinkTarget.NONE) {
  48696. warn('PDFJS.externalLinkTarget is already initialized');
  48697. return;
  48698. }
  48699. PDFJS.externalLinkTarget = value ? LinkTarget.BLANK : LinkTarget.NONE;
  48700. },
  48701. enumerable: true,
  48702. configurable: true
  48703. });
  48704. if (savedOpenExternalLinksInNewWindow) {
  48705. PDFJS.openExternalLinksInNewWindow = savedOpenExternalLinksInNewWindow;
  48706. }
  48707. PDFJS.getDocument = displayAPI.getDocument;
  48708. PDFJS.PDFDataRangeTransport = displayAPI.PDFDataRangeTransport;
  48709. PDFJS.PDFWorker = displayAPI.PDFWorker;
  48710. Object.defineProperty(PDFJS, 'hasCanvasTypedArrays', {
  48711. configurable: true,
  48712. get: function PDFJS_hasCanvasTypedArrays() {
  48713. var value = displayDOMUtils.hasCanvasTypedArrays();
  48714. return sharedUtil.shadow(PDFJS, 'hasCanvasTypedArrays', value);
  48715. }
  48716. });
  48717. PDFJS.CustomStyle = displayDOMUtils.CustomStyle;
  48718. PDFJS.LinkTarget = LinkTarget;
  48719. PDFJS.addLinkAttributes = displayDOMUtils.addLinkAttributes;
  48720. PDFJS.getFilenameFromUrl = displayDOMUtils.getFilenameFromUrl;
  48721. PDFJS.isExternalLinkTargetSet = displayDOMUtils.isExternalLinkTargetSet;
  48722. PDFJS.AnnotationLayer = displayAnnotationLayer.AnnotationLayer;
  48723. PDFJS.renderTextLayer = displayTextLayer.renderTextLayer;
  48724. PDFJS.Metadata = displayMetadata.Metadata;
  48725. PDFJS.SVGGraphics = displaySVG.SVGGraphics;
  48726. PDFJS.UnsupportedManager = displayAPI._UnsupportedManager;
  48727. exports.globalScope = globalScope;
  48728. exports.isWorker = isWorker;
  48729. exports.PDFJS = globalScope.PDFJS;
  48730. }));
  48731. (function (root, factory) {
  48732. factory(root.pdfjsCoreImage = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreColorSpace, root.pdfjsCoreStream, root.pdfjsCoreJpx);
  48733. }(this, function (exports, sharedUtil, corePrimitives, coreColorSpace, coreStream, coreJpx) {
  48734. var ImageKind = sharedUtil.ImageKind;
  48735. var assert = sharedUtil.assert;
  48736. var error = sharedUtil.error;
  48737. var info = sharedUtil.info;
  48738. var isArray = sharedUtil.isArray;
  48739. var warn = sharedUtil.warn;
  48740. var Name = corePrimitives.Name;
  48741. var isStream = corePrimitives.isStream;
  48742. var ColorSpace = coreColorSpace.ColorSpace;
  48743. var DecodeStream = coreStream.DecodeStream;
  48744. var JpegStream = coreStream.JpegStream;
  48745. var JpxImage = coreJpx.JpxImage;
  48746. var PDFImage = function PDFImageClosure() {
  48747. function handleImageData(image, nativeDecoder) {
  48748. if (nativeDecoder && nativeDecoder.canDecode(image)) {
  48749. return nativeDecoder.decode(image);
  48750. } else {
  48751. return Promise.resolve(image);
  48752. }
  48753. }
  48754. function decodeAndClamp(value, addend, coefficient, max) {
  48755. value = addend + value * coefficient;
  48756. return value < 0 ? 0 : value > max ? max : value;
  48757. }
  48758. function resizeImageMask(src, bpc, w1, h1, w2, h2) {
  48759. var length = w2 * h2;
  48760. var dest = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48761. var xRatio = w1 / w2;
  48762. var yRatio = h1 / h2;
  48763. var i, j, py, newIndex = 0, oldIndex;
  48764. var xScaled = new Uint16Array(w2);
  48765. var w1Scanline = w1;
  48766. for (i = 0; i < w2; i++) {
  48767. xScaled[i] = Math.floor(i * xRatio);
  48768. }
  48769. for (i = 0; i < h2; i++) {
  48770. py = Math.floor(i * yRatio) * w1Scanline;
  48771. for (j = 0; j < w2; j++) {
  48772. oldIndex = py + xScaled[j];
  48773. dest[newIndex++] = src[oldIndex];
  48774. }
  48775. }
  48776. return dest;
  48777. }
  48778. function PDFImage(xref, res, image, inline, smask, mask, isMask) {
  48779. this.image = image;
  48780. var dict = image.dict;
  48781. if (dict.has('Filter')) {
  48782. var filter = dict.get('Filter').name;
  48783. if (filter === 'JPXDecode') {
  48784. var jpxImage = new JpxImage();
  48785. jpxImage.parseImageProperties(image.stream);
  48786. image.stream.reset();
  48787. image.bitsPerComponent = jpxImage.bitsPerComponent;
  48788. image.numComps = jpxImage.componentsCount;
  48789. } else if (filter === 'JBIG2Decode') {
  48790. image.bitsPerComponent = 1;
  48791. image.numComps = 1;
  48792. }
  48793. }
  48794. this.width = dict.get('Width', 'W');
  48795. this.height = dict.get('Height', 'H');
  48796. if (this.width < 1 || this.height < 1) {
  48797. error('Invalid image width: ' + this.width + ' or height: ' + this.height);
  48798. }
  48799. this.interpolate = dict.get('Interpolate', 'I') || false;
  48800. this.imageMask = dict.get('ImageMask', 'IM') || false;
  48801. this.matte = dict.get('Matte') || false;
  48802. var bitsPerComponent = image.bitsPerComponent;
  48803. if (!bitsPerComponent) {
  48804. bitsPerComponent = dict.get('BitsPerComponent', 'BPC');
  48805. if (!bitsPerComponent) {
  48806. if (this.imageMask) {
  48807. bitsPerComponent = 1;
  48808. } else {
  48809. error('Bits per component missing in image: ' + this.imageMask);
  48810. }
  48811. }
  48812. }
  48813. this.bpc = bitsPerComponent;
  48814. if (!this.imageMask) {
  48815. var colorSpace = dict.get('ColorSpace', 'CS');
  48816. if (!colorSpace) {
  48817. info('JPX images (which do not require color spaces)');
  48818. switch (image.numComps) {
  48819. case 1:
  48820. colorSpace = Name.get('DeviceGray');
  48821. break;
  48822. case 3:
  48823. colorSpace = Name.get('DeviceRGB');
  48824. break;
  48825. case 4:
  48826. colorSpace = Name.get('DeviceCMYK');
  48827. break;
  48828. default:
  48829. error('JPX images with ' + this.numComps + ' color components not supported.');
  48830. }
  48831. }
  48832. this.colorSpace = ColorSpace.parse(colorSpace, xref, res);
  48833. this.numComps = this.colorSpace.numComps;
  48834. }
  48835. this.decode = dict.getArray('Decode', 'D');
  48836. this.needsDecode = false;
  48837. if (this.decode && (this.colorSpace && !this.colorSpace.isDefaultDecode(this.decode) || isMask && !ColorSpace.isDefaultDecode(this.decode, 1))) {
  48838. this.needsDecode = true;
  48839. var max = (1 << bitsPerComponent) - 1;
  48840. this.decodeCoefficients = [];
  48841. this.decodeAddends = [];
  48842. for (var i = 0, j = 0; i < this.decode.length; i += 2, ++j) {
  48843. var dmin = this.decode[i];
  48844. var dmax = this.decode[i + 1];
  48845. this.decodeCoefficients[j] = dmax - dmin;
  48846. this.decodeAddends[j] = max * dmin;
  48847. }
  48848. }
  48849. if (smask) {
  48850. this.smask = new PDFImage(xref, res, smask, false);
  48851. } else if (mask) {
  48852. if (isStream(mask)) {
  48853. var maskDict = mask.dict, imageMask = maskDict.get('ImageMask', 'IM');
  48854. if (!imageMask) {
  48855. warn('Ignoring /Mask in image without /ImageMask.');
  48856. } else {
  48857. this.mask = new PDFImage(xref, res, mask, false, null, null, true);
  48858. }
  48859. } else {
  48860. this.mask = mask;
  48861. }
  48862. }
  48863. }
  48864. PDFImage.buildImage = function PDFImage_buildImage(handler, xref, res, image, inline, nativeDecoder) {
  48865. var imagePromise = handleImageData(image, nativeDecoder);
  48866. var smaskPromise;
  48867. var maskPromise;
  48868. var smask = image.dict.get('SMask');
  48869. var mask = image.dict.get('Mask');
  48870. if (smask) {
  48871. smaskPromise = handleImageData(smask, nativeDecoder);
  48872. maskPromise = Promise.resolve(null);
  48873. } else {
  48874. smaskPromise = Promise.resolve(null);
  48875. if (mask) {
  48876. if (isStream(mask)) {
  48877. maskPromise = handleImageData(mask, nativeDecoder);
  48878. } else if (isArray(mask)) {
  48879. maskPromise = Promise.resolve(mask);
  48880. } else {
  48881. warn('Unsupported mask format.');
  48882. maskPromise = Promise.resolve(null);
  48883. }
  48884. } else {
  48885. maskPromise = Promise.resolve(null);
  48886. }
  48887. }
  48888. return Promise.all([
  48889. imagePromise,
  48890. smaskPromise,
  48891. maskPromise
  48892. ]).then(function (results) {
  48893. var imageData = results[0];
  48894. var smaskData = results[1];
  48895. var maskData = results[2];
  48896. return new PDFImage(xref, res, imageData, inline, smaskData, maskData);
  48897. });
  48898. };
  48899. PDFImage.createMask = function PDFImage_createMask(imgArray, width, height, imageIsFromDecodeStream, inverseDecode) {
  48900. var computedLength = (width + 7 >> 3) * height;
  48901. var actualLength = imgArray.byteLength;
  48902. var haveFullData = computedLength === actualLength;
  48903. var data, i;
  48904. if (imageIsFromDecodeStream && (!inverseDecode || haveFullData)) {
  48905. data = imgArray;
  48906. } else if (!inverseDecode) {
  48907. data = new Uint8Array(actualLength);
  48908. data.set(imgArray);
  48909. } else {
  48910. data = new Uint8Array(computedLength);
  48911. data.set(imgArray);
  48912. for (i = actualLength; i < computedLength; i++) {
  48913. data[i] = 0xff;
  48914. }
  48915. }
  48916. if (inverseDecode) {
  48917. for (i = 0; i < actualLength; i++) {
  48918. data[i] = ~data[i];
  48919. }
  48920. }
  48921. return {
  48922. data: data,
  48923. width: width,
  48924. height: height
  48925. };
  48926. };
  48927. PDFImage.prototype = {
  48928. get drawWidth() {
  48929. return Math.max(this.width, this.smask && this.smask.width || 0, this.mask && this.mask.width || 0);
  48930. },
  48931. get drawHeight() {
  48932. return Math.max(this.height, this.smask && this.smask.height || 0, this.mask && this.mask.height || 0);
  48933. },
  48934. decodeBuffer: function PDFImage_decodeBuffer(buffer) {
  48935. var bpc = this.bpc;
  48936. var numComps = this.numComps;
  48937. var decodeAddends = this.decodeAddends;
  48938. var decodeCoefficients = this.decodeCoefficients;
  48939. var max = (1 << bpc) - 1;
  48940. var i, ii;
  48941. if (bpc === 1) {
  48942. for (i = 0, ii = buffer.length; i < ii; i++) {
  48943. buffer[i] = +!buffer[i];
  48944. }
  48945. return;
  48946. }
  48947. var index = 0;
  48948. for (i = 0, ii = this.width * this.height; i < ii; i++) {
  48949. for (var j = 0; j < numComps; j++) {
  48950. buffer[index] = decodeAndClamp(buffer[index], decodeAddends[j], decodeCoefficients[j], max);
  48951. index++;
  48952. }
  48953. }
  48954. },
  48955. getComponents: function PDFImage_getComponents(buffer) {
  48956. var bpc = this.bpc;
  48957. if (bpc === 8) {
  48958. return buffer;
  48959. }
  48960. var width = this.width;
  48961. var height = this.height;
  48962. var numComps = this.numComps;
  48963. var length = width * height * numComps;
  48964. var bufferPos = 0;
  48965. var output = bpc <= 8 ? new Uint8Array(length) : bpc <= 16 ? new Uint16Array(length) : new Uint32Array(length);
  48966. var rowComps = width * numComps;
  48967. var max = (1 << bpc) - 1;
  48968. var i = 0, ii, buf;
  48969. if (bpc === 1) {
  48970. var mask, loop1End, loop2End;
  48971. for (var j = 0; j < height; j++) {
  48972. loop1End = i + (rowComps & ~7);
  48973. loop2End = i + rowComps;
  48974. while (i < loop1End) {
  48975. buf = buffer[bufferPos++];
  48976. output[i] = buf >> 7 & 1;
  48977. output[i + 1] = buf >> 6 & 1;
  48978. output[i + 2] = buf >> 5 & 1;
  48979. output[i + 3] = buf >> 4 & 1;
  48980. output[i + 4] = buf >> 3 & 1;
  48981. output[i + 5] = buf >> 2 & 1;
  48982. output[i + 6] = buf >> 1 & 1;
  48983. output[i + 7] = buf & 1;
  48984. i += 8;
  48985. }
  48986. if (i < loop2End) {
  48987. buf = buffer[bufferPos++];
  48988. mask = 128;
  48989. while (i < loop2End) {
  48990. output[i++] = +!!(buf & mask);
  48991. mask >>= 1;
  48992. }
  48993. }
  48994. }
  48995. } else {
  48996. var bits = 0;
  48997. buf = 0;
  48998. for (i = 0, ii = length; i < ii; ++i) {
  48999. if (i % rowComps === 0) {
  49000. buf = 0;
  49001. bits = 0;
  49002. }
  49003. while (bits < bpc) {
  49004. buf = buf << 8 | buffer[bufferPos++];
  49005. bits += 8;
  49006. }
  49007. var remainingBits = bits - bpc;
  49008. var value = buf >> remainingBits;
  49009. output[i] = value < 0 ? 0 : value > max ? max : value;
  49010. buf = buf & (1 << remainingBits) - 1;
  49011. bits = remainingBits;
  49012. }
  49013. }
  49014. return output;
  49015. },
  49016. fillOpacity: function PDFImage_fillOpacity(rgbaBuf, width, height, actualHeight, image) {
  49017. var smask = this.smask;
  49018. var mask = this.mask;
  49019. var alphaBuf, sw, sh, i, ii, j;
  49020. if (smask) {
  49021. sw = smask.width;
  49022. sh = smask.height;
  49023. alphaBuf = new Uint8Array(sw * sh);
  49024. smask.fillGrayBuffer(alphaBuf);
  49025. if (sw !== width || sh !== height) {
  49026. alphaBuf = resizeImageMask(alphaBuf, smask.bpc, sw, sh, width, height);
  49027. }
  49028. } else if (mask) {
  49029. if (mask instanceof PDFImage) {
  49030. sw = mask.width;
  49031. sh = mask.height;
  49032. alphaBuf = new Uint8Array(sw * sh);
  49033. mask.numComps = 1;
  49034. mask.fillGrayBuffer(alphaBuf);
  49035. for (i = 0, ii = sw * sh; i < ii; ++i) {
  49036. alphaBuf[i] = 255 - alphaBuf[i];
  49037. }
  49038. if (sw !== width || sh !== height) {
  49039. alphaBuf = resizeImageMask(alphaBuf, mask.bpc, sw, sh, width, height);
  49040. }
  49041. } else if (isArray(mask)) {
  49042. alphaBuf = new Uint8Array(width * height);
  49043. var numComps = this.numComps;
  49044. for (i = 0, ii = width * height; i < ii; ++i) {
  49045. var opacity = 0;
  49046. var imageOffset = i * numComps;
  49047. for (j = 0; j < numComps; ++j) {
  49048. var color = image[imageOffset + j];
  49049. var maskOffset = j * 2;
  49050. if (color < mask[maskOffset] || color > mask[maskOffset + 1]) {
  49051. opacity = 255;
  49052. break;
  49053. }
  49054. }
  49055. alphaBuf[i] = opacity;
  49056. }
  49057. } else {
  49058. error('Unknown mask format.');
  49059. }
  49060. }
  49061. if (alphaBuf) {
  49062. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49063. rgbaBuf[j] = alphaBuf[i];
  49064. }
  49065. } else {
  49066. for (i = 0, j = 3, ii = width * actualHeight; i < ii; ++i, j += 4) {
  49067. rgbaBuf[j] = 255;
  49068. }
  49069. }
  49070. },
  49071. undoPreblend: function PDFImage_undoPreblend(buffer, width, height) {
  49072. var matte = this.smask && this.smask.matte;
  49073. if (!matte) {
  49074. return;
  49075. }
  49076. var matteRgb = this.colorSpace.getRgb(matte, 0);
  49077. var matteR = matteRgb[0];
  49078. var matteG = matteRgb[1];
  49079. var matteB = matteRgb[2];
  49080. var length = width * height * 4;
  49081. var r, g, b;
  49082. for (var i = 0; i < length; i += 4) {
  49083. var alpha = buffer[i + 3];
  49084. if (alpha === 0) {
  49085. buffer[i] = 255;
  49086. buffer[i + 1] = 255;
  49087. buffer[i + 2] = 255;
  49088. continue;
  49089. }
  49090. var k = 255 / alpha;
  49091. r = (buffer[i] - matteR) * k + matteR;
  49092. g = (buffer[i + 1] - matteG) * k + matteG;
  49093. b = (buffer[i + 2] - matteB) * k + matteB;
  49094. buffer[i] = r <= 0 ? 0 : r >= 255 ? 255 : r | 0;
  49095. buffer[i + 1] = g <= 0 ? 0 : g >= 255 ? 255 : g | 0;
  49096. buffer[i + 2] = b <= 0 ? 0 : b >= 255 ? 255 : b | 0;
  49097. }
  49098. },
  49099. createImageData: function PDFImage_createImageData(forceRGBA) {
  49100. var drawWidth = this.drawWidth;
  49101. var drawHeight = this.drawHeight;
  49102. var imgData = {
  49103. width: drawWidth,
  49104. height: drawHeight
  49105. };
  49106. var numComps = this.numComps;
  49107. var originalWidth = this.width;
  49108. var originalHeight = this.height;
  49109. var bpc = this.bpc;
  49110. var rowBytes = originalWidth * numComps * bpc + 7 >> 3;
  49111. var imgArray;
  49112. if (!forceRGBA) {
  49113. var kind;
  49114. if (this.colorSpace.name === 'DeviceGray' && bpc === 1) {
  49115. kind = ImageKind.GRAYSCALE_1BPP;
  49116. } else if (this.colorSpace.name === 'DeviceRGB' && bpc === 8 && !this.needsDecode) {
  49117. kind = ImageKind.RGB_24BPP;
  49118. }
  49119. if (kind && !this.smask && !this.mask && drawWidth === originalWidth && drawHeight === originalHeight) {
  49120. imgData.kind = kind;
  49121. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49122. if (this.image instanceof DecodeStream) {
  49123. imgData.data = imgArray;
  49124. } else {
  49125. var newArray = new Uint8Array(imgArray.length);
  49126. newArray.set(imgArray);
  49127. imgData.data = newArray;
  49128. }
  49129. if (this.needsDecode) {
  49130. assert(kind === ImageKind.GRAYSCALE_1BPP);
  49131. var buffer = imgData.data;
  49132. for (var i = 0, ii = buffer.length; i < ii; i++) {
  49133. buffer[i] ^= 0xff;
  49134. }
  49135. }
  49136. return imgData;
  49137. }
  49138. if (this.image instanceof JpegStream && !this.smask && !this.mask && (this.colorSpace.name === 'DeviceGray' || this.colorSpace.name === 'DeviceRGB' || this.colorSpace.name === 'DeviceCMYK')) {
  49139. imgData.kind = ImageKind.RGB_24BPP;
  49140. imgData.data = this.getImageBytes(originalHeight * rowBytes, drawWidth, drawHeight, true);
  49141. return imgData;
  49142. }
  49143. }
  49144. imgArray = this.getImageBytes(originalHeight * rowBytes);
  49145. var actualHeight = 0 | imgArray.length / rowBytes * drawHeight / originalHeight;
  49146. var comps = this.getComponents(imgArray);
  49147. var alpha01, maybeUndoPreblend;
  49148. if (!forceRGBA && !this.smask && !this.mask) {
  49149. imgData.kind = ImageKind.RGB_24BPP;
  49150. imgData.data = new Uint8Array(drawWidth * drawHeight * 3);
  49151. alpha01 = 0;
  49152. maybeUndoPreblend = false;
  49153. } else {
  49154. imgData.kind = ImageKind.RGBA_32BPP;
  49155. imgData.data = new Uint8Array(drawWidth * drawHeight * 4);
  49156. alpha01 = 1;
  49157. maybeUndoPreblend = true;
  49158. this.fillOpacity(imgData.data, drawWidth, drawHeight, actualHeight, comps);
  49159. }
  49160. if (this.needsDecode) {
  49161. this.decodeBuffer(comps);
  49162. }
  49163. this.colorSpace.fillRgb(imgData.data, originalWidth, originalHeight, drawWidth, drawHeight, actualHeight, bpc, comps, alpha01);
  49164. if (maybeUndoPreblend) {
  49165. this.undoPreblend(imgData.data, drawWidth, actualHeight);
  49166. }
  49167. return imgData;
  49168. },
  49169. fillGrayBuffer: function PDFImage_fillGrayBuffer(buffer) {
  49170. var numComps = this.numComps;
  49171. if (numComps !== 1) {
  49172. error('Reading gray scale from a color image: ' + numComps);
  49173. }
  49174. var width = this.width;
  49175. var height = this.height;
  49176. var bpc = this.bpc;
  49177. var rowBytes = width * numComps * bpc + 7 >> 3;
  49178. var imgArray = this.getImageBytes(height * rowBytes);
  49179. var comps = this.getComponents(imgArray);
  49180. var i, length;
  49181. if (bpc === 1) {
  49182. length = width * height;
  49183. if (this.needsDecode) {
  49184. for (i = 0; i < length; ++i) {
  49185. buffer[i] = comps[i] - 1 & 255;
  49186. }
  49187. } else {
  49188. for (i = 0; i < length; ++i) {
  49189. buffer[i] = -comps[i] & 255;
  49190. }
  49191. }
  49192. return;
  49193. }
  49194. if (this.needsDecode) {
  49195. this.decodeBuffer(comps);
  49196. }
  49197. length = width * height;
  49198. var scale = 255 / ((1 << bpc) - 1);
  49199. for (i = 0; i < length; ++i) {
  49200. buffer[i] = scale * comps[i] | 0;
  49201. }
  49202. },
  49203. getImageBytes: function PDFImage_getImageBytes(length, drawWidth, drawHeight, forceRGB) {
  49204. this.image.reset();
  49205. this.image.drawWidth = drawWidth || this.width;
  49206. this.image.drawHeight = drawHeight || this.height;
  49207. this.image.forceRGB = !!forceRGB;
  49208. return this.image.getBytes(length);
  49209. }
  49210. };
  49211. return PDFImage;
  49212. }();
  49213. exports.PDFImage = PDFImage;
  49214. }));
  49215. (function (root, factory) {
  49216. factory(root.pdfjsCoreObj = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreCrypto, root.pdfjsCoreParser, root.pdfjsCoreChunkedStream, root.pdfjsCoreColorSpace);
  49217. }(this, function (exports, sharedUtil, corePrimitives, coreCrypto, coreParser, coreChunkedStream, coreColorSpace) {
  49218. var InvalidPDFException = sharedUtil.InvalidPDFException;
  49219. var MissingDataException = sharedUtil.MissingDataException;
  49220. var XRefParseException = sharedUtil.XRefParseException;
  49221. var assert = sharedUtil.assert;
  49222. var bytesToString = sharedUtil.bytesToString;
  49223. var createPromiseCapability = sharedUtil.createPromiseCapability;
  49224. var error = sharedUtil.error;
  49225. var info = sharedUtil.info;
  49226. var isArray = sharedUtil.isArray;
  49227. var isBool = sharedUtil.isBool;
  49228. var isInt = sharedUtil.isInt;
  49229. var isString = sharedUtil.isString;
  49230. var shadow = sharedUtil.shadow;
  49231. var stringToPDFString = sharedUtil.stringToPDFString;
  49232. var stringToUTF8String = sharedUtil.stringToUTF8String;
  49233. var warn = sharedUtil.warn;
  49234. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  49235. var Util = sharedUtil.Util;
  49236. var Ref = corePrimitives.Ref;
  49237. var RefSet = corePrimitives.RefSet;
  49238. var RefSetCache = corePrimitives.RefSetCache;
  49239. var isName = corePrimitives.isName;
  49240. var isCmd = corePrimitives.isCmd;
  49241. var isDict = corePrimitives.isDict;
  49242. var isRef = corePrimitives.isRef;
  49243. var isRefsEqual = corePrimitives.isRefsEqual;
  49244. var isStream = corePrimitives.isStream;
  49245. var CipherTransformFactory = coreCrypto.CipherTransformFactory;
  49246. var Lexer = coreParser.Lexer;
  49247. var Parser = coreParser.Parser;
  49248. var ChunkedStream = coreChunkedStream.ChunkedStream;
  49249. var ColorSpace = coreColorSpace.ColorSpace;
  49250. var Catalog = function CatalogClosure() {
  49251. function Catalog(pdfManager, xref, pageFactory) {
  49252. this.pdfManager = pdfManager;
  49253. this.xref = xref;
  49254. this.catDict = xref.getCatalogObj();
  49255. this.fontCache = new RefSetCache();
  49256. assert(isDict(this.catDict), 'catalog object is not a dictionary');
  49257. this.pageFactory = pageFactory;
  49258. this.pagePromises = [];
  49259. }
  49260. Catalog.prototype = {
  49261. get metadata() {
  49262. var streamRef = this.catDict.getRaw('Metadata');
  49263. if (!isRef(streamRef)) {
  49264. return shadow(this, 'metadata', null);
  49265. }
  49266. var encryptMetadata = !this.xref.encrypt ? false : this.xref.encrypt.encryptMetadata;
  49267. var stream = this.xref.fetch(streamRef, !encryptMetadata);
  49268. var metadata;
  49269. if (stream && isDict(stream.dict)) {
  49270. var type = stream.dict.get('Type');
  49271. var subtype = stream.dict.get('Subtype');
  49272. if (isName(type, 'Metadata') && isName(subtype, 'XML')) {
  49273. try {
  49274. metadata = stringToUTF8String(bytesToString(stream.getBytes()));
  49275. } catch (e) {
  49276. info('Skipping invalid metadata.');
  49277. }
  49278. }
  49279. }
  49280. return shadow(this, 'metadata', metadata);
  49281. },
  49282. get toplevelPagesDict() {
  49283. var pagesObj = this.catDict.get('Pages');
  49284. assert(isDict(pagesObj), 'invalid top-level pages dictionary');
  49285. return shadow(this, 'toplevelPagesDict', pagesObj);
  49286. },
  49287. get documentOutline() {
  49288. var obj = null;
  49289. try {
  49290. obj = this.readDocumentOutline();
  49291. } catch (ex) {
  49292. if (ex instanceof MissingDataException) {
  49293. throw ex;
  49294. }
  49295. warn('Unable to read document outline');
  49296. }
  49297. return shadow(this, 'documentOutline', obj);
  49298. },
  49299. readDocumentOutline: function Catalog_readDocumentOutline() {
  49300. var obj = this.catDict.get('Outlines');
  49301. if (!isDict(obj)) {
  49302. return null;
  49303. }
  49304. obj = obj.getRaw('First');
  49305. if (!isRef(obj)) {
  49306. return null;
  49307. }
  49308. var root = { items: [] };
  49309. var queue = [{
  49310. obj: obj,
  49311. parent: root
  49312. }];
  49313. var processed = new RefSet();
  49314. processed.put(obj);
  49315. var xref = this.xref, blackColor = new Uint8Array(3);
  49316. while (queue.length > 0) {
  49317. var i = queue.shift();
  49318. var outlineDict = xref.fetchIfRef(i.obj);
  49319. if (outlineDict === null) {
  49320. continue;
  49321. }
  49322. assert(outlineDict.has('Title'), 'Invalid outline item');
  49323. var data = {
  49324. url: null,
  49325. dest: null
  49326. };
  49327. Catalog.parseDestDictionary({
  49328. destDict: outlineDict,
  49329. resultObj: data,
  49330. docBaseUrl: this.pdfManager.docBaseUrl
  49331. });
  49332. var title = outlineDict.get('Title');
  49333. var flags = outlineDict.get('F') || 0;
  49334. var color = outlineDict.getArray('C'), rgbColor = blackColor;
  49335. if (isArray(color) && color.length === 3 && (color[0] !== 0 || color[1] !== 0 || color[2] !== 0)) {
  49336. rgbColor = ColorSpace.singletons.rgb.getRgb(color, 0);
  49337. }
  49338. var outlineItem = {
  49339. dest: data.dest,
  49340. url: data.url,
  49341. unsafeUrl: data.unsafeUrl,
  49342. newWindow: data.newWindow,
  49343. title: stringToPDFString(title),
  49344. color: rgbColor,
  49345. count: outlineDict.get('Count'),
  49346. bold: !!(flags & 2),
  49347. italic: !!(flags & 1),
  49348. items: []
  49349. };
  49350. i.parent.items.push(outlineItem);
  49351. obj = outlineDict.getRaw('First');
  49352. if (isRef(obj) && !processed.has(obj)) {
  49353. queue.push({
  49354. obj: obj,
  49355. parent: outlineItem
  49356. });
  49357. processed.put(obj);
  49358. }
  49359. obj = outlineDict.getRaw('Next');
  49360. if (isRef(obj) && !processed.has(obj)) {
  49361. queue.push({
  49362. obj: obj,
  49363. parent: i.parent
  49364. });
  49365. processed.put(obj);
  49366. }
  49367. }
  49368. return root.items.length > 0 ? root.items : null;
  49369. },
  49370. get numPages() {
  49371. var obj = this.toplevelPagesDict.get('Count');
  49372. assert(isInt(obj), 'page count in top level pages object is not an integer');
  49373. return shadow(this, 'num', obj);
  49374. },
  49375. get destinations() {
  49376. function fetchDestination(dest) {
  49377. return isDict(dest) ? dest.get('D') : dest;
  49378. }
  49379. var xref = this.xref;
  49380. var dests = {}, nameTreeRef, nameDictionaryRef;
  49381. var obj = this.catDict.get('Names');
  49382. if (obj && obj.has('Dests')) {
  49383. nameTreeRef = obj.getRaw('Dests');
  49384. } else if (this.catDict.has('Dests')) {
  49385. nameDictionaryRef = this.catDict.get('Dests');
  49386. }
  49387. if (nameDictionaryRef) {
  49388. obj = nameDictionaryRef;
  49389. obj.forEach(function catalogForEach(key, value) {
  49390. if (!value) {
  49391. return;
  49392. }
  49393. dests[key] = fetchDestination(value);
  49394. });
  49395. }
  49396. if (nameTreeRef) {
  49397. var nameTree = new NameTree(nameTreeRef, xref);
  49398. var names = nameTree.getAll();
  49399. for (var name in names) {
  49400. dests[name] = fetchDestination(names[name]);
  49401. }
  49402. }
  49403. return shadow(this, 'destinations', dests);
  49404. },
  49405. getDestination: function Catalog_getDestination(destinationId) {
  49406. function fetchDestination(dest) {
  49407. return isDict(dest) ? dest.get('D') : dest;
  49408. }
  49409. var xref = this.xref;
  49410. var dest = null, nameTreeRef, nameDictionaryRef;
  49411. var obj = this.catDict.get('Names');
  49412. if (obj && obj.has('Dests')) {
  49413. nameTreeRef = obj.getRaw('Dests');
  49414. } else if (this.catDict.has('Dests')) {
  49415. nameDictionaryRef = this.catDict.get('Dests');
  49416. }
  49417. if (nameDictionaryRef) {
  49418. var value = nameDictionaryRef.get(destinationId);
  49419. if (value) {
  49420. dest = fetchDestination(value);
  49421. }
  49422. }
  49423. if (nameTreeRef) {
  49424. var nameTree = new NameTree(nameTreeRef, xref);
  49425. dest = fetchDestination(nameTree.get(destinationId));
  49426. }
  49427. return dest;
  49428. },
  49429. get pageLabels() {
  49430. var obj = null;
  49431. try {
  49432. obj = this.readPageLabels();
  49433. } catch (ex) {
  49434. if (ex instanceof MissingDataException) {
  49435. throw ex;
  49436. }
  49437. warn('Unable to read page labels.');
  49438. }
  49439. return shadow(this, 'pageLabels', obj);
  49440. },
  49441. readPageLabels: function Catalog_readPageLabels() {
  49442. var obj = this.catDict.getRaw('PageLabels');
  49443. if (!obj) {
  49444. return null;
  49445. }
  49446. var pageLabels = new Array(this.numPages);
  49447. var style = null;
  49448. var prefix = '';
  49449. var numberTree = new NumberTree(obj, this.xref);
  49450. var nums = numberTree.getAll();
  49451. var currentLabel = '', currentIndex = 1;
  49452. for (var i = 0, ii = this.numPages; i < ii; i++) {
  49453. if (i in nums) {
  49454. var labelDict = nums[i];
  49455. assert(isDict(labelDict), 'The PageLabel is not a dictionary.');
  49456. var type = labelDict.get('Type');
  49457. assert(!type || isName(type, 'PageLabel'), 'Invalid type in PageLabel dictionary.');
  49458. var s = labelDict.get('S');
  49459. assert(!s || isName(s), 'Invalid style in PageLabel dictionary.');
  49460. style = s ? s.name : null;
  49461. var p = labelDict.get('P');
  49462. assert(!p || isString(p), 'Invalid prefix in PageLabel dictionary.');
  49463. prefix = p ? stringToPDFString(p) : '';
  49464. var st = labelDict.get('St');
  49465. assert(!st || isInt(st) && st >= 1, 'Invalid start in PageLabel dictionary.');
  49466. currentIndex = st || 1;
  49467. }
  49468. switch (style) {
  49469. case 'D':
  49470. currentLabel = currentIndex;
  49471. break;
  49472. case 'R':
  49473. case 'r':
  49474. currentLabel = Util.toRoman(currentIndex, style === 'r');
  49475. break;
  49476. case 'A':
  49477. case 'a':
  49478. var LIMIT = 26;
  49479. var A_UPPER_CASE = 0x41, A_LOWER_CASE = 0x61;
  49480. var baseCharCode = style === 'a' ? A_LOWER_CASE : A_UPPER_CASE;
  49481. var letterIndex = currentIndex - 1;
  49482. var character = String.fromCharCode(baseCharCode + letterIndex % LIMIT);
  49483. var charBuf = [];
  49484. for (var j = 0, jj = letterIndex / LIMIT | 0; j <= jj; j++) {
  49485. charBuf.push(character);
  49486. }
  49487. currentLabel = charBuf.join('');
  49488. break;
  49489. default:
  49490. assert(!style, 'Invalid style "' + style + '" in PageLabel dictionary.');
  49491. }
  49492. pageLabels[i] = prefix + currentLabel;
  49493. currentLabel = '';
  49494. currentIndex++;
  49495. }
  49496. return pageLabels;
  49497. },
  49498. get attachments() {
  49499. var xref = this.xref;
  49500. var attachments = null, nameTreeRef;
  49501. var obj = this.catDict.get('Names');
  49502. if (obj) {
  49503. nameTreeRef = obj.getRaw('EmbeddedFiles');
  49504. }
  49505. if (nameTreeRef) {
  49506. var nameTree = new NameTree(nameTreeRef, xref);
  49507. var names = nameTree.getAll();
  49508. for (var name in names) {
  49509. var fs = new FileSpec(names[name], xref);
  49510. if (!attachments) {
  49511. attachments = Object.create(null);
  49512. }
  49513. attachments[stringToPDFString(name)] = fs.serializable;
  49514. }
  49515. }
  49516. return shadow(this, 'attachments', attachments);
  49517. },
  49518. get javaScript() {
  49519. var xref = this.xref;
  49520. var obj = this.catDict.get('Names');
  49521. var javaScript = [];
  49522. function appendIfJavaScriptDict(jsDict) {
  49523. var type = jsDict.get('S');
  49524. if (!isName(type, 'JavaScript')) {
  49525. return;
  49526. }
  49527. var js = jsDict.get('JS');
  49528. if (isStream(js)) {
  49529. js = bytesToString(js.getBytes());
  49530. } else if (!isString(js)) {
  49531. return;
  49532. }
  49533. javaScript.push(stringToPDFString(js));
  49534. }
  49535. if (obj && obj.has('JavaScript')) {
  49536. var nameTree = new NameTree(obj.getRaw('JavaScript'), xref);
  49537. var names = nameTree.getAll();
  49538. for (var name in names) {
  49539. var jsDict = names[name];
  49540. if (isDict(jsDict)) {
  49541. appendIfJavaScriptDict(jsDict);
  49542. }
  49543. }
  49544. }
  49545. var openactionDict = this.catDict.get('OpenAction');
  49546. if (isDict(openactionDict, 'Action')) {
  49547. var actionType = openactionDict.get('S');
  49548. if (isName(actionType, 'Named')) {
  49549. var action = openactionDict.get('N');
  49550. if (isName(action, 'Print')) {
  49551. javaScript.push('print({});');
  49552. }
  49553. } else {
  49554. appendIfJavaScriptDict(openactionDict);
  49555. }
  49556. }
  49557. return shadow(this, 'javaScript', javaScript);
  49558. },
  49559. cleanup: function Catalog_cleanup() {
  49560. var promises = [];
  49561. this.fontCache.forEach(function (promise) {
  49562. promises.push(promise);
  49563. });
  49564. return Promise.all(promises).then(function (translatedFonts) {
  49565. for (var i = 0, ii = translatedFonts.length; i < ii; i++) {
  49566. var font = translatedFonts[i].dict;
  49567. delete font.translated;
  49568. }
  49569. this.fontCache.clear();
  49570. }.bind(this));
  49571. },
  49572. getPage: function Catalog_getPage(pageIndex) {
  49573. if (!(pageIndex in this.pagePromises)) {
  49574. this.pagePromises[pageIndex] = this.getPageDict(pageIndex).then(function (a) {
  49575. var dict = a[0];
  49576. var ref = a[1];
  49577. return this.pageFactory.createPage(pageIndex, dict, ref, this.fontCache);
  49578. }.bind(this));
  49579. }
  49580. return this.pagePromises[pageIndex];
  49581. },
  49582. getPageDict: function Catalog_getPageDict(pageIndex) {
  49583. var capability = createPromiseCapability();
  49584. var nodesToVisit = [this.catDict.getRaw('Pages')];
  49585. var currentPageIndex = 0;
  49586. var xref = this.xref;
  49587. var checkAllKids = false;
  49588. function next() {
  49589. while (nodesToVisit.length) {
  49590. var currentNode = nodesToVisit.pop();
  49591. if (isRef(currentNode)) {
  49592. xref.fetchAsync(currentNode).then(function (obj) {
  49593. if (isDict(obj, 'Page') || isDict(obj) && !obj.has('Kids')) {
  49594. if (pageIndex === currentPageIndex) {
  49595. capability.resolve([
  49596. obj,
  49597. currentNode
  49598. ]);
  49599. } else {
  49600. currentPageIndex++;
  49601. next();
  49602. }
  49603. return;
  49604. }
  49605. nodesToVisit.push(obj);
  49606. next();
  49607. }, capability.reject);
  49608. return;
  49609. }
  49610. assert(isDict(currentNode), 'page dictionary kid reference points to wrong type of object');
  49611. var count = currentNode.get('Count');
  49612. if (count === 0) {
  49613. checkAllKids = true;
  49614. }
  49615. if (currentPageIndex + count <= pageIndex) {
  49616. currentPageIndex += count;
  49617. continue;
  49618. }
  49619. var kids = currentNode.get('Kids');
  49620. assert(isArray(kids), 'page dictionary kids object is not an array');
  49621. if (!checkAllKids && count === kids.length) {
  49622. nodesToVisit = [kids[pageIndex - currentPageIndex]];
  49623. currentPageIndex = pageIndex;
  49624. continue;
  49625. } else {
  49626. for (var last = kids.length - 1; last >= 0; last--) {
  49627. nodesToVisit.push(kids[last]);
  49628. }
  49629. }
  49630. }
  49631. capability.reject('Page index ' + pageIndex + ' not found.');
  49632. }
  49633. next();
  49634. return capability.promise;
  49635. },
  49636. getPageIndex: function Catalog_getPageIndex(pageRef) {
  49637. var xref = this.xref;
  49638. function pagesBeforeRef(kidRef) {
  49639. var total = 0;
  49640. var parentRef;
  49641. return xref.fetchAsync(kidRef).then(function (node) {
  49642. if (isRefsEqual(kidRef, pageRef) && !isDict(node, 'Page') && !(isDict(node) && !node.has('Type') && node.has('Contents'))) {
  49643. throw new Error('The reference does not point to a /Page Dict.');
  49644. }
  49645. if (!node) {
  49646. return null;
  49647. }
  49648. assert(isDict(node), 'node must be a Dict.');
  49649. parentRef = node.getRaw('Parent');
  49650. return node.getAsync('Parent');
  49651. }).then(function (parent) {
  49652. if (!parent) {
  49653. return null;
  49654. }
  49655. assert(isDict(parent), 'parent must be a Dict.');
  49656. return parent.getAsync('Kids');
  49657. }).then(function (kids) {
  49658. if (!kids) {
  49659. return null;
  49660. }
  49661. var kidPromises = [];
  49662. var found = false;
  49663. for (var i = 0; i < kids.length; i++) {
  49664. var kid = kids[i];
  49665. assert(isRef(kid), 'kid must be a Ref.');
  49666. if (kid.num === kidRef.num) {
  49667. found = true;
  49668. break;
  49669. }
  49670. kidPromises.push(xref.fetchAsync(kid).then(function (kid) {
  49671. if (kid.has('Count')) {
  49672. var count = kid.get('Count');
  49673. total += count;
  49674. } else {
  49675. total++;
  49676. }
  49677. }));
  49678. }
  49679. if (!found) {
  49680. error('kid ref not found in parents kids');
  49681. }
  49682. return Promise.all(kidPromises).then(function () {
  49683. return [
  49684. total,
  49685. parentRef
  49686. ];
  49687. });
  49688. });
  49689. }
  49690. var total = 0;
  49691. function next(ref) {
  49692. return pagesBeforeRef(ref).then(function (args) {
  49693. if (!args) {
  49694. return total;
  49695. }
  49696. var count = args[0];
  49697. var parentRef = args[1];
  49698. total += count;
  49699. return next(parentRef);
  49700. });
  49701. }
  49702. return next(pageRef);
  49703. }
  49704. };
  49705. Catalog.parseDestDictionary = function Catalog_parseDestDictionary(params) {
  49706. function addDefaultProtocolToUrl(url) {
  49707. if (url.indexOf('www.') === 0) {
  49708. return 'http://' + url;
  49709. }
  49710. return url;
  49711. }
  49712. function tryConvertUrlEncoding(url) {
  49713. try {
  49714. return stringToUTF8String(url);
  49715. } catch (e) {
  49716. return url;
  49717. }
  49718. }
  49719. var destDict = params.destDict;
  49720. if (!isDict(destDict)) {
  49721. warn('Catalog_parseDestDictionary: "destDict" must be a dictionary.');
  49722. return;
  49723. }
  49724. var resultObj = params.resultObj;
  49725. if (typeof resultObj !== 'object') {
  49726. warn('Catalog_parseDestDictionary: "resultObj" must be an object.');
  49727. return;
  49728. }
  49729. var docBaseUrl = params.docBaseUrl || null;
  49730. var action = destDict.get('A'), url, dest;
  49731. if (isDict(action)) {
  49732. var linkType = action.get('S').name;
  49733. switch (linkType) {
  49734. case 'URI':
  49735. url = action.get('URI');
  49736. if (isName(url)) {
  49737. url = '/' + url.name;
  49738. } else if (isString(url)) {
  49739. url = addDefaultProtocolToUrl(url);
  49740. }
  49741. break;
  49742. case 'GoTo':
  49743. dest = action.get('D');
  49744. break;
  49745. case 'Launch':
  49746. case 'GoToR':
  49747. var urlDict = action.get('F');
  49748. if (isDict(urlDict)) {
  49749. url = urlDict.get('F') || null;
  49750. } else if (isString(urlDict)) {
  49751. url = urlDict;
  49752. }
  49753. var remoteDest = action.get('D');
  49754. if (remoteDest) {
  49755. if (isName(remoteDest)) {
  49756. remoteDest = remoteDest.name;
  49757. }
  49758. if (isString(url)) {
  49759. var baseUrl = url.split('#')[0];
  49760. if (isString(remoteDest)) {
  49761. url = baseUrl + '#' + (/^\d+$/.test(remoteDest) ? 'nameddest=' : '') + remoteDest;
  49762. } else if (isArray(remoteDest)) {
  49763. url = baseUrl + '#' + JSON.stringify(remoteDest);
  49764. }
  49765. }
  49766. }
  49767. var newWindow = action.get('NewWindow');
  49768. if (isBool(newWindow)) {
  49769. resultObj.newWindow = newWindow;
  49770. }
  49771. break;
  49772. case 'Named':
  49773. var namedAction = action.get('N');
  49774. if (isName(namedAction)) {
  49775. resultObj.action = namedAction.name;
  49776. }
  49777. break;
  49778. case 'JavaScript':
  49779. var jsAction = action.get('JS'), js;
  49780. if (isStream(jsAction)) {
  49781. js = bytesToString(jsAction.getBytes());
  49782. } else if (isString(jsAction)) {
  49783. js = jsAction;
  49784. }
  49785. if (js) {
  49786. var URL_OPEN_METHODS = [
  49787. 'app.launchURL',
  49788. 'window.open'
  49789. ];
  49790. var regex = new RegExp('^(?:' + URL_OPEN_METHODS.join('|') + ')' + '\\((?:\'|\")(\\S+)(?:\'|\")(?:,|\\))');
  49791. var jsUrl = regex.exec(stringToPDFString(js), 'i');
  49792. if (jsUrl && jsUrl[1]) {
  49793. url = jsUrl[1];
  49794. break;
  49795. }
  49796. }
  49797. default:
  49798. warn('Catalog_parseDestDictionary: Unrecognized link type "' + linkType + '".');
  49799. break;
  49800. }
  49801. } else if (destDict.has('Dest')) {
  49802. dest = destDict.get('Dest');
  49803. }
  49804. if (isString(url)) {
  49805. url = tryConvertUrlEncoding(url);
  49806. var absoluteUrl = createValidAbsoluteUrl(url, docBaseUrl);
  49807. if (absoluteUrl) {
  49808. resultObj.url = absoluteUrl.href;
  49809. }
  49810. resultObj.unsafeUrl = url;
  49811. }
  49812. if (dest) {
  49813. if (isName(dest)) {
  49814. dest = dest.name;
  49815. }
  49816. if (isString(dest) || isArray(dest)) {
  49817. resultObj.dest = dest;
  49818. }
  49819. }
  49820. };
  49821. return Catalog;
  49822. }();
  49823. var XRef = function XRefClosure() {
  49824. function XRef(stream, password) {
  49825. this.stream = stream;
  49826. this.entries = [];
  49827. this.xrefstms = Object.create(null);
  49828. this.cache = [];
  49829. this.password = password;
  49830. this.stats = {
  49831. streamTypes: [],
  49832. fontTypes: []
  49833. };
  49834. }
  49835. XRef.prototype = {
  49836. setStartXRef: function XRef_setStartXRef(startXRef) {
  49837. this.startXRefQueue = [startXRef];
  49838. },
  49839. parse: function XRef_parse(recoveryMode) {
  49840. var trailerDict;
  49841. if (!recoveryMode) {
  49842. trailerDict = this.readXRef();
  49843. } else {
  49844. warn('Indexing all PDF objects');
  49845. trailerDict = this.indexObjects();
  49846. }
  49847. trailerDict.assignXref(this);
  49848. this.trailer = trailerDict;
  49849. var encrypt = trailerDict.get('Encrypt');
  49850. if (encrypt) {
  49851. var ids = trailerDict.get('ID');
  49852. var fileId = ids && ids.length ? ids[0] : '';
  49853. encrypt.suppressEncryption = true;
  49854. this.encrypt = new CipherTransformFactory(encrypt, fileId, this.password);
  49855. }
  49856. if (!(this.root = trailerDict.get('Root'))) {
  49857. error('Invalid root reference');
  49858. }
  49859. },
  49860. processXRefTable: function XRef_processXRefTable(parser) {
  49861. if (!('tableState' in this)) {
  49862. this.tableState = {
  49863. entryNum: 0,
  49864. streamPos: parser.lexer.stream.pos,
  49865. parserBuf1: parser.buf1,
  49866. parserBuf2: parser.buf2
  49867. };
  49868. }
  49869. var obj = this.readXRefTable(parser);
  49870. if (!isCmd(obj, 'trailer')) {
  49871. error('Invalid XRef table: could not find trailer dictionary');
  49872. }
  49873. var dict = parser.getObj();
  49874. if (!isDict(dict) && dict.dict) {
  49875. dict = dict.dict;
  49876. }
  49877. if (!isDict(dict)) {
  49878. error('Invalid XRef table: could not parse trailer dictionary');
  49879. }
  49880. delete this.tableState;
  49881. return dict;
  49882. },
  49883. readXRefTable: function XRef_readXRefTable(parser) {
  49884. var stream = parser.lexer.stream;
  49885. var tableState = this.tableState;
  49886. stream.pos = tableState.streamPos;
  49887. parser.buf1 = tableState.parserBuf1;
  49888. parser.buf2 = tableState.parserBuf2;
  49889. var obj;
  49890. while (true) {
  49891. if (!('firstEntryNum' in tableState) || !('entryCount' in tableState)) {
  49892. if (isCmd(obj = parser.getObj(), 'trailer')) {
  49893. break;
  49894. }
  49895. tableState.firstEntryNum = obj;
  49896. tableState.entryCount = parser.getObj();
  49897. }
  49898. var first = tableState.firstEntryNum;
  49899. var count = tableState.entryCount;
  49900. if (!isInt(first) || !isInt(count)) {
  49901. error('Invalid XRef table: wrong types in subsection header');
  49902. }
  49903. for (var i = tableState.entryNum; i < count; i++) {
  49904. tableState.streamPos = stream.pos;
  49905. tableState.entryNum = i;
  49906. tableState.parserBuf1 = parser.buf1;
  49907. tableState.parserBuf2 = parser.buf2;
  49908. var entry = {};
  49909. entry.offset = parser.getObj();
  49910. entry.gen = parser.getObj();
  49911. var type = parser.getObj();
  49912. if (isCmd(type, 'f')) {
  49913. entry.free = true;
  49914. } else if (isCmd(type, 'n')) {
  49915. entry.uncompressed = true;
  49916. }
  49917. if (!isInt(entry.offset) || !isInt(entry.gen) || !(entry.free || entry.uncompressed)) {
  49918. error('Invalid entry in XRef subsection: ' + first + ', ' + count);
  49919. }
  49920. if (i === 0 && entry.free && first === 1) {
  49921. first = 0;
  49922. }
  49923. if (!this.entries[i + first]) {
  49924. this.entries[i + first] = entry;
  49925. }
  49926. }
  49927. tableState.entryNum = 0;
  49928. tableState.streamPos = stream.pos;
  49929. tableState.parserBuf1 = parser.buf1;
  49930. tableState.parserBuf2 = parser.buf2;
  49931. delete tableState.firstEntryNum;
  49932. delete tableState.entryCount;
  49933. }
  49934. if (this.entries[0] && !this.entries[0].free) {
  49935. error('Invalid XRef table: unexpected first object');
  49936. }
  49937. return obj;
  49938. },
  49939. processXRefStream: function XRef_processXRefStream(stream) {
  49940. if (!('streamState' in this)) {
  49941. var streamParameters = stream.dict;
  49942. var byteWidths = streamParameters.get('W');
  49943. var range = streamParameters.get('Index');
  49944. if (!range) {
  49945. range = [
  49946. 0,
  49947. streamParameters.get('Size')
  49948. ];
  49949. }
  49950. this.streamState = {
  49951. entryRanges: range,
  49952. byteWidths: byteWidths,
  49953. entryNum: 0,
  49954. streamPos: stream.pos
  49955. };
  49956. }
  49957. this.readXRefStream(stream);
  49958. delete this.streamState;
  49959. return stream.dict;
  49960. },
  49961. readXRefStream: function XRef_readXRefStream(stream) {
  49962. var i, j;
  49963. var streamState = this.streamState;
  49964. stream.pos = streamState.streamPos;
  49965. var byteWidths = streamState.byteWidths;
  49966. var typeFieldWidth = byteWidths[0];
  49967. var offsetFieldWidth = byteWidths[1];
  49968. var generationFieldWidth = byteWidths[2];
  49969. var entryRanges = streamState.entryRanges;
  49970. while (entryRanges.length > 0) {
  49971. var first = entryRanges[0];
  49972. var n = entryRanges[1];
  49973. if (!isInt(first) || !isInt(n)) {
  49974. error('Invalid XRef range fields: ' + first + ', ' + n);
  49975. }
  49976. if (!isInt(typeFieldWidth) || !isInt(offsetFieldWidth) || !isInt(generationFieldWidth)) {
  49977. error('Invalid XRef entry fields length: ' + first + ', ' + n);
  49978. }
  49979. for (i = streamState.entryNum; i < n; ++i) {
  49980. streamState.entryNum = i;
  49981. streamState.streamPos = stream.pos;
  49982. var type = 0, offset = 0, generation = 0;
  49983. for (j = 0; j < typeFieldWidth; ++j) {
  49984. type = type << 8 | stream.getByte();
  49985. }
  49986. if (typeFieldWidth === 0) {
  49987. type = 1;
  49988. }
  49989. for (j = 0; j < offsetFieldWidth; ++j) {
  49990. offset = offset << 8 | stream.getByte();
  49991. }
  49992. for (j = 0; j < generationFieldWidth; ++j) {
  49993. generation = generation << 8 | stream.getByte();
  49994. }
  49995. var entry = {};
  49996. entry.offset = offset;
  49997. entry.gen = generation;
  49998. switch (type) {
  49999. case 0:
  50000. entry.free = true;
  50001. break;
  50002. case 1:
  50003. entry.uncompressed = true;
  50004. break;
  50005. case 2:
  50006. break;
  50007. default:
  50008. error('Invalid XRef entry type: ' + type);
  50009. }
  50010. if (!this.entries[first + i]) {
  50011. this.entries[first + i] = entry;
  50012. }
  50013. }
  50014. streamState.entryNum = 0;
  50015. streamState.streamPos = stream.pos;
  50016. entryRanges.splice(0, 2);
  50017. }
  50018. },
  50019. indexObjects: function XRef_indexObjects() {
  50020. var TAB = 0x9, LF = 0xA, CR = 0xD, SPACE = 0x20;
  50021. var PERCENT = 0x25, LT = 0x3C;
  50022. function readToken(data, offset) {
  50023. var token = '', ch = data[offset];
  50024. while (ch !== LF && ch !== CR && ch !== LT) {
  50025. if (++offset >= data.length) {
  50026. break;
  50027. }
  50028. token += String.fromCharCode(ch);
  50029. ch = data[offset];
  50030. }
  50031. return token;
  50032. }
  50033. function skipUntil(data, offset, what) {
  50034. var length = what.length, dataLength = data.length;
  50035. var skipped = 0;
  50036. while (offset < dataLength) {
  50037. var i = 0;
  50038. while (i < length && data[offset + i] === what[i]) {
  50039. ++i;
  50040. }
  50041. if (i >= length) {
  50042. break;
  50043. }
  50044. offset++;
  50045. skipped++;
  50046. }
  50047. return skipped;
  50048. }
  50049. var objRegExp = /^(\d+)\s+(\d+)\s+obj\b/;
  50050. var trailerBytes = new Uint8Array([
  50051. 116,
  50052. 114,
  50053. 97,
  50054. 105,
  50055. 108,
  50056. 101,
  50057. 114
  50058. ]);
  50059. var startxrefBytes = new Uint8Array([
  50060. 115,
  50061. 116,
  50062. 97,
  50063. 114,
  50064. 116,
  50065. 120,
  50066. 114,
  50067. 101,
  50068. 102
  50069. ]);
  50070. var endobjBytes = new Uint8Array([
  50071. 101,
  50072. 110,
  50073. 100,
  50074. 111,
  50075. 98,
  50076. 106
  50077. ]);
  50078. var xrefBytes = new Uint8Array([
  50079. 47,
  50080. 88,
  50081. 82,
  50082. 101,
  50083. 102
  50084. ]);
  50085. this.entries.length = 0;
  50086. var stream = this.stream;
  50087. stream.pos = 0;
  50088. var buffer = stream.getBytes();
  50089. var position = stream.start, length = buffer.length;
  50090. var trailers = [], xrefStms = [];
  50091. while (position < length) {
  50092. var ch = buffer[position];
  50093. if (ch === TAB || ch === LF || ch === CR || ch === SPACE) {
  50094. ++position;
  50095. continue;
  50096. }
  50097. if (ch === PERCENT) {
  50098. do {
  50099. ++position;
  50100. if (position >= length) {
  50101. break;
  50102. }
  50103. ch = buffer[position];
  50104. } while (ch !== LF && ch !== CR);
  50105. continue;
  50106. }
  50107. var token = readToken(buffer, position);
  50108. var m;
  50109. if (token.indexOf('xref') === 0 && (token.length === 4 || /\s/.test(token[4]))) {
  50110. position += skipUntil(buffer, position, trailerBytes);
  50111. trailers.push(position);
  50112. position += skipUntil(buffer, position, startxrefBytes);
  50113. } else if (m = objRegExp.exec(token)) {
  50114. if (typeof this.entries[m[1]] === 'undefined') {
  50115. this.entries[m[1]] = {
  50116. offset: position - stream.start,
  50117. gen: m[2] | 0,
  50118. uncompressed: true
  50119. };
  50120. }
  50121. var contentLength = skipUntil(buffer, position, endobjBytes) + 7;
  50122. var content = buffer.subarray(position, position + contentLength);
  50123. var xrefTagOffset = skipUntil(content, 0, xrefBytes);
  50124. if (xrefTagOffset < contentLength && content[xrefTagOffset + 5] < 64) {
  50125. xrefStms.push(position - stream.start);
  50126. this.xrefstms[position - stream.start] = 1;
  50127. }
  50128. position += contentLength;
  50129. } else if (token.indexOf('trailer') === 0 && (token.length === 7 || /\s/.test(token[7]))) {
  50130. trailers.push(position);
  50131. position += skipUntil(buffer, position, startxrefBytes);
  50132. } else {
  50133. position += token.length + 1;
  50134. }
  50135. }
  50136. var i, ii;
  50137. for (i = 0, ii = xrefStms.length; i < ii; ++i) {
  50138. this.startXRefQueue.push(xrefStms[i]);
  50139. this.readXRef(true);
  50140. }
  50141. var dict;
  50142. for (i = 0, ii = trailers.length; i < ii; ++i) {
  50143. stream.pos = trailers[i];
  50144. var parser = new Parser(new Lexer(stream), true, this, true);
  50145. var obj = parser.getObj();
  50146. if (!isCmd(obj, 'trailer')) {
  50147. continue;
  50148. }
  50149. dict = parser.getObj();
  50150. if (!isDict(dict)) {
  50151. continue;
  50152. }
  50153. if (dict.has('ID')) {
  50154. return dict;
  50155. }
  50156. }
  50157. if (dict) {
  50158. return dict;
  50159. }
  50160. throw new InvalidPDFException('Invalid PDF structure');
  50161. },
  50162. readXRef: function XRef_readXRef(recoveryMode) {
  50163. var stream = this.stream;
  50164. try {
  50165. while (this.startXRefQueue.length) {
  50166. var startXRef = this.startXRefQueue[0];
  50167. stream.pos = startXRef + stream.start;
  50168. var parser = new Parser(new Lexer(stream), true, this);
  50169. var obj = parser.getObj();
  50170. var dict;
  50171. if (isCmd(obj, 'xref')) {
  50172. dict = this.processXRefTable(parser);
  50173. if (!this.topDict) {
  50174. this.topDict = dict;
  50175. }
  50176. obj = dict.get('XRefStm');
  50177. if (isInt(obj)) {
  50178. var pos = obj;
  50179. if (!(pos in this.xrefstms)) {
  50180. this.xrefstms[pos] = 1;
  50181. this.startXRefQueue.push(pos);
  50182. }
  50183. }
  50184. } else if (isInt(obj)) {
  50185. if (!isInt(parser.getObj()) || !isCmd(parser.getObj(), 'obj') || !isStream(obj = parser.getObj())) {
  50186. error('Invalid XRef stream');
  50187. }
  50188. dict = this.processXRefStream(obj);
  50189. if (!this.topDict) {
  50190. this.topDict = dict;
  50191. }
  50192. if (!dict) {
  50193. error('Failed to read XRef stream');
  50194. }
  50195. } else {
  50196. error('Invalid XRef stream header');
  50197. }
  50198. obj = dict.get('Prev');
  50199. if (isInt(obj)) {
  50200. this.startXRefQueue.push(obj);
  50201. } else if (isRef(obj)) {
  50202. this.startXRefQueue.push(obj.num);
  50203. }
  50204. this.startXRefQueue.shift();
  50205. }
  50206. return this.topDict;
  50207. } catch (e) {
  50208. if (e instanceof MissingDataException) {
  50209. throw e;
  50210. }
  50211. info('(while reading XRef): ' + e);
  50212. }
  50213. if (recoveryMode) {
  50214. return;
  50215. }
  50216. throw new XRefParseException();
  50217. },
  50218. getEntry: function XRef_getEntry(i) {
  50219. var xrefEntry = this.entries[i];
  50220. if (xrefEntry && !xrefEntry.free && xrefEntry.offset) {
  50221. return xrefEntry;
  50222. }
  50223. return null;
  50224. },
  50225. fetchIfRef: function XRef_fetchIfRef(obj, suppressEncryption) {
  50226. if (!isRef(obj)) {
  50227. return obj;
  50228. }
  50229. return this.fetch(obj, suppressEncryption);
  50230. },
  50231. fetch: function XRef_fetch(ref, suppressEncryption) {
  50232. assert(isRef(ref), 'ref object is not a reference');
  50233. var num = ref.num;
  50234. if (num in this.cache) {
  50235. var cacheEntry = this.cache[num];
  50236. return cacheEntry;
  50237. }
  50238. var xrefEntry = this.getEntry(num);
  50239. if (xrefEntry === null) {
  50240. return this.cache[num] = null;
  50241. }
  50242. if (xrefEntry.uncompressed) {
  50243. xrefEntry = this.fetchUncompressed(ref, xrefEntry, suppressEncryption);
  50244. } else {
  50245. xrefEntry = this.fetchCompressed(xrefEntry, suppressEncryption);
  50246. }
  50247. if (isDict(xrefEntry)) {
  50248. xrefEntry.objId = ref.toString();
  50249. } else if (isStream(xrefEntry)) {
  50250. xrefEntry.dict.objId = ref.toString();
  50251. }
  50252. return xrefEntry;
  50253. },
  50254. fetchUncompressed: function XRef_fetchUncompressed(ref, xrefEntry, suppressEncryption) {
  50255. var gen = ref.gen;
  50256. var num = ref.num;
  50257. if (xrefEntry.gen !== gen) {
  50258. error('inconsistent generation in XRef');
  50259. }
  50260. var stream = this.stream.makeSubStream(xrefEntry.offset + this.stream.start);
  50261. var parser = new Parser(new Lexer(stream), true, this);
  50262. var obj1 = parser.getObj();
  50263. var obj2 = parser.getObj();
  50264. var obj3 = parser.getObj();
  50265. if (!isInt(obj1) || parseInt(obj1, 10) !== num || !isInt(obj2) || parseInt(obj2, 10) !== gen || !isCmd(obj3)) {
  50266. error('bad XRef entry');
  50267. }
  50268. if (!isCmd(obj3, 'obj')) {
  50269. if (obj3.cmd.indexOf('obj') === 0) {
  50270. num = parseInt(obj3.cmd.substring(3), 10);
  50271. if (!isNaN(num)) {
  50272. return num;
  50273. }
  50274. }
  50275. error('bad XRef entry');
  50276. }
  50277. if (this.encrypt && !suppressEncryption) {
  50278. xrefEntry = parser.getObj(this.encrypt.createCipherTransform(num, gen));
  50279. } else {
  50280. xrefEntry = parser.getObj();
  50281. }
  50282. if (!isStream(xrefEntry)) {
  50283. this.cache[num] = xrefEntry;
  50284. }
  50285. return xrefEntry;
  50286. },
  50287. fetchCompressed: function XRef_fetchCompressed(xrefEntry, suppressEncryption) {
  50288. var tableOffset = xrefEntry.offset;
  50289. var stream = this.fetch(new Ref(tableOffset, 0));
  50290. if (!isStream(stream)) {
  50291. error('bad ObjStm stream');
  50292. }
  50293. var first = stream.dict.get('First');
  50294. var n = stream.dict.get('N');
  50295. if (!isInt(first) || !isInt(n)) {
  50296. error('invalid first and n parameters for ObjStm stream');
  50297. }
  50298. var parser = new Parser(new Lexer(stream), false, this);
  50299. parser.allowStreams = true;
  50300. var i, entries = [], num, nums = [];
  50301. for (i = 0; i < n; ++i) {
  50302. num = parser.getObj();
  50303. if (!isInt(num)) {
  50304. error('invalid object number in the ObjStm stream: ' + num);
  50305. }
  50306. nums.push(num);
  50307. var offset = parser.getObj();
  50308. if (!isInt(offset)) {
  50309. error('invalid object offset in the ObjStm stream: ' + offset);
  50310. }
  50311. }
  50312. for (i = 0; i < n; ++i) {
  50313. entries.push(parser.getObj());
  50314. if (isCmd(parser.buf1, 'endobj')) {
  50315. parser.shift();
  50316. }
  50317. num = nums[i];
  50318. var entry = this.entries[num];
  50319. if (entry && entry.offset === tableOffset && entry.gen === i) {
  50320. this.cache[num] = entries[i];
  50321. }
  50322. }
  50323. xrefEntry = entries[xrefEntry.gen];
  50324. if (xrefEntry === undefined) {
  50325. error('bad XRef entry for compressed object');
  50326. }
  50327. return xrefEntry;
  50328. },
  50329. fetchIfRefAsync: function XRef_fetchIfRefAsync(obj, suppressEncryption) {
  50330. if (!isRef(obj)) {
  50331. return Promise.resolve(obj);
  50332. }
  50333. return this.fetchAsync(obj, suppressEncryption);
  50334. },
  50335. fetchAsync: function XRef_fetchAsync(ref, suppressEncryption) {
  50336. var streamManager = this.stream.manager;
  50337. var xref = this;
  50338. return new Promise(function tryFetch(resolve, reject) {
  50339. try {
  50340. resolve(xref.fetch(ref, suppressEncryption));
  50341. } catch (e) {
  50342. if (e instanceof MissingDataException) {
  50343. streamManager.requestRange(e.begin, e.end).then(function () {
  50344. tryFetch(resolve, reject);
  50345. }, reject);
  50346. return;
  50347. }
  50348. reject(e);
  50349. }
  50350. });
  50351. },
  50352. getCatalogObj: function XRef_getCatalogObj() {
  50353. return this.root;
  50354. }
  50355. };
  50356. return XRef;
  50357. }();
  50358. var NameOrNumberTree = function NameOrNumberTreeClosure() {
  50359. function NameOrNumberTree(root, xref) {
  50360. throw new Error('Cannot initialize NameOrNumberTree.');
  50361. }
  50362. NameOrNumberTree.prototype = {
  50363. getAll: function NameOrNumberTree_getAll() {
  50364. var dict = Object.create(null);
  50365. if (!this.root) {
  50366. return dict;
  50367. }
  50368. var xref = this.xref;
  50369. var processed = new RefSet();
  50370. processed.put(this.root);
  50371. var queue = [this.root];
  50372. while (queue.length > 0) {
  50373. var i, n;
  50374. var obj = xref.fetchIfRef(queue.shift());
  50375. if (!isDict(obj)) {
  50376. continue;
  50377. }
  50378. if (obj.has('Kids')) {
  50379. var kids = obj.get('Kids');
  50380. for (i = 0, n = kids.length; i < n; i++) {
  50381. var kid = kids[i];
  50382. assert(!processed.has(kid), 'Duplicate entry in "' + this._type + '" tree.');
  50383. queue.push(kid);
  50384. processed.put(kid);
  50385. }
  50386. continue;
  50387. }
  50388. var entries = obj.get(this._type);
  50389. if (isArray(entries)) {
  50390. for (i = 0, n = entries.length; i < n; i += 2) {
  50391. dict[xref.fetchIfRef(entries[i])] = xref.fetchIfRef(entries[i + 1]);
  50392. }
  50393. }
  50394. }
  50395. return dict;
  50396. },
  50397. get: function NameOrNumberTree_get(key) {
  50398. if (!this.root) {
  50399. return null;
  50400. }
  50401. var xref = this.xref;
  50402. var kidsOrEntries = xref.fetchIfRef(this.root);
  50403. var loopCount = 0;
  50404. var MAX_LEVELS = 10;
  50405. var l, r, m;
  50406. while (kidsOrEntries.has('Kids')) {
  50407. if (++loopCount > MAX_LEVELS) {
  50408. warn('Search depth limit reached for "' + this._type + '" tree.');
  50409. return null;
  50410. }
  50411. var kids = kidsOrEntries.get('Kids');
  50412. if (!isArray(kids)) {
  50413. return null;
  50414. }
  50415. l = 0;
  50416. r = kids.length - 1;
  50417. while (l <= r) {
  50418. m = l + r >> 1;
  50419. var kid = xref.fetchIfRef(kids[m]);
  50420. var limits = kid.get('Limits');
  50421. if (key < xref.fetchIfRef(limits[0])) {
  50422. r = m - 1;
  50423. } else if (key > xref.fetchIfRef(limits[1])) {
  50424. l = m + 1;
  50425. } else {
  50426. kidsOrEntries = xref.fetchIfRef(kids[m]);
  50427. break;
  50428. }
  50429. }
  50430. if (l > r) {
  50431. return null;
  50432. }
  50433. }
  50434. var entries = kidsOrEntries.get(this._type);
  50435. if (isArray(entries)) {
  50436. l = 0;
  50437. r = entries.length - 2;
  50438. while (l <= r) {
  50439. m = l + r & ~1;
  50440. var currentKey = xref.fetchIfRef(entries[m]);
  50441. if (key < currentKey) {
  50442. r = m - 2;
  50443. } else if (key > currentKey) {
  50444. l = m + 2;
  50445. } else {
  50446. return xref.fetchIfRef(entries[m + 1]);
  50447. }
  50448. }
  50449. }
  50450. return null;
  50451. }
  50452. };
  50453. return NameOrNumberTree;
  50454. }();
  50455. var NameTree = function NameTreeClosure() {
  50456. function NameTree(root, xref) {
  50457. this.root = root;
  50458. this.xref = xref;
  50459. this._type = 'Names';
  50460. }
  50461. Util.inherit(NameTree, NameOrNumberTree, {});
  50462. return NameTree;
  50463. }();
  50464. var NumberTree = function NumberTreeClosure() {
  50465. function NumberTree(root, xref) {
  50466. this.root = root;
  50467. this.xref = xref;
  50468. this._type = 'Nums';
  50469. }
  50470. Util.inherit(NumberTree, NameOrNumberTree, {});
  50471. return NumberTree;
  50472. }();
  50473. var FileSpec = function FileSpecClosure() {
  50474. function FileSpec(root, xref) {
  50475. if (!root || !isDict(root)) {
  50476. return;
  50477. }
  50478. this.xref = xref;
  50479. this.root = root;
  50480. if (root.has('FS')) {
  50481. this.fs = root.get('FS');
  50482. }
  50483. this.description = root.has('Desc') ? stringToPDFString(root.get('Desc')) : '';
  50484. if (root.has('RF')) {
  50485. warn('Related file specifications are not supported');
  50486. }
  50487. this.contentAvailable = true;
  50488. if (!root.has('EF')) {
  50489. this.contentAvailable = false;
  50490. warn('Non-embedded file specifications are not supported');
  50491. }
  50492. }
  50493. function pickPlatformItem(dict) {
  50494. if (dict.has('UF')) {
  50495. return dict.get('UF');
  50496. } else if (dict.has('F')) {
  50497. return dict.get('F');
  50498. } else if (dict.has('Unix')) {
  50499. return dict.get('Unix');
  50500. } else if (dict.has('Mac')) {
  50501. return dict.get('Mac');
  50502. } else if (dict.has('DOS')) {
  50503. return dict.get('DOS');
  50504. } else {
  50505. return null;
  50506. }
  50507. }
  50508. FileSpec.prototype = {
  50509. get filename() {
  50510. if (!this._filename && this.root) {
  50511. var filename = pickPlatformItem(this.root) || 'unnamed';
  50512. this._filename = stringToPDFString(filename).replace(/\\\\/g, '\\').replace(/\\\//g, '/').replace(/\\/g, '/');
  50513. }
  50514. return this._filename;
  50515. },
  50516. get content() {
  50517. if (!this.contentAvailable) {
  50518. return null;
  50519. }
  50520. if (!this.contentRef && this.root) {
  50521. this.contentRef = pickPlatformItem(this.root.get('EF'));
  50522. }
  50523. var content = null;
  50524. if (this.contentRef) {
  50525. var xref = this.xref;
  50526. var fileObj = xref.fetchIfRef(this.contentRef);
  50527. if (fileObj && isStream(fileObj)) {
  50528. content = fileObj.getBytes();
  50529. } else {
  50530. warn('Embedded file specification points to non-existing/invalid ' + 'content');
  50531. }
  50532. } else {
  50533. warn('Embedded file specification does not have a content');
  50534. }
  50535. return content;
  50536. },
  50537. get serializable() {
  50538. return {
  50539. filename: this.filename,
  50540. content: this.content
  50541. };
  50542. }
  50543. };
  50544. return FileSpec;
  50545. }();
  50546. var ObjectLoader = function () {
  50547. function mayHaveChildren(value) {
  50548. return isRef(value) || isDict(value) || isArray(value) || isStream(value);
  50549. }
  50550. function addChildren(node, nodesToVisit) {
  50551. var value;
  50552. if (isDict(node) || isStream(node)) {
  50553. var map;
  50554. if (isDict(node)) {
  50555. map = node.map;
  50556. } else {
  50557. map = node.dict.map;
  50558. }
  50559. for (var key in map) {
  50560. value = map[key];
  50561. if (mayHaveChildren(value)) {
  50562. nodesToVisit.push(value);
  50563. }
  50564. }
  50565. } else if (isArray(node)) {
  50566. for (var i = 0, ii = node.length; i < ii; i++) {
  50567. value = node[i];
  50568. if (mayHaveChildren(value)) {
  50569. nodesToVisit.push(value);
  50570. }
  50571. }
  50572. }
  50573. }
  50574. function ObjectLoader(obj, keys, xref) {
  50575. this.obj = obj;
  50576. this.keys = keys;
  50577. this.xref = xref;
  50578. this.refSet = null;
  50579. this.capability = null;
  50580. }
  50581. ObjectLoader.prototype = {
  50582. load: function ObjectLoader_load() {
  50583. var keys = this.keys;
  50584. this.capability = createPromiseCapability();
  50585. if (!(this.xref.stream instanceof ChunkedStream) || this.xref.stream.getMissingChunks().length === 0) {
  50586. this.capability.resolve();
  50587. return this.capability.promise;
  50588. }
  50589. this.refSet = new RefSet();
  50590. var nodesToVisit = [];
  50591. for (var i = 0; i < keys.length; i++) {
  50592. nodesToVisit.push(this.obj[keys[i]]);
  50593. }
  50594. this._walk(nodesToVisit);
  50595. return this.capability.promise;
  50596. },
  50597. _walk: function ObjectLoader_walk(nodesToVisit) {
  50598. var nodesToRevisit = [];
  50599. var pendingRequests = [];
  50600. while (nodesToVisit.length) {
  50601. var currentNode = nodesToVisit.pop();
  50602. if (isRef(currentNode)) {
  50603. if (this.refSet.has(currentNode)) {
  50604. continue;
  50605. }
  50606. try {
  50607. var ref = currentNode;
  50608. this.refSet.put(ref);
  50609. currentNode = this.xref.fetch(currentNode);
  50610. } catch (e) {
  50611. if (!(e instanceof MissingDataException)) {
  50612. throw e;
  50613. }
  50614. nodesToRevisit.push(currentNode);
  50615. pendingRequests.push({
  50616. begin: e.begin,
  50617. end: e.end
  50618. });
  50619. }
  50620. }
  50621. if (currentNode && currentNode.getBaseStreams) {
  50622. var baseStreams = currentNode.getBaseStreams();
  50623. var foundMissingData = false;
  50624. for (var i = 0; i < baseStreams.length; i++) {
  50625. var stream = baseStreams[i];
  50626. if (stream.getMissingChunks && stream.getMissingChunks().length) {
  50627. foundMissingData = true;
  50628. pendingRequests.push({
  50629. begin: stream.start,
  50630. end: stream.end
  50631. });
  50632. }
  50633. }
  50634. if (foundMissingData) {
  50635. nodesToRevisit.push(currentNode);
  50636. }
  50637. }
  50638. addChildren(currentNode, nodesToVisit);
  50639. }
  50640. if (pendingRequests.length) {
  50641. this.xref.stream.manager.requestRanges(pendingRequests).then(function pendingRequestCallback() {
  50642. nodesToVisit = nodesToRevisit;
  50643. for (var i = 0; i < nodesToRevisit.length; i++) {
  50644. var node = nodesToRevisit[i];
  50645. if (isRef(node)) {
  50646. this.refSet.remove(node);
  50647. }
  50648. }
  50649. this._walk(nodesToVisit);
  50650. }.bind(this), this.capability.reject);
  50651. return;
  50652. }
  50653. this.refSet = null;
  50654. this.capability.resolve();
  50655. }
  50656. };
  50657. return ObjectLoader;
  50658. }();
  50659. exports.Catalog = Catalog;
  50660. exports.ObjectLoader = ObjectLoader;
  50661. exports.XRef = XRef;
  50662. exports.FileSpec = FileSpec;
  50663. }));
  50664. (function (root, factory) {
  50665. factory(root.pdfjsCorePattern = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreFunction, root.pdfjsCoreColorSpace);
  50666. }(this, function (exports, sharedUtil, corePrimitives, coreFunction, coreColorSpace) {
  50667. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  50668. var MissingDataException = sharedUtil.MissingDataException;
  50669. var Util = sharedUtil.Util;
  50670. var assert = sharedUtil.assert;
  50671. var error = sharedUtil.error;
  50672. var info = sharedUtil.info;
  50673. var warn = sharedUtil.warn;
  50674. var isStream = corePrimitives.isStream;
  50675. var PDFFunction = coreFunction.PDFFunction;
  50676. var ColorSpace = coreColorSpace.ColorSpace;
  50677. var ShadingType = {
  50678. FUNCTION_BASED: 1,
  50679. AXIAL: 2,
  50680. RADIAL: 3,
  50681. FREE_FORM_MESH: 4,
  50682. LATTICE_FORM_MESH: 5,
  50683. COONS_PATCH_MESH: 6,
  50684. TENSOR_PATCH_MESH: 7
  50685. };
  50686. var Pattern = function PatternClosure() {
  50687. function Pattern() {
  50688. error('should not call Pattern constructor');
  50689. }
  50690. Pattern.prototype = {
  50691. getPattern: function Pattern_getPattern(ctx) {
  50692. error('Should not call Pattern.getStyle: ' + ctx);
  50693. }
  50694. };
  50695. Pattern.parseShading = function Pattern_parseShading(shading, matrix, xref, res, handler) {
  50696. var dict = isStream(shading) ? shading.dict : shading;
  50697. var type = dict.get('ShadingType');
  50698. try {
  50699. switch (type) {
  50700. case ShadingType.AXIAL:
  50701. case ShadingType.RADIAL:
  50702. return new Shadings.RadialAxial(dict, matrix, xref, res);
  50703. case ShadingType.FREE_FORM_MESH:
  50704. case ShadingType.LATTICE_FORM_MESH:
  50705. case ShadingType.COONS_PATCH_MESH:
  50706. case ShadingType.TENSOR_PATCH_MESH:
  50707. return new Shadings.Mesh(shading, matrix, xref, res);
  50708. default:
  50709. throw new Error('Unsupported ShadingType: ' + type);
  50710. }
  50711. } catch (ex) {
  50712. if (ex instanceof MissingDataException) {
  50713. throw ex;
  50714. }
  50715. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.shadingPattern });
  50716. warn(ex);
  50717. return new Shadings.Dummy();
  50718. }
  50719. };
  50720. return Pattern;
  50721. }();
  50722. var Shadings = {};
  50723. Shadings.SMALL_NUMBER = 1e-6;
  50724. Shadings.RadialAxial = function RadialAxialClosure() {
  50725. function RadialAxial(dict, matrix, xref, res) {
  50726. this.matrix = matrix;
  50727. this.coordsArr = dict.getArray('Coords');
  50728. this.shadingType = dict.get('ShadingType');
  50729. this.type = 'Pattern';
  50730. var cs = dict.get('ColorSpace', 'CS');
  50731. cs = ColorSpace.parse(cs, xref, res);
  50732. this.cs = cs;
  50733. var t0 = 0.0, t1 = 1.0;
  50734. if (dict.has('Domain')) {
  50735. var domainArr = dict.getArray('Domain');
  50736. t0 = domainArr[0];
  50737. t1 = domainArr[1];
  50738. }
  50739. var extendStart = false, extendEnd = false;
  50740. if (dict.has('Extend')) {
  50741. var extendArr = dict.getArray('Extend');
  50742. extendStart = extendArr[0];
  50743. extendEnd = extendArr[1];
  50744. }
  50745. if (this.shadingType === ShadingType.RADIAL && (!extendStart || !extendEnd)) {
  50746. var x1 = this.coordsArr[0];
  50747. var y1 = this.coordsArr[1];
  50748. var r1 = this.coordsArr[2];
  50749. var x2 = this.coordsArr[3];
  50750. var y2 = this.coordsArr[4];
  50751. var r2 = this.coordsArr[5];
  50752. var distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
  50753. if (r1 <= r2 + distance && r2 <= r1 + distance) {
  50754. warn('Unsupported radial gradient.');
  50755. }
  50756. }
  50757. this.extendStart = extendStart;
  50758. this.extendEnd = extendEnd;
  50759. var fnObj = dict.get('Function');
  50760. var fn = PDFFunction.parseArray(xref, fnObj);
  50761. var diff = t1 - t0;
  50762. var step = diff / 10;
  50763. var colorStops = this.colorStops = [];
  50764. if (t0 >= t1 || step <= 0) {
  50765. info('Bad shading domain.');
  50766. return;
  50767. }
  50768. var color = new Float32Array(cs.numComps), ratio = new Float32Array(1);
  50769. var rgbColor;
  50770. for (var i = t0; i <= t1; i += step) {
  50771. ratio[0] = i;
  50772. fn(ratio, 0, color, 0);
  50773. rgbColor = cs.getRgb(color, 0);
  50774. var cssColor = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50775. colorStops.push([
  50776. (i - t0) / diff,
  50777. cssColor
  50778. ]);
  50779. }
  50780. var background = 'transparent';
  50781. if (dict.has('Background')) {
  50782. rgbColor = cs.getRgb(dict.get('Background'), 0);
  50783. background = Util.makeCssRgb(rgbColor[0], rgbColor[1], rgbColor[2]);
  50784. }
  50785. if (!extendStart) {
  50786. colorStops.unshift([
  50787. 0,
  50788. background
  50789. ]);
  50790. colorStops[1][0] += Shadings.SMALL_NUMBER;
  50791. }
  50792. if (!extendEnd) {
  50793. colorStops[colorStops.length - 1][0] -= Shadings.SMALL_NUMBER;
  50794. colorStops.push([
  50795. 1,
  50796. background
  50797. ]);
  50798. }
  50799. this.colorStops = colorStops;
  50800. }
  50801. RadialAxial.prototype = {
  50802. getIR: function RadialAxial_getIR() {
  50803. var coordsArr = this.coordsArr;
  50804. var shadingType = this.shadingType;
  50805. var type, p0, p1, r0, r1;
  50806. if (shadingType === ShadingType.AXIAL) {
  50807. p0 = [
  50808. coordsArr[0],
  50809. coordsArr[1]
  50810. ];
  50811. p1 = [
  50812. coordsArr[2],
  50813. coordsArr[3]
  50814. ];
  50815. r0 = null;
  50816. r1 = null;
  50817. type = 'axial';
  50818. } else if (shadingType === ShadingType.RADIAL) {
  50819. p0 = [
  50820. coordsArr[0],
  50821. coordsArr[1]
  50822. ];
  50823. p1 = [
  50824. coordsArr[3],
  50825. coordsArr[4]
  50826. ];
  50827. r0 = coordsArr[2];
  50828. r1 = coordsArr[5];
  50829. type = 'radial';
  50830. } else {
  50831. error('getPattern type unknown: ' + shadingType);
  50832. }
  50833. var matrix = this.matrix;
  50834. if (matrix) {
  50835. p0 = Util.applyTransform(p0, matrix);
  50836. p1 = Util.applyTransform(p1, matrix);
  50837. if (shadingType === ShadingType.RADIAL) {
  50838. var scale = Util.singularValueDecompose2dScale(matrix);
  50839. r0 *= scale[0];
  50840. r1 *= scale[1];
  50841. }
  50842. }
  50843. return [
  50844. 'RadialAxial',
  50845. type,
  50846. this.colorStops,
  50847. p0,
  50848. p1,
  50849. r0,
  50850. r1
  50851. ];
  50852. }
  50853. };
  50854. return RadialAxial;
  50855. }();
  50856. Shadings.Mesh = function MeshClosure() {
  50857. function MeshStreamReader(stream, context) {
  50858. this.stream = stream;
  50859. this.context = context;
  50860. this.buffer = 0;
  50861. this.bufferLength = 0;
  50862. var numComps = context.numComps;
  50863. this.tmpCompsBuf = new Float32Array(numComps);
  50864. var csNumComps = context.colorSpace.numComps;
  50865. this.tmpCsCompsBuf = context.colorFn ? new Float32Array(csNumComps) : this.tmpCompsBuf;
  50866. }
  50867. MeshStreamReader.prototype = {
  50868. get hasData() {
  50869. if (this.stream.end) {
  50870. return this.stream.pos < this.stream.end;
  50871. }
  50872. if (this.bufferLength > 0) {
  50873. return true;
  50874. }
  50875. var nextByte = this.stream.getByte();
  50876. if (nextByte < 0) {
  50877. return false;
  50878. }
  50879. this.buffer = nextByte;
  50880. this.bufferLength = 8;
  50881. return true;
  50882. },
  50883. readBits: function MeshStreamReader_readBits(n) {
  50884. var buffer = this.buffer;
  50885. var bufferLength = this.bufferLength;
  50886. if (n === 32) {
  50887. if (bufferLength === 0) {
  50888. return (this.stream.getByte() << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte()) >>> 0;
  50889. }
  50890. buffer = buffer << 24 | this.stream.getByte() << 16 | this.stream.getByte() << 8 | this.stream.getByte();
  50891. var nextByte = this.stream.getByte();
  50892. this.buffer = nextByte & (1 << bufferLength) - 1;
  50893. return (buffer << 8 - bufferLength | (nextByte & 0xFF) >> bufferLength) >>> 0;
  50894. }
  50895. if (n === 8 && bufferLength === 0) {
  50896. return this.stream.getByte();
  50897. }
  50898. while (bufferLength < n) {
  50899. buffer = buffer << 8 | this.stream.getByte();
  50900. bufferLength += 8;
  50901. }
  50902. bufferLength -= n;
  50903. this.bufferLength = bufferLength;
  50904. this.buffer = buffer & (1 << bufferLength) - 1;
  50905. return buffer >> bufferLength;
  50906. },
  50907. align: function MeshStreamReader_align() {
  50908. this.buffer = 0;
  50909. this.bufferLength = 0;
  50910. },
  50911. readFlag: function MeshStreamReader_readFlag() {
  50912. return this.readBits(this.context.bitsPerFlag);
  50913. },
  50914. readCoordinate: function MeshStreamReader_readCoordinate() {
  50915. var bitsPerCoordinate = this.context.bitsPerCoordinate;
  50916. var xi = this.readBits(bitsPerCoordinate);
  50917. var yi = this.readBits(bitsPerCoordinate);
  50918. var decode = this.context.decode;
  50919. var scale = bitsPerCoordinate < 32 ? 1 / ((1 << bitsPerCoordinate) - 1) : 2.3283064365386963e-10;
  50920. return [
  50921. xi * scale * (decode[1] - decode[0]) + decode[0],
  50922. yi * scale * (decode[3] - decode[2]) + decode[2]
  50923. ];
  50924. },
  50925. readComponents: function MeshStreamReader_readComponents() {
  50926. var numComps = this.context.numComps;
  50927. var bitsPerComponent = this.context.bitsPerComponent;
  50928. var scale = bitsPerComponent < 32 ? 1 / ((1 << bitsPerComponent) - 1) : 2.3283064365386963e-10;
  50929. var decode = this.context.decode;
  50930. var components = this.tmpCompsBuf;
  50931. for (var i = 0, j = 4; i < numComps; i++, j += 2) {
  50932. var ci = this.readBits(bitsPerComponent);
  50933. components[i] = ci * scale * (decode[j + 1] - decode[j]) + decode[j];
  50934. }
  50935. var color = this.tmpCsCompsBuf;
  50936. if (this.context.colorFn) {
  50937. this.context.colorFn(components, 0, color, 0);
  50938. }
  50939. return this.context.colorSpace.getRgb(color, 0);
  50940. }
  50941. };
  50942. function decodeType4Shading(mesh, reader) {
  50943. var coords = mesh.coords;
  50944. var colors = mesh.colors;
  50945. var operators = [];
  50946. var ps = [];
  50947. var verticesLeft = 0;
  50948. while (reader.hasData) {
  50949. var f = reader.readFlag();
  50950. var coord = reader.readCoordinate();
  50951. var color = reader.readComponents();
  50952. if (verticesLeft === 0) {
  50953. assert(0 <= f && f <= 2, 'Unknown type4 flag');
  50954. switch (f) {
  50955. case 0:
  50956. verticesLeft = 3;
  50957. break;
  50958. case 1:
  50959. ps.push(ps[ps.length - 2], ps[ps.length - 1]);
  50960. verticesLeft = 1;
  50961. break;
  50962. case 2:
  50963. ps.push(ps[ps.length - 3], ps[ps.length - 1]);
  50964. verticesLeft = 1;
  50965. break;
  50966. }
  50967. operators.push(f);
  50968. }
  50969. ps.push(coords.length);
  50970. coords.push(coord);
  50971. colors.push(color);
  50972. verticesLeft--;
  50973. reader.align();
  50974. }
  50975. mesh.figures.push({
  50976. type: 'triangles',
  50977. coords: new Int32Array(ps),
  50978. colors: new Int32Array(ps)
  50979. });
  50980. }
  50981. function decodeType5Shading(mesh, reader, verticesPerRow) {
  50982. var coords = mesh.coords;
  50983. var colors = mesh.colors;
  50984. var ps = [];
  50985. while (reader.hasData) {
  50986. var coord = reader.readCoordinate();
  50987. var color = reader.readComponents();
  50988. ps.push(coords.length);
  50989. coords.push(coord);
  50990. colors.push(color);
  50991. }
  50992. mesh.figures.push({
  50993. type: 'lattice',
  50994. coords: new Int32Array(ps),
  50995. colors: new Int32Array(ps),
  50996. verticesPerRow: verticesPerRow
  50997. });
  50998. }
  50999. var MIN_SPLIT_PATCH_CHUNKS_AMOUNT = 3;
  51000. var MAX_SPLIT_PATCH_CHUNKS_AMOUNT = 20;
  51001. var TRIANGLE_DENSITY = 20;
  51002. var getB = function getBClosure() {
  51003. function buildB(count) {
  51004. var lut = [];
  51005. for (var i = 0; i <= count; i++) {
  51006. var t = i / count, t_ = 1 - t;
  51007. lut.push(new Float32Array([
  51008. t_ * t_ * t_,
  51009. 3 * t * t_ * t_,
  51010. 3 * t * t * t_,
  51011. t * t * t
  51012. ]));
  51013. }
  51014. return lut;
  51015. }
  51016. var cache = [];
  51017. return function getB(count) {
  51018. if (!cache[count]) {
  51019. cache[count] = buildB(count);
  51020. }
  51021. return cache[count];
  51022. };
  51023. }();
  51024. function buildFigureFromPatch(mesh, index) {
  51025. var figure = mesh.figures[index];
  51026. assert(figure.type === 'patch', 'Unexpected patch mesh figure');
  51027. var coords = mesh.coords, colors = mesh.colors;
  51028. var pi = figure.coords;
  51029. var ci = figure.colors;
  51030. var figureMinX = Math.min(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51031. var figureMinY = Math.min(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51032. var figureMaxX = Math.max(coords[pi[0]][0], coords[pi[3]][0], coords[pi[12]][0], coords[pi[15]][0]);
  51033. var figureMaxY = Math.max(coords[pi[0]][1], coords[pi[3]][1], coords[pi[12]][1], coords[pi[15]][1]);
  51034. var splitXBy = Math.ceil((figureMaxX - figureMinX) * TRIANGLE_DENSITY / (mesh.bounds[2] - mesh.bounds[0]));
  51035. splitXBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitXBy));
  51036. var splitYBy = Math.ceil((figureMaxY - figureMinY) * TRIANGLE_DENSITY / (mesh.bounds[3] - mesh.bounds[1]));
  51037. splitYBy = Math.max(MIN_SPLIT_PATCH_CHUNKS_AMOUNT, Math.min(MAX_SPLIT_PATCH_CHUNKS_AMOUNT, splitYBy));
  51038. var verticesPerRow = splitXBy + 1;
  51039. var figureCoords = new Int32Array((splitYBy + 1) * verticesPerRow);
  51040. var figureColors = new Int32Array((splitYBy + 1) * verticesPerRow);
  51041. var k = 0;
  51042. var cl = new Uint8Array(3), cr = new Uint8Array(3);
  51043. var c0 = colors[ci[0]], c1 = colors[ci[1]], c2 = colors[ci[2]], c3 = colors[ci[3]];
  51044. var bRow = getB(splitYBy), bCol = getB(splitXBy);
  51045. for (var row = 0; row <= splitYBy; row++) {
  51046. cl[0] = (c0[0] * (splitYBy - row) + c2[0] * row) / splitYBy | 0;
  51047. cl[1] = (c0[1] * (splitYBy - row) + c2[1] * row) / splitYBy | 0;
  51048. cl[2] = (c0[2] * (splitYBy - row) + c2[2] * row) / splitYBy | 0;
  51049. cr[0] = (c1[0] * (splitYBy - row) + c3[0] * row) / splitYBy | 0;
  51050. cr[1] = (c1[1] * (splitYBy - row) + c3[1] * row) / splitYBy | 0;
  51051. cr[2] = (c1[2] * (splitYBy - row) + c3[2] * row) / splitYBy | 0;
  51052. for (var col = 0; col <= splitXBy; col++, k++) {
  51053. if ((row === 0 || row === splitYBy) && (col === 0 || col === splitXBy)) {
  51054. continue;
  51055. }
  51056. var x = 0, y = 0;
  51057. var q = 0;
  51058. for (var i = 0; i <= 3; i++) {
  51059. for (var j = 0; j <= 3; j++, q++) {
  51060. var m = bRow[row][i] * bCol[col][j];
  51061. x += coords[pi[q]][0] * m;
  51062. y += coords[pi[q]][1] * m;
  51063. }
  51064. }
  51065. figureCoords[k] = coords.length;
  51066. coords.push([
  51067. x,
  51068. y
  51069. ]);
  51070. figureColors[k] = colors.length;
  51071. var newColor = new Uint8Array(3);
  51072. newColor[0] = (cl[0] * (splitXBy - col) + cr[0] * col) / splitXBy | 0;
  51073. newColor[1] = (cl[1] * (splitXBy - col) + cr[1] * col) / splitXBy | 0;
  51074. newColor[2] = (cl[2] * (splitXBy - col) + cr[2] * col) / splitXBy | 0;
  51075. colors.push(newColor);
  51076. }
  51077. }
  51078. figureCoords[0] = pi[0];
  51079. figureColors[0] = ci[0];
  51080. figureCoords[splitXBy] = pi[3];
  51081. figureColors[splitXBy] = ci[1];
  51082. figureCoords[verticesPerRow * splitYBy] = pi[12];
  51083. figureColors[verticesPerRow * splitYBy] = ci[2];
  51084. figureCoords[verticesPerRow * splitYBy + splitXBy] = pi[15];
  51085. figureColors[verticesPerRow * splitYBy + splitXBy] = ci[3];
  51086. mesh.figures[index] = {
  51087. type: 'lattice',
  51088. coords: figureCoords,
  51089. colors: figureColors,
  51090. verticesPerRow: verticesPerRow
  51091. };
  51092. }
  51093. function decodeType6Shading(mesh, reader) {
  51094. var coords = mesh.coords;
  51095. var colors = mesh.colors;
  51096. var ps = new Int32Array(16);
  51097. var cs = new Int32Array(4);
  51098. while (reader.hasData) {
  51099. var f = reader.readFlag();
  51100. assert(0 <= f && f <= 3, 'Unknown type6 flag');
  51101. var i, ii;
  51102. var pi = coords.length;
  51103. for (i = 0, ii = f !== 0 ? 8 : 12; i < ii; i++) {
  51104. coords.push(reader.readCoordinate());
  51105. }
  51106. var ci = colors.length;
  51107. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51108. colors.push(reader.readComponents());
  51109. }
  51110. var tmp1, tmp2, tmp3, tmp4;
  51111. switch (f) {
  51112. case 0:
  51113. ps[12] = pi + 3;
  51114. ps[13] = pi + 4;
  51115. ps[14] = pi + 5;
  51116. ps[15] = pi + 6;
  51117. ps[8] = pi + 2;
  51118. ps[11] = pi + 7;
  51119. ps[4] = pi + 1;
  51120. ps[7] = pi + 8;
  51121. ps[0] = pi;
  51122. ps[1] = pi + 11;
  51123. ps[2] = pi + 10;
  51124. ps[3] = pi + 9;
  51125. cs[2] = ci + 1;
  51126. cs[3] = ci + 2;
  51127. cs[0] = ci;
  51128. cs[1] = ci + 3;
  51129. break;
  51130. case 1:
  51131. tmp1 = ps[12];
  51132. tmp2 = ps[13];
  51133. tmp3 = ps[14];
  51134. tmp4 = ps[15];
  51135. ps[12] = tmp4;
  51136. ps[13] = pi + 0;
  51137. ps[14] = pi + 1;
  51138. ps[15] = pi + 2;
  51139. ps[8] = tmp3;
  51140. ps[11] = pi + 3;
  51141. ps[4] = tmp2;
  51142. ps[7] = pi + 4;
  51143. ps[0] = tmp1;
  51144. ps[1] = pi + 7;
  51145. ps[2] = pi + 6;
  51146. ps[3] = pi + 5;
  51147. tmp1 = cs[2];
  51148. tmp2 = cs[3];
  51149. cs[2] = tmp2;
  51150. cs[3] = ci;
  51151. cs[0] = tmp1;
  51152. cs[1] = ci + 1;
  51153. break;
  51154. case 2:
  51155. tmp1 = ps[15];
  51156. tmp2 = ps[11];
  51157. ps[12] = ps[3];
  51158. ps[13] = pi + 0;
  51159. ps[14] = pi + 1;
  51160. ps[15] = pi + 2;
  51161. ps[8] = ps[7];
  51162. ps[11] = pi + 3;
  51163. ps[4] = tmp2;
  51164. ps[7] = pi + 4;
  51165. ps[0] = tmp1;
  51166. ps[1] = pi + 7;
  51167. ps[2] = pi + 6;
  51168. ps[3] = pi + 5;
  51169. tmp1 = cs[3];
  51170. cs[2] = cs[1];
  51171. cs[3] = ci;
  51172. cs[0] = tmp1;
  51173. cs[1] = ci + 1;
  51174. break;
  51175. case 3:
  51176. ps[12] = ps[0];
  51177. ps[13] = pi + 0;
  51178. ps[14] = pi + 1;
  51179. ps[15] = pi + 2;
  51180. ps[8] = ps[1];
  51181. ps[11] = pi + 3;
  51182. ps[4] = ps[2];
  51183. ps[7] = pi + 4;
  51184. ps[0] = ps[3];
  51185. ps[1] = pi + 7;
  51186. ps[2] = pi + 6;
  51187. ps[3] = pi + 5;
  51188. cs[2] = cs[0];
  51189. cs[3] = ci;
  51190. cs[0] = cs[1];
  51191. cs[1] = ci + 1;
  51192. break;
  51193. }
  51194. ps[5] = coords.length;
  51195. coords.push([
  51196. (-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,
  51197. (-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
  51198. ]);
  51199. ps[6] = coords.length;
  51200. coords.push([
  51201. (-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,
  51202. (-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
  51203. ]);
  51204. ps[9] = coords.length;
  51205. coords.push([
  51206. (-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,
  51207. (-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
  51208. ]);
  51209. ps[10] = coords.length;
  51210. coords.push([
  51211. (-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,
  51212. (-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
  51213. ]);
  51214. mesh.figures.push({
  51215. type: 'patch',
  51216. coords: new Int32Array(ps),
  51217. colors: new Int32Array(cs)
  51218. });
  51219. }
  51220. }
  51221. function decodeType7Shading(mesh, reader) {
  51222. var coords = mesh.coords;
  51223. var colors = mesh.colors;
  51224. var ps = new Int32Array(16);
  51225. var cs = new Int32Array(4);
  51226. while (reader.hasData) {
  51227. var f = reader.readFlag();
  51228. assert(0 <= f && f <= 3, 'Unknown type7 flag');
  51229. var i, ii;
  51230. var pi = coords.length;
  51231. for (i = 0, ii = f !== 0 ? 12 : 16; i < ii; i++) {
  51232. coords.push(reader.readCoordinate());
  51233. }
  51234. var ci = colors.length;
  51235. for (i = 0, ii = f !== 0 ? 2 : 4; i < ii; i++) {
  51236. colors.push(reader.readComponents());
  51237. }
  51238. var tmp1, tmp2, tmp3, tmp4;
  51239. switch (f) {
  51240. case 0:
  51241. ps[12] = pi + 3;
  51242. ps[13] = pi + 4;
  51243. ps[14] = pi + 5;
  51244. ps[15] = pi + 6;
  51245. ps[8] = pi + 2;
  51246. ps[9] = pi + 13;
  51247. ps[10] = pi + 14;
  51248. ps[11] = pi + 7;
  51249. ps[4] = pi + 1;
  51250. ps[5] = pi + 12;
  51251. ps[6] = pi + 15;
  51252. ps[7] = pi + 8;
  51253. ps[0] = pi;
  51254. ps[1] = pi + 11;
  51255. ps[2] = pi + 10;
  51256. ps[3] = pi + 9;
  51257. cs[2] = ci + 1;
  51258. cs[3] = ci + 2;
  51259. cs[0] = ci;
  51260. cs[1] = ci + 3;
  51261. break;
  51262. case 1:
  51263. tmp1 = ps[12];
  51264. tmp2 = ps[13];
  51265. tmp3 = ps[14];
  51266. tmp4 = ps[15];
  51267. ps[12] = tmp4;
  51268. ps[13] = pi + 0;
  51269. ps[14] = pi + 1;
  51270. ps[15] = pi + 2;
  51271. ps[8] = tmp3;
  51272. ps[9] = pi + 9;
  51273. ps[10] = pi + 10;
  51274. ps[11] = pi + 3;
  51275. ps[4] = tmp2;
  51276. ps[5] = pi + 8;
  51277. ps[6] = pi + 11;
  51278. ps[7] = pi + 4;
  51279. ps[0] = tmp1;
  51280. ps[1] = pi + 7;
  51281. ps[2] = pi + 6;
  51282. ps[3] = pi + 5;
  51283. tmp1 = cs[2];
  51284. tmp2 = cs[3];
  51285. cs[2] = tmp2;
  51286. cs[3] = ci;
  51287. cs[0] = tmp1;
  51288. cs[1] = ci + 1;
  51289. break;
  51290. case 2:
  51291. tmp1 = ps[15];
  51292. tmp2 = ps[11];
  51293. ps[12] = ps[3];
  51294. ps[13] = pi + 0;
  51295. ps[14] = pi + 1;
  51296. ps[15] = pi + 2;
  51297. ps[8] = ps[7];
  51298. ps[9] = pi + 9;
  51299. ps[10] = pi + 10;
  51300. ps[11] = pi + 3;
  51301. ps[4] = tmp2;
  51302. ps[5] = pi + 8;
  51303. ps[6] = pi + 11;
  51304. ps[7] = pi + 4;
  51305. ps[0] = tmp1;
  51306. ps[1] = pi + 7;
  51307. ps[2] = pi + 6;
  51308. ps[3] = pi + 5;
  51309. tmp1 = cs[3];
  51310. cs[2] = cs[1];
  51311. cs[3] = ci;
  51312. cs[0] = tmp1;
  51313. cs[1] = ci + 1;
  51314. break;
  51315. case 3:
  51316. ps[12] = ps[0];
  51317. ps[13] = pi + 0;
  51318. ps[14] = pi + 1;
  51319. ps[15] = pi + 2;
  51320. ps[8] = ps[1];
  51321. ps[9] = pi + 9;
  51322. ps[10] = pi + 10;
  51323. ps[11] = pi + 3;
  51324. ps[4] = ps[2];
  51325. ps[5] = pi + 8;
  51326. ps[6] = pi + 11;
  51327. ps[7] = pi + 4;
  51328. ps[0] = ps[3];
  51329. ps[1] = pi + 7;
  51330. ps[2] = pi + 6;
  51331. ps[3] = pi + 5;
  51332. cs[2] = cs[0];
  51333. cs[3] = ci;
  51334. cs[0] = cs[1];
  51335. cs[1] = ci + 1;
  51336. break;
  51337. }
  51338. mesh.figures.push({
  51339. type: 'patch',
  51340. coords: new Int32Array(ps),
  51341. colors: new Int32Array(cs)
  51342. });
  51343. }
  51344. }
  51345. function updateBounds(mesh) {
  51346. var minX = mesh.coords[0][0], minY = mesh.coords[0][1], maxX = minX, maxY = minY;
  51347. for (var i = 1, ii = mesh.coords.length; i < ii; i++) {
  51348. var x = mesh.coords[i][0], y = mesh.coords[i][1];
  51349. minX = minX > x ? x : minX;
  51350. minY = minY > y ? y : minY;
  51351. maxX = maxX < x ? x : maxX;
  51352. maxY = maxY < y ? y : maxY;
  51353. }
  51354. mesh.bounds = [
  51355. minX,
  51356. minY,
  51357. maxX,
  51358. maxY
  51359. ];
  51360. }
  51361. function packData(mesh) {
  51362. var i, ii, j, jj;
  51363. var coords = mesh.coords;
  51364. var coordsPacked = new Float32Array(coords.length * 2);
  51365. for (i = 0, j = 0, ii = coords.length; i < ii; i++) {
  51366. var xy = coords[i];
  51367. coordsPacked[j++] = xy[0];
  51368. coordsPacked[j++] = xy[1];
  51369. }
  51370. mesh.coords = coordsPacked;
  51371. var colors = mesh.colors;
  51372. var colorsPacked = new Uint8Array(colors.length * 3);
  51373. for (i = 0, j = 0, ii = colors.length; i < ii; i++) {
  51374. var c = colors[i];
  51375. colorsPacked[j++] = c[0];
  51376. colorsPacked[j++] = c[1];
  51377. colorsPacked[j++] = c[2];
  51378. }
  51379. mesh.colors = colorsPacked;
  51380. var figures = mesh.figures;
  51381. for (i = 0, ii = figures.length; i < ii; i++) {
  51382. var figure = figures[i], ps = figure.coords, cs = figure.colors;
  51383. for (j = 0, jj = ps.length; j < jj; j++) {
  51384. ps[j] *= 2;
  51385. cs[j] *= 3;
  51386. }
  51387. }
  51388. }
  51389. function Mesh(stream, matrix, xref, res) {
  51390. assert(isStream(stream), 'Mesh data is not a stream');
  51391. var dict = stream.dict;
  51392. this.matrix = matrix;
  51393. this.shadingType = dict.get('ShadingType');
  51394. this.type = 'Pattern';
  51395. this.bbox = dict.getArray('BBox');
  51396. var cs = dict.get('ColorSpace', 'CS');
  51397. cs = ColorSpace.parse(cs, xref, res);
  51398. this.cs = cs;
  51399. this.background = dict.has('Background') ? cs.getRgb(dict.get('Background'), 0) : null;
  51400. var fnObj = dict.get('Function');
  51401. var fn = fnObj ? PDFFunction.parseArray(xref, fnObj) : null;
  51402. this.coords = [];
  51403. this.colors = [];
  51404. this.figures = [];
  51405. var decodeContext = {
  51406. bitsPerCoordinate: dict.get('BitsPerCoordinate'),
  51407. bitsPerComponent: dict.get('BitsPerComponent'),
  51408. bitsPerFlag: dict.get('BitsPerFlag'),
  51409. decode: dict.getArray('Decode'),
  51410. colorFn: fn,
  51411. colorSpace: cs,
  51412. numComps: fn ? 1 : cs.numComps
  51413. };
  51414. var reader = new MeshStreamReader(stream, decodeContext);
  51415. var patchMesh = false;
  51416. switch (this.shadingType) {
  51417. case ShadingType.FREE_FORM_MESH:
  51418. decodeType4Shading(this, reader);
  51419. break;
  51420. case ShadingType.LATTICE_FORM_MESH:
  51421. var verticesPerRow = dict.get('VerticesPerRow') | 0;
  51422. assert(verticesPerRow >= 2, 'Invalid VerticesPerRow');
  51423. decodeType5Shading(this, reader, verticesPerRow);
  51424. break;
  51425. case ShadingType.COONS_PATCH_MESH:
  51426. decodeType6Shading(this, reader);
  51427. patchMesh = true;
  51428. break;
  51429. case ShadingType.TENSOR_PATCH_MESH:
  51430. decodeType7Shading(this, reader);
  51431. patchMesh = true;
  51432. break;
  51433. default:
  51434. error('Unsupported mesh type.');
  51435. break;
  51436. }
  51437. if (patchMesh) {
  51438. updateBounds(this);
  51439. for (var i = 0, ii = this.figures.length; i < ii; i++) {
  51440. buildFigureFromPatch(this, i);
  51441. }
  51442. }
  51443. updateBounds(this);
  51444. packData(this);
  51445. }
  51446. Mesh.prototype = {
  51447. getIR: function Mesh_getIR() {
  51448. return [
  51449. 'Mesh',
  51450. this.shadingType,
  51451. this.coords,
  51452. this.colors,
  51453. this.figures,
  51454. this.bounds,
  51455. this.matrix,
  51456. this.bbox,
  51457. this.background
  51458. ];
  51459. }
  51460. };
  51461. return Mesh;
  51462. }();
  51463. Shadings.Dummy = function DummyClosure() {
  51464. function Dummy() {
  51465. this.type = 'Pattern';
  51466. }
  51467. Dummy.prototype = {
  51468. getIR: function Dummy_getIR() {
  51469. return ['Dummy'];
  51470. }
  51471. };
  51472. return Dummy;
  51473. }();
  51474. function getTilingPatternIR(operatorList, dict, args) {
  51475. var matrix = dict.getArray('Matrix');
  51476. var bbox = dict.getArray('BBox');
  51477. var xstep = dict.get('XStep');
  51478. var ystep = dict.get('YStep');
  51479. var paintType = dict.get('PaintType');
  51480. var tilingType = dict.get('TilingType');
  51481. return [
  51482. 'TilingPattern',
  51483. args,
  51484. operatorList,
  51485. matrix,
  51486. bbox,
  51487. xstep,
  51488. ystep,
  51489. paintType,
  51490. tilingType
  51491. ];
  51492. }
  51493. exports.Pattern = Pattern;
  51494. exports.getTilingPatternIR = getTilingPatternIR;
  51495. }));
  51496. (function (root, factory) {
  51497. 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);
  51498. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreParser, coreImage, coreColorSpace, coreMurmurHash3, coreFonts, coreFunction, corePattern, coreCMap, coreMetrics, coreBidi, coreEncodings, coreStandardFonts, coreUnicode, coreGlyphList) {
  51499. var FONT_IDENTITY_MATRIX = sharedUtil.FONT_IDENTITY_MATRIX;
  51500. var IDENTITY_MATRIX = sharedUtil.IDENTITY_MATRIX;
  51501. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  51502. var ImageKind = sharedUtil.ImageKind;
  51503. var OPS = sharedUtil.OPS;
  51504. var TextRenderingMode = sharedUtil.TextRenderingMode;
  51505. var Util = sharedUtil.Util;
  51506. var assert = sharedUtil.assert;
  51507. var createPromiseCapability = sharedUtil.createPromiseCapability;
  51508. var error = sharedUtil.error;
  51509. var info = sharedUtil.info;
  51510. var isArray = sharedUtil.isArray;
  51511. var isNum = sharedUtil.isNum;
  51512. var isString = sharedUtil.isString;
  51513. var getLookupTableFactory = sharedUtil.getLookupTableFactory;
  51514. var warn = sharedUtil.warn;
  51515. var Dict = corePrimitives.Dict;
  51516. var Name = corePrimitives.Name;
  51517. var isCmd = corePrimitives.isCmd;
  51518. var isDict = corePrimitives.isDict;
  51519. var isName = corePrimitives.isName;
  51520. var isRef = corePrimitives.isRef;
  51521. var isStream = corePrimitives.isStream;
  51522. var DecodeStream = coreStream.DecodeStream;
  51523. var JpegStream = coreStream.JpegStream;
  51524. var Stream = coreStream.Stream;
  51525. var Lexer = coreParser.Lexer;
  51526. var Parser = coreParser.Parser;
  51527. var isEOF = coreParser.isEOF;
  51528. var PDFImage = coreImage.PDFImage;
  51529. var ColorSpace = coreColorSpace.ColorSpace;
  51530. var MurmurHash3_64 = coreMurmurHash3.MurmurHash3_64;
  51531. var ErrorFont = coreFonts.ErrorFont;
  51532. var FontFlags = coreFonts.FontFlags;
  51533. var Font = coreFonts.Font;
  51534. var IdentityToUnicodeMap = coreFonts.IdentityToUnicodeMap;
  51535. var ToUnicodeMap = coreFonts.ToUnicodeMap;
  51536. var getFontType = coreFonts.getFontType;
  51537. var isPDFFunction = coreFunction.isPDFFunction;
  51538. var PDFFunction = coreFunction.PDFFunction;
  51539. var Pattern = corePattern.Pattern;
  51540. var getTilingPatternIR = corePattern.getTilingPatternIR;
  51541. var CMapFactory = coreCMap.CMapFactory;
  51542. var IdentityCMap = coreCMap.IdentityCMap;
  51543. var getMetrics = coreMetrics.getMetrics;
  51544. var bidi = coreBidi.bidi;
  51545. var WinAnsiEncoding = coreEncodings.WinAnsiEncoding;
  51546. var StandardEncoding = coreEncodings.StandardEncoding;
  51547. var MacRomanEncoding = coreEncodings.MacRomanEncoding;
  51548. var SymbolSetEncoding = coreEncodings.SymbolSetEncoding;
  51549. var ZapfDingbatsEncoding = coreEncodings.ZapfDingbatsEncoding;
  51550. var getEncoding = coreEncodings.getEncoding;
  51551. var getStdFontMap = coreStandardFonts.getStdFontMap;
  51552. var getSerifFonts = coreStandardFonts.getSerifFonts;
  51553. var getSymbolsFonts = coreStandardFonts.getSymbolsFonts;
  51554. var getNormalizedUnicodes = coreUnicode.getNormalizedUnicodes;
  51555. var reverseIfRtl = coreUnicode.reverseIfRtl;
  51556. var getUnicodeForGlyph = coreUnicode.getUnicodeForGlyph;
  51557. var getGlyphsUnicode = coreGlyphList.getGlyphsUnicode;
  51558. var PartialEvaluator = function PartialEvaluatorClosure() {
  51559. var DefaultPartialEvaluatorOptions = {
  51560. forceDataSchema: false,
  51561. maxImageSize: -1,
  51562. disableFontFace: false,
  51563. cMapOptions: {
  51564. url: null,
  51565. packed: false
  51566. }
  51567. };
  51568. function NativeImageDecoder(xref, resources, handler, forceDataSchema) {
  51569. this.xref = xref;
  51570. this.resources = resources;
  51571. this.handler = handler;
  51572. this.forceDataSchema = forceDataSchema;
  51573. }
  51574. NativeImageDecoder.prototype = {
  51575. canDecode: function (image) {
  51576. return image instanceof JpegStream && NativeImageDecoder.isDecodable(image, this.xref, this.resources);
  51577. },
  51578. decode: function (image) {
  51579. var dict = image.dict;
  51580. var colorSpace = dict.get('ColorSpace', 'CS');
  51581. colorSpace = ColorSpace.parse(colorSpace, this.xref, this.resources);
  51582. var numComps = colorSpace.numComps;
  51583. var decodePromise = this.handler.sendWithPromise('JpegDecode', [
  51584. image.getIR(this.forceDataSchema),
  51585. numComps
  51586. ]);
  51587. return decodePromise.then(function (message) {
  51588. var data = message.data;
  51589. return new Stream(data, 0, data.length, image.dict);
  51590. });
  51591. }
  51592. };
  51593. NativeImageDecoder.isSupported = function NativeImageDecoder_isSupported(image, xref, res) {
  51594. var dict = image.dict;
  51595. if (dict.has('DecodeParms') || dict.has('DP')) {
  51596. return false;
  51597. }
  51598. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51599. return (cs.name === 'DeviceGray' || cs.name === 'DeviceRGB') && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51600. };
  51601. NativeImageDecoder.isDecodable = function NativeImageDecoder_isDecodable(image, xref, res) {
  51602. var dict = image.dict;
  51603. if (dict.has('DecodeParms') || dict.has('DP')) {
  51604. return false;
  51605. }
  51606. var cs = ColorSpace.parse(dict.get('ColorSpace', 'CS'), xref, res);
  51607. return (cs.numComps === 1 || cs.numComps === 3) && cs.isDefaultDecode(dict.getArray('Decode', 'D'));
  51608. };
  51609. function PartialEvaluator(pdfManager, xref, handler, pageIndex, uniquePrefix, idCounters, fontCache, options) {
  51610. this.pdfManager = pdfManager;
  51611. this.xref = xref;
  51612. this.handler = handler;
  51613. this.pageIndex = pageIndex;
  51614. this.uniquePrefix = uniquePrefix;
  51615. this.idCounters = idCounters;
  51616. this.fontCache = fontCache;
  51617. this.options = options || DefaultPartialEvaluatorOptions;
  51618. }
  51619. var TIME_SLOT_DURATION_MS = 20;
  51620. var CHECK_TIME_EVERY = 100;
  51621. function TimeSlotManager() {
  51622. this.reset();
  51623. }
  51624. TimeSlotManager.prototype = {
  51625. check: function TimeSlotManager_check() {
  51626. if (++this.checked < CHECK_TIME_EVERY) {
  51627. return false;
  51628. }
  51629. this.checked = 0;
  51630. return this.endTime <= Date.now();
  51631. },
  51632. reset: function TimeSlotManager_reset() {
  51633. this.endTime = Date.now() + TIME_SLOT_DURATION_MS;
  51634. this.checked = 0;
  51635. }
  51636. };
  51637. var deferred = Promise.resolve();
  51638. var TILING_PATTERN = 1, SHADING_PATTERN = 2;
  51639. PartialEvaluator.prototype = {
  51640. hasBlendModes: function PartialEvaluator_hasBlendModes(resources) {
  51641. if (!isDict(resources)) {
  51642. return false;
  51643. }
  51644. var processed = Object.create(null);
  51645. if (resources.objId) {
  51646. processed[resources.objId] = true;
  51647. }
  51648. var nodes = [resources], xref = this.xref;
  51649. while (nodes.length) {
  51650. var key, i, ii;
  51651. var node = nodes.shift();
  51652. var graphicStates = node.get('ExtGState');
  51653. if (isDict(graphicStates)) {
  51654. var graphicStatesKeys = graphicStates.getKeys();
  51655. for (i = 0, ii = graphicStatesKeys.length; i < ii; i++) {
  51656. key = graphicStatesKeys[i];
  51657. var graphicState = graphicStates.get(key);
  51658. var bm = graphicState.get('BM');
  51659. if (isName(bm) && bm.name !== 'Normal') {
  51660. return true;
  51661. }
  51662. }
  51663. }
  51664. var xObjects = node.get('XObject');
  51665. if (!isDict(xObjects)) {
  51666. continue;
  51667. }
  51668. var xObjectsKeys = xObjects.getKeys();
  51669. for (i = 0, ii = xObjectsKeys.length; i < ii; i++) {
  51670. key = xObjectsKeys[i];
  51671. var xObject = xObjects.getRaw(key);
  51672. if (isRef(xObject)) {
  51673. if (processed[xObject.toString()]) {
  51674. continue;
  51675. }
  51676. xObject = xref.fetch(xObject);
  51677. }
  51678. if (!isStream(xObject)) {
  51679. continue;
  51680. }
  51681. if (xObject.dict.objId) {
  51682. if (processed[xObject.dict.objId]) {
  51683. continue;
  51684. }
  51685. processed[xObject.dict.objId] = true;
  51686. }
  51687. var xResources = xObject.dict.get('Resources');
  51688. if (isDict(xResources) && (!xResources.objId || !processed[xResources.objId])) {
  51689. nodes.push(xResources);
  51690. if (xResources.objId) {
  51691. processed[xResources.objId] = true;
  51692. }
  51693. }
  51694. }
  51695. }
  51696. return false;
  51697. },
  51698. buildFormXObject: function PartialEvaluator_buildFormXObject(resources, xobj, smask, operatorList, task, initialState) {
  51699. var matrix = xobj.dict.getArray('Matrix');
  51700. var bbox = xobj.dict.getArray('BBox');
  51701. var group = xobj.dict.get('Group');
  51702. if (group) {
  51703. var groupOptions = {
  51704. matrix: matrix,
  51705. bbox: bbox,
  51706. smask: smask,
  51707. isolated: false,
  51708. knockout: false
  51709. };
  51710. var groupSubtype = group.get('S');
  51711. var colorSpace;
  51712. if (isName(groupSubtype, 'Transparency')) {
  51713. groupOptions.isolated = group.get('I') || false;
  51714. groupOptions.knockout = group.get('K') || false;
  51715. colorSpace = group.has('CS') ? ColorSpace.parse(group.get('CS'), this.xref, resources) : null;
  51716. }
  51717. if (smask && smask.backdrop) {
  51718. colorSpace = colorSpace || ColorSpace.singletons.rgb;
  51719. smask.backdrop = colorSpace.getRgb(smask.backdrop, 0);
  51720. }
  51721. operatorList.addOp(OPS.beginGroup, [groupOptions]);
  51722. }
  51723. operatorList.addOp(OPS.paintFormXObjectBegin, [
  51724. matrix,
  51725. bbox
  51726. ]);
  51727. return this.getOperatorList(xobj, task, xobj.dict.get('Resources') || resources, operatorList, initialState).then(function () {
  51728. operatorList.addOp(OPS.paintFormXObjectEnd, []);
  51729. if (group) {
  51730. operatorList.addOp(OPS.endGroup, [groupOptions]);
  51731. }
  51732. });
  51733. },
  51734. buildPaintImageXObject: function PartialEvaluator_buildPaintImageXObject(resources, image, inline, operatorList, cacheKey, imageCache) {
  51735. var self = this;
  51736. var dict = image.dict;
  51737. var w = dict.get('Width', 'W');
  51738. var h = dict.get('Height', 'H');
  51739. if (!(w && isNum(w)) || !(h && isNum(h))) {
  51740. warn('Image dimensions are missing, or not numbers.');
  51741. return;
  51742. }
  51743. var maxImageSize = this.options.maxImageSize;
  51744. if (maxImageSize !== -1 && w * h > maxImageSize) {
  51745. warn('Image exceeded maximum allowed size and was removed.');
  51746. return;
  51747. }
  51748. var imageMask = dict.get('ImageMask', 'IM') || false;
  51749. var imgData, args;
  51750. if (imageMask) {
  51751. var width = dict.get('Width', 'W');
  51752. var height = dict.get('Height', 'H');
  51753. var bitStrideLength = width + 7 >> 3;
  51754. var imgArray = image.getBytes(bitStrideLength * height);
  51755. var decode = dict.getArray('Decode', 'D');
  51756. var inverseDecode = !!decode && decode[0] > 0;
  51757. imgData = PDFImage.createMask(imgArray, width, height, image instanceof DecodeStream, inverseDecode);
  51758. imgData.cached = true;
  51759. args = [imgData];
  51760. operatorList.addOp(OPS.paintImageMaskXObject, args);
  51761. if (cacheKey) {
  51762. imageCache[cacheKey] = {
  51763. fn: OPS.paintImageMaskXObject,
  51764. args: args
  51765. };
  51766. }
  51767. return;
  51768. }
  51769. var softMask = dict.get('SMask', 'SM') || false;
  51770. var mask = dict.get('Mask') || false;
  51771. var SMALL_IMAGE_DIMENSIONS = 200;
  51772. if (inline && !softMask && !mask && !(image instanceof JpegStream) && w + h < SMALL_IMAGE_DIMENSIONS) {
  51773. var imageObj = new PDFImage(this.xref, resources, image, inline, null, null);
  51774. imgData = imageObj.createImageData(true);
  51775. operatorList.addOp(OPS.paintInlineImageXObject, [imgData]);
  51776. return;
  51777. }
  51778. var uniquePrefix = this.uniquePrefix || '';
  51779. var objId = 'img_' + uniquePrefix + ++this.idCounters.obj;
  51780. operatorList.addDependency(objId);
  51781. args = [
  51782. objId,
  51783. w,
  51784. h
  51785. ];
  51786. if (!softMask && !mask && image instanceof JpegStream && NativeImageDecoder.isSupported(image, this.xref, resources)) {
  51787. operatorList.addOp(OPS.paintJpegXObject, args);
  51788. this.handler.send('obj', [
  51789. objId,
  51790. this.pageIndex,
  51791. 'JpegStream',
  51792. image.getIR(this.options.forceDataSchema)
  51793. ]);
  51794. return;
  51795. }
  51796. var nativeImageDecoder = null;
  51797. if (image instanceof JpegStream || mask instanceof JpegStream || softMask instanceof JpegStream) {
  51798. nativeImageDecoder = new NativeImageDecoder(self.xref, resources, self.handler, self.options.forceDataSchema);
  51799. }
  51800. PDFImage.buildImage(self.handler, self.xref, resources, image, inline, nativeImageDecoder).then(function (imageObj) {
  51801. var imgData = imageObj.createImageData(false);
  51802. self.handler.send('obj', [
  51803. objId,
  51804. self.pageIndex,
  51805. 'Image',
  51806. imgData
  51807. ], [imgData.data.buffer]);
  51808. }).then(undefined, function (reason) {
  51809. warn('Unable to decode image: ' + reason);
  51810. self.handler.send('obj', [
  51811. objId,
  51812. self.pageIndex,
  51813. 'Image',
  51814. null
  51815. ]);
  51816. });
  51817. operatorList.addOp(OPS.paintImageXObject, args);
  51818. if (cacheKey) {
  51819. imageCache[cacheKey] = {
  51820. fn: OPS.paintImageXObject,
  51821. args: args
  51822. };
  51823. }
  51824. },
  51825. handleSMask: function PartialEvaluator_handleSmask(smask, resources, operatorList, task, stateManager) {
  51826. var smaskContent = smask.get('G');
  51827. var smaskOptions = {
  51828. subtype: smask.get('S').name,
  51829. backdrop: smask.get('BC')
  51830. };
  51831. var transferObj = smask.get('TR');
  51832. if (isPDFFunction(transferObj)) {
  51833. var transferFn = PDFFunction.parse(this.xref, transferObj);
  51834. var transferMap = new Uint8Array(256);
  51835. var tmp = new Float32Array(1);
  51836. for (var i = 0; i < 256; i++) {
  51837. tmp[0] = i / 255;
  51838. transferFn(tmp, 0, tmp, 0);
  51839. transferMap[i] = tmp[0] * 255 | 0;
  51840. }
  51841. smaskOptions.transferMap = transferMap;
  51842. }
  51843. return this.buildFormXObject(resources, smaskContent, smaskOptions, operatorList, task, stateManager.state.clone());
  51844. },
  51845. handleTilingType: function PartialEvaluator_handleTilingType(fn, args, resources, pattern, patternDict, operatorList, task) {
  51846. var tilingOpList = new OperatorList();
  51847. var resourcesArray = [
  51848. patternDict.get('Resources'),
  51849. resources
  51850. ];
  51851. var patternResources = Dict.merge(this.xref, resourcesArray);
  51852. return this.getOperatorList(pattern, task, patternResources, tilingOpList).then(function () {
  51853. operatorList.addDependencies(tilingOpList.dependencies);
  51854. operatorList.addOp(fn, getTilingPatternIR({
  51855. fnArray: tilingOpList.fnArray,
  51856. argsArray: tilingOpList.argsArray
  51857. }, patternDict, args));
  51858. });
  51859. },
  51860. handleSetFont: function PartialEvaluator_handleSetFont(resources, fontArgs, fontRef, operatorList, task, state) {
  51861. var fontName;
  51862. if (fontArgs) {
  51863. fontArgs = fontArgs.slice();
  51864. fontName = fontArgs[0].name;
  51865. }
  51866. var self = this;
  51867. return this.loadFont(fontName, fontRef, this.xref, resources).then(function (translated) {
  51868. if (!translated.font.isType3Font) {
  51869. return translated;
  51870. }
  51871. return translated.loadType3Data(self, resources, operatorList, task).then(function () {
  51872. return translated;
  51873. }, function (reason) {
  51874. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  51875. return new TranslatedFont('g_font_error', new ErrorFont('Type3 font load error: ' + reason), translated.font);
  51876. });
  51877. }).then(function (translated) {
  51878. state.font = translated.font;
  51879. translated.send(self.handler);
  51880. return translated.loadedName;
  51881. });
  51882. },
  51883. handleText: function PartialEvaluator_handleText(chars, state) {
  51884. var font = state.font;
  51885. var glyphs = font.charsToGlyphs(chars);
  51886. var isAddToPathSet = !!(state.textRenderingMode & TextRenderingMode.ADD_TO_PATH_FLAG);
  51887. if (font.data && (isAddToPathSet || this.options.disableFontFace)) {
  51888. var buildPath = function (fontChar) {
  51889. if (!font.renderer.hasBuiltPath(fontChar)) {
  51890. var path = font.renderer.getPathJs(fontChar);
  51891. this.handler.send('commonobj', [
  51892. font.loadedName + '_path_' + fontChar,
  51893. 'FontPath',
  51894. path
  51895. ]);
  51896. }
  51897. }.bind(this);
  51898. for (var i = 0, ii = glyphs.length; i < ii; i++) {
  51899. var glyph = glyphs[i];
  51900. buildPath(glyph.fontChar);
  51901. var accent = glyph.accent;
  51902. if (accent && accent.fontChar) {
  51903. buildPath(accent.fontChar);
  51904. }
  51905. }
  51906. }
  51907. return glyphs;
  51908. },
  51909. setGState: function PartialEvaluator_setGState(resources, gState, operatorList, task, xref, stateManager) {
  51910. var gStateObj = [];
  51911. var gStateKeys = gState.getKeys();
  51912. var self = this;
  51913. var promise = Promise.resolve();
  51914. for (var i = 0, ii = gStateKeys.length; i < ii; i++) {
  51915. var key = gStateKeys[i];
  51916. var value = gState.get(key);
  51917. switch (key) {
  51918. case 'Type':
  51919. break;
  51920. case 'LW':
  51921. case 'LC':
  51922. case 'LJ':
  51923. case 'ML':
  51924. case 'D':
  51925. case 'RI':
  51926. case 'FL':
  51927. case 'CA':
  51928. case 'ca':
  51929. gStateObj.push([
  51930. key,
  51931. value
  51932. ]);
  51933. break;
  51934. case 'Font':
  51935. promise = promise.then(function () {
  51936. return self.handleSetFont(resources, null, value[0], operatorList, task, stateManager.state).then(function (loadedName) {
  51937. operatorList.addDependency(loadedName);
  51938. gStateObj.push([
  51939. key,
  51940. [
  51941. loadedName,
  51942. value[1]
  51943. ]
  51944. ]);
  51945. });
  51946. });
  51947. break;
  51948. case 'BM':
  51949. gStateObj.push([
  51950. key,
  51951. value
  51952. ]);
  51953. break;
  51954. case 'SMask':
  51955. if (isName(value, 'None')) {
  51956. gStateObj.push([
  51957. key,
  51958. false
  51959. ]);
  51960. break;
  51961. }
  51962. if (isDict(value)) {
  51963. promise = promise.then(function (dict) {
  51964. return self.handleSMask(dict, resources, operatorList, task, stateManager);
  51965. }.bind(this, value));
  51966. gStateObj.push([
  51967. key,
  51968. true
  51969. ]);
  51970. } else {
  51971. warn('Unsupported SMask type');
  51972. }
  51973. break;
  51974. case 'OP':
  51975. case 'op':
  51976. case 'OPM':
  51977. case 'BG':
  51978. case 'BG2':
  51979. case 'UCR':
  51980. case 'UCR2':
  51981. case 'TR':
  51982. case 'TR2':
  51983. case 'HT':
  51984. case 'SM':
  51985. case 'SA':
  51986. case 'AIS':
  51987. case 'TK':
  51988. info('graphic state operator ' + key);
  51989. break;
  51990. default:
  51991. info('Unknown graphic state operator ' + key);
  51992. break;
  51993. }
  51994. }
  51995. return promise.then(function () {
  51996. if (gStateObj.length > 0) {
  51997. operatorList.addOp(OPS.setGState, [gStateObj]);
  51998. }
  51999. });
  52000. },
  52001. loadFont: function PartialEvaluator_loadFont(fontName, font, xref, resources) {
  52002. function errorFont() {
  52003. return Promise.resolve(new TranslatedFont('g_font_error', new ErrorFont('Font ' + fontName + ' is not available'), font));
  52004. }
  52005. var fontRef;
  52006. if (font) {
  52007. assert(isRef(font));
  52008. fontRef = font;
  52009. } else {
  52010. var fontRes = resources.get('Font');
  52011. if (fontRes) {
  52012. fontRef = fontRes.getRaw(fontName);
  52013. } else {
  52014. warn('fontRes not available');
  52015. return errorFont();
  52016. }
  52017. }
  52018. if (!fontRef) {
  52019. warn('fontRef not available');
  52020. return errorFont();
  52021. }
  52022. if (this.fontCache.has(fontRef)) {
  52023. return this.fontCache.get(fontRef);
  52024. }
  52025. font = xref.fetchIfRef(fontRef);
  52026. if (!isDict(font)) {
  52027. return errorFont();
  52028. }
  52029. if (font.translated) {
  52030. return font.translated;
  52031. }
  52032. var fontCapability = createPromiseCapability();
  52033. var preEvaluatedFont = this.preEvaluateFont(font, xref);
  52034. var descriptor = preEvaluatedFont.descriptor;
  52035. var fontRefIsRef = isRef(fontRef), fontID;
  52036. if (fontRefIsRef) {
  52037. fontID = fontRef.toString();
  52038. }
  52039. if (isDict(descriptor)) {
  52040. if (!descriptor.fontAliases) {
  52041. descriptor.fontAliases = Object.create(null);
  52042. }
  52043. var fontAliases = descriptor.fontAliases;
  52044. var hash = preEvaluatedFont.hash;
  52045. if (fontAliases[hash]) {
  52046. var aliasFontRef = fontAliases[hash].aliasRef;
  52047. if (fontRefIsRef && aliasFontRef && this.fontCache.has(aliasFontRef)) {
  52048. this.fontCache.putAlias(fontRef, aliasFontRef);
  52049. return this.fontCache.get(fontRef);
  52050. }
  52051. } else {
  52052. fontAliases[hash] = { fontID: Font.getFontID() };
  52053. }
  52054. if (fontRefIsRef) {
  52055. fontAliases[hash].aliasRef = fontRef;
  52056. }
  52057. fontID = fontAliases[hash].fontID;
  52058. }
  52059. if (fontRefIsRef) {
  52060. this.fontCache.put(fontRef, fontCapability.promise);
  52061. } else {
  52062. if (!fontID) {
  52063. fontID = (this.uniquePrefix || 'F_') + ++this.idCounters.obj;
  52064. }
  52065. this.fontCache.put('id_' + fontID, fontCapability.promise);
  52066. }
  52067. assert(fontID, 'The "fontID" must be defined.');
  52068. font.loadedName = 'g_' + this.pdfManager.docId + '_f' + fontID;
  52069. font.translated = fontCapability.promise;
  52070. var translatedPromise;
  52071. try {
  52072. translatedPromise = this.translateFont(preEvaluatedFont, xref);
  52073. } catch (e) {
  52074. translatedPromise = Promise.reject(e);
  52075. }
  52076. var self = this;
  52077. translatedPromise.then(function (translatedFont) {
  52078. if (translatedFont.fontType !== undefined) {
  52079. var xrefFontStats = xref.stats.fontTypes;
  52080. xrefFontStats[translatedFont.fontType] = true;
  52081. }
  52082. fontCapability.resolve(new TranslatedFont(font.loadedName, translatedFont, font));
  52083. }, function (reason) {
  52084. self.handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.font });
  52085. try {
  52086. var descriptor = preEvaluatedFont.descriptor;
  52087. var fontFile3 = descriptor && descriptor.get('FontFile3');
  52088. var subtype = fontFile3 && fontFile3.get('Subtype');
  52089. var fontType = getFontType(preEvaluatedFont.type, subtype && subtype.name);
  52090. var xrefFontStats = xref.stats.fontTypes;
  52091. xrefFontStats[fontType] = true;
  52092. } catch (ex) {
  52093. }
  52094. fontCapability.resolve(new TranslatedFont(font.loadedName, new ErrorFont(reason instanceof Error ? reason.message : reason), font));
  52095. });
  52096. return fontCapability.promise;
  52097. },
  52098. buildPath: function PartialEvaluator_buildPath(operatorList, fn, args) {
  52099. var lastIndex = operatorList.length - 1;
  52100. if (!args) {
  52101. args = [];
  52102. }
  52103. if (lastIndex < 0 || operatorList.fnArray[lastIndex] !== OPS.constructPath) {
  52104. operatorList.addOp(OPS.constructPath, [
  52105. [fn],
  52106. args
  52107. ]);
  52108. } else {
  52109. var opArgs = operatorList.argsArray[lastIndex];
  52110. opArgs[0].push(fn);
  52111. Array.prototype.push.apply(opArgs[1], args);
  52112. }
  52113. },
  52114. handleColorN: function PartialEvaluator_handleColorN(operatorList, fn, args, cs, patterns, resources, task, xref) {
  52115. var patternName = args[args.length - 1];
  52116. var pattern;
  52117. if (isName(patternName) && (pattern = patterns.get(patternName.name))) {
  52118. var dict = isStream(pattern) ? pattern.dict : pattern;
  52119. var typeNum = dict.get('PatternType');
  52120. if (typeNum === TILING_PATTERN) {
  52121. var color = cs.base ? cs.base.getRgb(args, 0) : null;
  52122. return this.handleTilingType(fn, color, resources, pattern, dict, operatorList, task);
  52123. } else if (typeNum === SHADING_PATTERN) {
  52124. var shading = dict.get('Shading');
  52125. var matrix = dict.getArray('Matrix');
  52126. pattern = Pattern.parseShading(shading, matrix, xref, resources, this.handler);
  52127. operatorList.addOp(fn, pattern.getIR());
  52128. return Promise.resolve();
  52129. } else {
  52130. return Promise.reject('Unknown PatternType: ' + typeNum);
  52131. }
  52132. }
  52133. operatorList.addOp(fn, args);
  52134. return Promise.resolve();
  52135. },
  52136. getOperatorList: function PartialEvaluator_getOperatorList(stream, task, resources, operatorList, initialState) {
  52137. var self = this;
  52138. var xref = this.xref;
  52139. var imageCache = Object.create(null);
  52140. assert(operatorList);
  52141. resources = resources || Dict.empty;
  52142. var xobjs = resources.get('XObject') || Dict.empty;
  52143. var patterns = resources.get('Pattern') || Dict.empty;
  52144. var stateManager = new StateManager(initialState || new EvalState());
  52145. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52146. var timeSlotManager = new TimeSlotManager();
  52147. return new Promise(function promiseBody(resolve, reject) {
  52148. var next = function (promise) {
  52149. promise.then(function () {
  52150. try {
  52151. promiseBody(resolve, reject);
  52152. } catch (ex) {
  52153. reject(ex);
  52154. }
  52155. }, reject);
  52156. };
  52157. task.ensureNotTerminated();
  52158. timeSlotManager.reset();
  52159. var stop, operation = {}, i, ii, cs;
  52160. while (!(stop = timeSlotManager.check())) {
  52161. operation.args = null;
  52162. if (!preprocessor.read(operation)) {
  52163. break;
  52164. }
  52165. var args = operation.args;
  52166. var fn = operation.fn;
  52167. switch (fn | 0) {
  52168. case OPS.paintXObject:
  52169. if (args[0].code) {
  52170. break;
  52171. }
  52172. var name = args[0].name;
  52173. if (!name) {
  52174. warn('XObject must be referred to by name.');
  52175. continue;
  52176. }
  52177. if (imageCache[name] !== undefined) {
  52178. operatorList.addOp(imageCache[name].fn, imageCache[name].args);
  52179. args = null;
  52180. continue;
  52181. }
  52182. var xobj = xobjs.get(name);
  52183. if (xobj) {
  52184. assert(isStream(xobj), 'XObject should be a stream');
  52185. var type = xobj.dict.get('Subtype');
  52186. assert(isName(type), 'XObject should have a Name subtype');
  52187. if (type.name === 'Form') {
  52188. stateManager.save();
  52189. next(self.buildFormXObject(resources, xobj, null, operatorList, task, stateManager.state.clone()).then(function () {
  52190. stateManager.restore();
  52191. }));
  52192. return;
  52193. } else if (type.name === 'Image') {
  52194. self.buildPaintImageXObject(resources, xobj, false, operatorList, name, imageCache);
  52195. args = null;
  52196. continue;
  52197. } else if (type.name === 'PS') {
  52198. info('Ignored XObject subtype PS');
  52199. continue;
  52200. } else {
  52201. error('Unhandled XObject subtype ' + type.name);
  52202. }
  52203. }
  52204. break;
  52205. case OPS.setFont:
  52206. var fontSize = args[1];
  52207. next(self.handleSetFont(resources, args, null, operatorList, task, stateManager.state).then(function (loadedName) {
  52208. operatorList.addDependency(loadedName);
  52209. operatorList.addOp(OPS.setFont, [
  52210. loadedName,
  52211. fontSize
  52212. ]);
  52213. }));
  52214. return;
  52215. case OPS.endInlineImage:
  52216. var cacheKey = args[0].cacheKey;
  52217. if (cacheKey) {
  52218. var cacheEntry = imageCache[cacheKey];
  52219. if (cacheEntry !== undefined) {
  52220. operatorList.addOp(cacheEntry.fn, cacheEntry.args);
  52221. args = null;
  52222. continue;
  52223. }
  52224. }
  52225. self.buildPaintImageXObject(resources, args[0], true, operatorList, cacheKey, imageCache);
  52226. args = null;
  52227. continue;
  52228. case OPS.showText:
  52229. args[0] = self.handleText(args[0], stateManager.state);
  52230. break;
  52231. case OPS.showSpacedText:
  52232. var arr = args[0];
  52233. var combinedGlyphs = [];
  52234. var arrLength = arr.length;
  52235. var state = stateManager.state;
  52236. for (i = 0; i < arrLength; ++i) {
  52237. var arrItem = arr[i];
  52238. if (isString(arrItem)) {
  52239. Array.prototype.push.apply(combinedGlyphs, self.handleText(arrItem, state));
  52240. } else if (isNum(arrItem)) {
  52241. combinedGlyphs.push(arrItem);
  52242. }
  52243. }
  52244. args[0] = combinedGlyphs;
  52245. fn = OPS.showText;
  52246. break;
  52247. case OPS.nextLineShowText:
  52248. operatorList.addOp(OPS.nextLine);
  52249. args[0] = self.handleText(args[0], stateManager.state);
  52250. fn = OPS.showText;
  52251. break;
  52252. case OPS.nextLineSetSpacingShowText:
  52253. operatorList.addOp(OPS.nextLine);
  52254. operatorList.addOp(OPS.setWordSpacing, [args.shift()]);
  52255. operatorList.addOp(OPS.setCharSpacing, [args.shift()]);
  52256. args[0] = self.handleText(args[0], stateManager.state);
  52257. fn = OPS.showText;
  52258. break;
  52259. case OPS.setTextRenderingMode:
  52260. stateManager.state.textRenderingMode = args[0];
  52261. break;
  52262. case OPS.setFillColorSpace:
  52263. stateManager.state.fillColorSpace = ColorSpace.parse(args[0], xref, resources);
  52264. continue;
  52265. case OPS.setStrokeColorSpace:
  52266. stateManager.state.strokeColorSpace = ColorSpace.parse(args[0], xref, resources);
  52267. continue;
  52268. case OPS.setFillColor:
  52269. cs = stateManager.state.fillColorSpace;
  52270. args = cs.getRgb(args, 0);
  52271. fn = OPS.setFillRGBColor;
  52272. break;
  52273. case OPS.setStrokeColor:
  52274. cs = stateManager.state.strokeColorSpace;
  52275. args = cs.getRgb(args, 0);
  52276. fn = OPS.setStrokeRGBColor;
  52277. break;
  52278. case OPS.setFillGray:
  52279. stateManager.state.fillColorSpace = ColorSpace.singletons.gray;
  52280. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52281. fn = OPS.setFillRGBColor;
  52282. break;
  52283. case OPS.setStrokeGray:
  52284. stateManager.state.strokeColorSpace = ColorSpace.singletons.gray;
  52285. args = ColorSpace.singletons.gray.getRgb(args, 0);
  52286. fn = OPS.setStrokeRGBColor;
  52287. break;
  52288. case OPS.setFillCMYKColor:
  52289. stateManager.state.fillColorSpace = ColorSpace.singletons.cmyk;
  52290. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52291. fn = OPS.setFillRGBColor;
  52292. break;
  52293. case OPS.setStrokeCMYKColor:
  52294. stateManager.state.strokeColorSpace = ColorSpace.singletons.cmyk;
  52295. args = ColorSpace.singletons.cmyk.getRgb(args, 0);
  52296. fn = OPS.setStrokeRGBColor;
  52297. break;
  52298. case OPS.setFillRGBColor:
  52299. stateManager.state.fillColorSpace = ColorSpace.singletons.rgb;
  52300. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52301. break;
  52302. case OPS.setStrokeRGBColor:
  52303. stateManager.state.strokeColorSpace = ColorSpace.singletons.rgb;
  52304. args = ColorSpace.singletons.rgb.getRgb(args, 0);
  52305. break;
  52306. case OPS.setFillColorN:
  52307. cs = stateManager.state.fillColorSpace;
  52308. if (cs.name === 'Pattern') {
  52309. next(self.handleColorN(operatorList, OPS.setFillColorN, args, cs, patterns, resources, task, xref));
  52310. return;
  52311. }
  52312. args = cs.getRgb(args, 0);
  52313. fn = OPS.setFillRGBColor;
  52314. break;
  52315. case OPS.setStrokeColorN:
  52316. cs = stateManager.state.strokeColorSpace;
  52317. if (cs.name === 'Pattern') {
  52318. next(self.handleColorN(operatorList, OPS.setStrokeColorN, args, cs, patterns, resources, task, xref));
  52319. return;
  52320. }
  52321. args = cs.getRgb(args, 0);
  52322. fn = OPS.setStrokeRGBColor;
  52323. break;
  52324. case OPS.shadingFill:
  52325. var shadingRes = resources.get('Shading');
  52326. if (!shadingRes) {
  52327. error('No shading resource found');
  52328. }
  52329. var shading = shadingRes.get(args[0].name);
  52330. if (!shading) {
  52331. error('No shading object found');
  52332. }
  52333. var shadingFill = Pattern.parseShading(shading, null, xref, resources, self.handler);
  52334. var patternIR = shadingFill.getIR();
  52335. args = [patternIR];
  52336. fn = OPS.shadingFill;
  52337. break;
  52338. case OPS.setGState:
  52339. var dictName = args[0];
  52340. var extGState = resources.get('ExtGState');
  52341. if (!isDict(extGState) || !extGState.has(dictName.name)) {
  52342. break;
  52343. }
  52344. var gState = extGState.get(dictName.name);
  52345. next(self.setGState(resources, gState, operatorList, task, xref, stateManager));
  52346. return;
  52347. case OPS.moveTo:
  52348. case OPS.lineTo:
  52349. case OPS.curveTo:
  52350. case OPS.curveTo2:
  52351. case OPS.curveTo3:
  52352. case OPS.closePath:
  52353. self.buildPath(operatorList, fn, args);
  52354. continue;
  52355. case OPS.rectangle:
  52356. self.buildPath(operatorList, fn, args);
  52357. continue;
  52358. case OPS.markPoint:
  52359. case OPS.markPointProps:
  52360. case OPS.beginMarkedContent:
  52361. case OPS.beginMarkedContentProps:
  52362. case OPS.endMarkedContent:
  52363. case OPS.beginCompat:
  52364. case OPS.endCompat:
  52365. continue;
  52366. default:
  52367. if (args !== null) {
  52368. for (i = 0, ii = args.length; i < ii; i++) {
  52369. if (args[i] instanceof Dict) {
  52370. break;
  52371. }
  52372. }
  52373. if (i < ii) {
  52374. warn('getOperatorList - ignoring operator: ' + fn);
  52375. continue;
  52376. }
  52377. }
  52378. }
  52379. operatorList.addOp(fn, args);
  52380. }
  52381. if (stop) {
  52382. next(deferred);
  52383. return;
  52384. }
  52385. for (i = 0, ii = preprocessor.savedStatesDepth; i < ii; i++) {
  52386. operatorList.addOp(OPS.restore, []);
  52387. }
  52388. resolve();
  52389. });
  52390. },
  52391. getTextContent: function PartialEvaluator_getTextContent(stream, task, resources, stateManager, normalizeWhitespace, combineTextItems) {
  52392. stateManager = stateManager || new StateManager(new TextState());
  52393. var WhitespaceRegexp = /\s/g;
  52394. var textContent = {
  52395. items: [],
  52396. styles: Object.create(null)
  52397. };
  52398. var textContentItem = {
  52399. initialized: false,
  52400. str: [],
  52401. width: 0,
  52402. height: 0,
  52403. vertical: false,
  52404. lastAdvanceWidth: 0,
  52405. lastAdvanceHeight: 0,
  52406. textAdvanceScale: 0,
  52407. spaceWidth: 0,
  52408. fakeSpaceMin: Infinity,
  52409. fakeMultiSpaceMin: Infinity,
  52410. fakeMultiSpaceMax: -0,
  52411. textRunBreakAllowed: false,
  52412. transform: null,
  52413. fontName: null
  52414. };
  52415. var SPACE_FACTOR = 0.3;
  52416. var MULTI_SPACE_FACTOR = 1.5;
  52417. var MULTI_SPACE_FACTOR_MAX = 4;
  52418. var self = this;
  52419. var xref = this.xref;
  52420. resources = xref.fetchIfRef(resources) || Dict.empty;
  52421. var xobjs = null;
  52422. var xobjsCache = Object.create(null);
  52423. var preprocessor = new EvaluatorPreprocessor(stream, xref, stateManager);
  52424. var textState;
  52425. function ensureTextContentItem() {
  52426. if (textContentItem.initialized) {
  52427. return textContentItem;
  52428. }
  52429. var font = textState.font;
  52430. if (!(font.loadedName in textContent.styles)) {
  52431. textContent.styles[font.loadedName] = {
  52432. fontFamily: font.fallbackName,
  52433. ascent: font.ascent,
  52434. descent: font.descent,
  52435. vertical: font.vertical
  52436. };
  52437. }
  52438. textContentItem.fontName = font.loadedName;
  52439. var tsm = [
  52440. textState.fontSize * textState.textHScale,
  52441. 0,
  52442. 0,
  52443. textState.fontSize,
  52444. 0,
  52445. textState.textRise
  52446. ];
  52447. if (font.isType3Font && textState.fontMatrix !== FONT_IDENTITY_MATRIX && textState.fontSize === 1) {
  52448. var glyphHeight = font.bbox[3] - font.bbox[1];
  52449. if (glyphHeight > 0) {
  52450. glyphHeight = glyphHeight * textState.fontMatrix[3];
  52451. tsm[3] *= glyphHeight;
  52452. }
  52453. }
  52454. var trm = Util.transform(textState.ctm, Util.transform(textState.textMatrix, tsm));
  52455. textContentItem.transform = trm;
  52456. if (!font.vertical) {
  52457. textContentItem.width = 0;
  52458. textContentItem.height = Math.sqrt(trm[2] * trm[2] + trm[3] * trm[3]);
  52459. textContentItem.vertical = false;
  52460. } else {
  52461. textContentItem.width = Math.sqrt(trm[0] * trm[0] + trm[1] * trm[1]);
  52462. textContentItem.height = 0;
  52463. textContentItem.vertical = true;
  52464. }
  52465. var a = textState.textLineMatrix[0];
  52466. var b = textState.textLineMatrix[1];
  52467. var scaleLineX = Math.sqrt(a * a + b * b);
  52468. a = textState.ctm[0];
  52469. b = textState.ctm[1];
  52470. var scaleCtmX = Math.sqrt(a * a + b * b);
  52471. textContentItem.textAdvanceScale = scaleCtmX * scaleLineX;
  52472. textContentItem.lastAdvanceWidth = 0;
  52473. textContentItem.lastAdvanceHeight = 0;
  52474. var spaceWidth = font.spaceWidth / 1000 * textState.fontSize;
  52475. if (spaceWidth) {
  52476. textContentItem.spaceWidth = spaceWidth;
  52477. textContentItem.fakeSpaceMin = spaceWidth * SPACE_FACTOR;
  52478. textContentItem.fakeMultiSpaceMin = spaceWidth * MULTI_SPACE_FACTOR;
  52479. textContentItem.fakeMultiSpaceMax = spaceWidth * MULTI_SPACE_FACTOR_MAX;
  52480. textContentItem.textRunBreakAllowed = !font.isMonospace;
  52481. } else {
  52482. textContentItem.spaceWidth = 0;
  52483. textContentItem.fakeSpaceMin = Infinity;
  52484. textContentItem.fakeMultiSpaceMin = Infinity;
  52485. textContentItem.fakeMultiSpaceMax = 0;
  52486. textContentItem.textRunBreakAllowed = false;
  52487. }
  52488. textContentItem.initialized = true;
  52489. return textContentItem;
  52490. }
  52491. function replaceWhitespace(str) {
  52492. var i = 0, ii = str.length, code;
  52493. while (i < ii && (code = str.charCodeAt(i)) >= 0x20 && code <= 0x7F) {
  52494. i++;
  52495. }
  52496. return i < ii ? str.replace(WhitespaceRegexp, ' ') : str;
  52497. }
  52498. function runBidiTransform(textChunk) {
  52499. var str = textChunk.str.join('');
  52500. var bidiResult = bidi(str, -1, textChunk.vertical);
  52501. return {
  52502. str: normalizeWhitespace ? replaceWhitespace(bidiResult.str) : bidiResult.str,
  52503. dir: bidiResult.dir,
  52504. width: textChunk.width,
  52505. height: textChunk.height,
  52506. transform: textChunk.transform,
  52507. fontName: textChunk.fontName
  52508. };
  52509. }
  52510. function handleSetFont(fontName, fontRef) {
  52511. return self.loadFont(fontName, fontRef, xref, resources).then(function (translated) {
  52512. textState.font = translated.font;
  52513. textState.fontMatrix = translated.font.fontMatrix || FONT_IDENTITY_MATRIX;
  52514. });
  52515. }
  52516. function buildTextContentItem(chars) {
  52517. var font = textState.font;
  52518. var textChunk = ensureTextContentItem();
  52519. var width = 0;
  52520. var height = 0;
  52521. var glyphs = font.charsToGlyphs(chars);
  52522. var defaultVMetrics = font.defaultVMetrics;
  52523. for (var i = 0; i < glyphs.length; i++) {
  52524. var glyph = glyphs[i];
  52525. var vMetricX = null;
  52526. var vMetricY = null;
  52527. var glyphWidth = null;
  52528. if (font.vertical) {
  52529. if (glyph.vmetric) {
  52530. glyphWidth = glyph.vmetric[0];
  52531. vMetricX = glyph.vmetric[1];
  52532. vMetricY = glyph.vmetric[2];
  52533. } else {
  52534. glyphWidth = glyph.width;
  52535. vMetricX = glyph.width * 0.5;
  52536. vMetricY = defaultVMetrics[2];
  52537. }
  52538. } else {
  52539. glyphWidth = glyph.width;
  52540. }
  52541. var glyphUnicode = glyph.unicode;
  52542. var NormalizedUnicodes = getNormalizedUnicodes();
  52543. if (NormalizedUnicodes[glyphUnicode] !== undefined) {
  52544. glyphUnicode = NormalizedUnicodes[glyphUnicode];
  52545. }
  52546. glyphUnicode = reverseIfRtl(glyphUnicode);
  52547. var charSpacing = textState.charSpacing;
  52548. if (glyph.isSpace) {
  52549. var wordSpacing = textState.wordSpacing;
  52550. charSpacing += wordSpacing;
  52551. if (wordSpacing > 0) {
  52552. addFakeSpaces(wordSpacing, textChunk.str);
  52553. }
  52554. }
  52555. var tx = 0;
  52556. var ty = 0;
  52557. if (!font.vertical) {
  52558. var w0 = glyphWidth * textState.fontMatrix[0];
  52559. tx = (w0 * textState.fontSize + charSpacing) * textState.textHScale;
  52560. width += tx;
  52561. } else {
  52562. var w1 = glyphWidth * textState.fontMatrix[0];
  52563. ty = w1 * textState.fontSize + charSpacing;
  52564. height += ty;
  52565. }
  52566. textState.translateTextMatrix(tx, ty);
  52567. textChunk.str.push(glyphUnicode);
  52568. }
  52569. if (!font.vertical) {
  52570. textChunk.lastAdvanceWidth = width;
  52571. textChunk.width += width * textChunk.textAdvanceScale;
  52572. } else {
  52573. textChunk.lastAdvanceHeight = height;
  52574. textChunk.height += Math.abs(height * textChunk.textAdvanceScale);
  52575. }
  52576. return textChunk;
  52577. }
  52578. function addFakeSpaces(width, strBuf) {
  52579. if (width < textContentItem.fakeSpaceMin) {
  52580. return;
  52581. }
  52582. if (width < textContentItem.fakeMultiSpaceMin) {
  52583. strBuf.push(' ');
  52584. return;
  52585. }
  52586. var fakeSpaces = Math.round(width / textContentItem.spaceWidth);
  52587. while (fakeSpaces-- > 0) {
  52588. strBuf.push(' ');
  52589. }
  52590. }
  52591. function flushTextContentItem() {
  52592. if (!textContentItem.initialized) {
  52593. return;
  52594. }
  52595. textContent.items.push(runBidiTransform(textContentItem));
  52596. textContentItem.initialized = false;
  52597. textContentItem.str.length = 0;
  52598. }
  52599. var timeSlotManager = new TimeSlotManager();
  52600. return new Promise(function promiseBody(resolve, reject) {
  52601. var next = function (promise) {
  52602. promise.then(function () {
  52603. try {
  52604. promiseBody(resolve, reject);
  52605. } catch (ex) {
  52606. reject(ex);
  52607. }
  52608. }, reject);
  52609. };
  52610. task.ensureNotTerminated();
  52611. timeSlotManager.reset();
  52612. var stop, operation = {}, args = [];
  52613. while (!(stop = timeSlotManager.check())) {
  52614. args.length = 0;
  52615. operation.args = args;
  52616. if (!preprocessor.read(operation)) {
  52617. break;
  52618. }
  52619. textState = stateManager.state;
  52620. var fn = operation.fn;
  52621. args = operation.args;
  52622. var advance, diff;
  52623. switch (fn | 0) {
  52624. case OPS.setFont:
  52625. var fontNameArg = args[0].name, fontSizeArg = args[1];
  52626. if (textState.font && fontNameArg === textState.fontName && fontSizeArg === textState.fontSize) {
  52627. break;
  52628. }
  52629. flushTextContentItem();
  52630. textState.fontName = fontNameArg;
  52631. textState.fontSize = fontSizeArg;
  52632. next(handleSetFont(fontNameArg, null));
  52633. return;
  52634. case OPS.setTextRise:
  52635. flushTextContentItem();
  52636. textState.textRise = args[0];
  52637. break;
  52638. case OPS.setHScale:
  52639. flushTextContentItem();
  52640. textState.textHScale = args[0] / 100;
  52641. break;
  52642. case OPS.setLeading:
  52643. flushTextContentItem();
  52644. textState.leading = args[0];
  52645. break;
  52646. case OPS.moveText:
  52647. var isSameTextLine = !textState.font ? false : (textState.font.vertical ? args[0] : args[1]) === 0;
  52648. advance = args[0] - args[1];
  52649. if (combineTextItems && isSameTextLine && textContentItem.initialized && advance > 0 && advance <= textContentItem.fakeMultiSpaceMax) {
  52650. textState.translateTextLineMatrix(args[0], args[1]);
  52651. textContentItem.width += args[0] - textContentItem.lastAdvanceWidth;
  52652. textContentItem.height += args[1] - textContentItem.lastAdvanceHeight;
  52653. diff = args[0] - textContentItem.lastAdvanceWidth - (args[1] - textContentItem.lastAdvanceHeight);
  52654. addFakeSpaces(diff, textContentItem.str);
  52655. break;
  52656. }
  52657. flushTextContentItem();
  52658. textState.translateTextLineMatrix(args[0], args[1]);
  52659. textState.textMatrix = textState.textLineMatrix.slice();
  52660. break;
  52661. case OPS.setLeadingMoveText:
  52662. flushTextContentItem();
  52663. textState.leading = -args[1];
  52664. textState.translateTextLineMatrix(args[0], args[1]);
  52665. textState.textMatrix = textState.textLineMatrix.slice();
  52666. break;
  52667. case OPS.nextLine:
  52668. flushTextContentItem();
  52669. textState.carriageReturn();
  52670. break;
  52671. case OPS.setTextMatrix:
  52672. advance = textState.calcTextLineMatrixAdvance(args[0], args[1], args[2], args[3], args[4], args[5]);
  52673. if (combineTextItems && advance !== null && textContentItem.initialized && advance.value > 0 && advance.value <= textContentItem.fakeMultiSpaceMax) {
  52674. textState.translateTextLineMatrix(advance.width, advance.height);
  52675. textContentItem.width += advance.width - textContentItem.lastAdvanceWidth;
  52676. textContentItem.height += advance.height - textContentItem.lastAdvanceHeight;
  52677. diff = advance.width - textContentItem.lastAdvanceWidth - (advance.height - textContentItem.lastAdvanceHeight);
  52678. addFakeSpaces(diff, textContentItem.str);
  52679. break;
  52680. }
  52681. flushTextContentItem();
  52682. textState.setTextMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52683. textState.setTextLineMatrix(args[0], args[1], args[2], args[3], args[4], args[5]);
  52684. break;
  52685. case OPS.setCharSpacing:
  52686. textState.charSpacing = args[0];
  52687. break;
  52688. case OPS.setWordSpacing:
  52689. textState.wordSpacing = args[0];
  52690. break;
  52691. case OPS.beginText:
  52692. flushTextContentItem();
  52693. textState.textMatrix = IDENTITY_MATRIX.slice();
  52694. textState.textLineMatrix = IDENTITY_MATRIX.slice();
  52695. break;
  52696. case OPS.showSpacedText:
  52697. var items = args[0];
  52698. var offset;
  52699. for (var j = 0, jj = items.length; j < jj; j++) {
  52700. if (typeof items[j] === 'string') {
  52701. buildTextContentItem(items[j]);
  52702. } else if (isNum(items[j])) {
  52703. ensureTextContentItem();
  52704. advance = items[j] * textState.fontSize / 1000;
  52705. var breakTextRun = false;
  52706. if (textState.font.vertical) {
  52707. offset = advance * (textState.textHScale * textState.textMatrix[2] + textState.textMatrix[3]);
  52708. textState.translateTextMatrix(0, advance);
  52709. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52710. if (!breakTextRun) {
  52711. textContentItem.height += offset;
  52712. }
  52713. } else {
  52714. advance = -advance;
  52715. offset = advance * (textState.textHScale * textState.textMatrix[0] + textState.textMatrix[1]);
  52716. textState.translateTextMatrix(advance, 0);
  52717. breakTextRun = textContentItem.textRunBreakAllowed && advance > textContentItem.fakeMultiSpaceMax;
  52718. if (!breakTextRun) {
  52719. textContentItem.width += offset;
  52720. }
  52721. }
  52722. if (breakTextRun) {
  52723. flushTextContentItem();
  52724. } else if (advance > 0) {
  52725. addFakeSpaces(advance, textContentItem.str);
  52726. }
  52727. }
  52728. }
  52729. break;
  52730. case OPS.showText:
  52731. buildTextContentItem(args[0]);
  52732. break;
  52733. case OPS.nextLineShowText:
  52734. flushTextContentItem();
  52735. textState.carriageReturn();
  52736. buildTextContentItem(args[0]);
  52737. break;
  52738. case OPS.nextLineSetSpacingShowText:
  52739. flushTextContentItem();
  52740. textState.wordSpacing = args[0];
  52741. textState.charSpacing = args[1];
  52742. textState.carriageReturn();
  52743. buildTextContentItem(args[2]);
  52744. break;
  52745. case OPS.paintXObject:
  52746. flushTextContentItem();
  52747. if (args[0].code) {
  52748. break;
  52749. }
  52750. if (!xobjs) {
  52751. xobjs = resources.get('XObject') || Dict.empty;
  52752. }
  52753. var name = args[0].name;
  52754. if (xobjsCache.key === name) {
  52755. if (xobjsCache.texts) {
  52756. Util.appendToArray(textContent.items, xobjsCache.texts.items);
  52757. Util.extendObj(textContent.styles, xobjsCache.texts.styles);
  52758. }
  52759. break;
  52760. }
  52761. var xobj = xobjs.get(name);
  52762. if (!xobj) {
  52763. break;
  52764. }
  52765. assert(isStream(xobj), 'XObject should be a stream');
  52766. var type = xobj.dict.get('Subtype');
  52767. assert(isName(type), 'XObject should have a Name subtype');
  52768. if ('Form' !== type.name) {
  52769. xobjsCache.key = name;
  52770. xobjsCache.texts = null;
  52771. break;
  52772. }
  52773. stateManager.save();
  52774. var matrix = xobj.dict.getArray('Matrix');
  52775. if (isArray(matrix) && matrix.length === 6) {
  52776. stateManager.transform(matrix);
  52777. }
  52778. next(self.getTextContent(xobj, task, xobj.dict.get('Resources') || resources, stateManager, normalizeWhitespace, combineTextItems).then(function (formTextContent) {
  52779. Util.appendToArray(textContent.items, formTextContent.items);
  52780. Util.extendObj(textContent.styles, formTextContent.styles);
  52781. stateManager.restore();
  52782. xobjsCache.key = name;
  52783. xobjsCache.texts = formTextContent;
  52784. }));
  52785. return;
  52786. case OPS.setGState:
  52787. flushTextContentItem();
  52788. var dictName = args[0];
  52789. var extGState = resources.get('ExtGState');
  52790. if (!isDict(extGState) || !isName(dictName)) {
  52791. break;
  52792. }
  52793. var gState = extGState.get(dictName.name);
  52794. if (!isDict(gState)) {
  52795. break;
  52796. }
  52797. var gStateFont = gState.get('Font');
  52798. if (gStateFont) {
  52799. textState.fontName = null;
  52800. textState.fontSize = gStateFont[1];
  52801. next(handleSetFont(null, gStateFont[0]));
  52802. return;
  52803. }
  52804. break;
  52805. }
  52806. }
  52807. if (stop) {
  52808. next(deferred);
  52809. return;
  52810. }
  52811. flushTextContentItem();
  52812. resolve(textContent);
  52813. });
  52814. },
  52815. extractDataStructures: function PartialEvaluator_extractDataStructures(dict, baseDict, xref, properties) {
  52816. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  52817. var toUnicodePromise = toUnicode ? this.readToUnicode(toUnicode) : Promise.resolve(undefined);
  52818. if (properties.composite) {
  52819. var cidSystemInfo = dict.get('CIDSystemInfo');
  52820. if (isDict(cidSystemInfo)) {
  52821. properties.cidSystemInfo = {
  52822. registry: cidSystemInfo.get('Registry'),
  52823. ordering: cidSystemInfo.get('Ordering'),
  52824. supplement: cidSystemInfo.get('Supplement')
  52825. };
  52826. }
  52827. var cidToGidMap = dict.get('CIDToGIDMap');
  52828. if (isStream(cidToGidMap)) {
  52829. properties.cidToGidMap = this.readCidToGidMap(cidToGidMap);
  52830. }
  52831. }
  52832. var differences = [];
  52833. var baseEncodingName = null;
  52834. var encoding;
  52835. if (dict.has('Encoding')) {
  52836. encoding = dict.get('Encoding');
  52837. if (isDict(encoding)) {
  52838. baseEncodingName = encoding.get('BaseEncoding');
  52839. baseEncodingName = isName(baseEncodingName) ? baseEncodingName.name : null;
  52840. if (encoding.has('Differences')) {
  52841. var diffEncoding = encoding.get('Differences');
  52842. var index = 0;
  52843. for (var j = 0, jj = diffEncoding.length; j < jj; j++) {
  52844. var data = xref.fetchIfRef(diffEncoding[j]);
  52845. if (isNum(data)) {
  52846. index = data;
  52847. } else if (isName(data)) {
  52848. differences[index++] = data.name;
  52849. } else {
  52850. error('Invalid entry in \'Differences\' array: ' + data);
  52851. }
  52852. }
  52853. }
  52854. } else if (isName(encoding)) {
  52855. baseEncodingName = encoding.name;
  52856. } else {
  52857. error('Encoding is not a Name nor a Dict');
  52858. }
  52859. if (baseEncodingName !== 'MacRomanEncoding' && baseEncodingName !== 'MacExpertEncoding' && baseEncodingName !== 'WinAnsiEncoding') {
  52860. baseEncodingName = null;
  52861. }
  52862. }
  52863. if (baseEncodingName) {
  52864. properties.defaultEncoding = getEncoding(baseEncodingName).slice();
  52865. } else {
  52866. var isSymbolicFont = !!(properties.flags & FontFlags.Symbolic);
  52867. var isNonsymbolicFont = !!(properties.flags & FontFlags.Nonsymbolic);
  52868. encoding = StandardEncoding;
  52869. if (properties.type === 'TrueType' && !isNonsymbolicFont) {
  52870. encoding = WinAnsiEncoding;
  52871. }
  52872. if (isSymbolicFont) {
  52873. encoding = MacRomanEncoding;
  52874. if (!properties.file) {
  52875. if (/Symbol/i.test(properties.name)) {
  52876. encoding = SymbolSetEncoding;
  52877. } else if (/Dingbats/i.test(properties.name)) {
  52878. encoding = ZapfDingbatsEncoding;
  52879. }
  52880. }
  52881. }
  52882. properties.defaultEncoding = encoding;
  52883. }
  52884. properties.differences = differences;
  52885. properties.baseEncodingName = baseEncodingName;
  52886. properties.hasEncoding = !!baseEncodingName || differences.length > 0;
  52887. properties.dict = dict;
  52888. return toUnicodePromise.then(function (toUnicode) {
  52889. properties.toUnicode = toUnicode;
  52890. return this.buildToUnicode(properties);
  52891. }.bind(this)).then(function (toUnicode) {
  52892. properties.toUnicode = toUnicode;
  52893. return properties;
  52894. });
  52895. },
  52896. buildToUnicode: function PartialEvaluator_buildToUnicode(properties) {
  52897. properties.hasIncludedToUnicodeMap = !!properties.toUnicode && properties.toUnicode.length > 0;
  52898. if (properties.hasIncludedToUnicodeMap) {
  52899. return Promise.resolve(properties.toUnicode);
  52900. }
  52901. var toUnicode, charcode, glyphName;
  52902. if (!properties.composite)
  52903. {
  52904. toUnicode = [];
  52905. var encoding = properties.defaultEncoding.slice();
  52906. var baseEncodingName = properties.baseEncodingName;
  52907. var differences = properties.differences;
  52908. for (charcode in differences) {
  52909. glyphName = differences[charcode];
  52910. if (glyphName === '.notdef') {
  52911. continue;
  52912. }
  52913. encoding[charcode] = glyphName;
  52914. }
  52915. var glyphsUnicodeMap = getGlyphsUnicode();
  52916. for (charcode in encoding) {
  52917. glyphName = encoding[charcode];
  52918. if (glyphName === '') {
  52919. continue;
  52920. } else if (glyphsUnicodeMap[glyphName] === undefined) {
  52921. var code = 0;
  52922. switch (glyphName[0]) {
  52923. case 'G':
  52924. if (glyphName.length === 3) {
  52925. code = parseInt(glyphName.substr(1), 16);
  52926. }
  52927. break;
  52928. case 'g':
  52929. if (glyphName.length === 5) {
  52930. code = parseInt(glyphName.substr(1), 16);
  52931. }
  52932. break;
  52933. case 'C':
  52934. case 'c':
  52935. if (glyphName.length >= 3) {
  52936. code = +glyphName.substr(1);
  52937. }
  52938. break;
  52939. default:
  52940. var unicode = getUnicodeForGlyph(glyphName, glyphsUnicodeMap);
  52941. if (unicode !== -1) {
  52942. code = unicode;
  52943. }
  52944. }
  52945. if (code) {
  52946. if (baseEncodingName && code === +charcode) {
  52947. var baseEncoding = getEncoding(baseEncodingName);
  52948. if (baseEncoding && (glyphName = baseEncoding[charcode])) {
  52949. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52950. continue;
  52951. }
  52952. }
  52953. toUnicode[charcode] = String.fromCharCode(code);
  52954. }
  52955. continue;
  52956. }
  52957. toUnicode[charcode] = String.fromCharCode(glyphsUnicodeMap[glyphName]);
  52958. }
  52959. return Promise.resolve(new ToUnicodeMap(toUnicode));
  52960. }
  52961. 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'))) {
  52962. var registry = properties.cidSystemInfo.registry;
  52963. var ordering = properties.cidSystemInfo.ordering;
  52964. var ucs2CMapName = Name.get(registry + '-' + ordering + '-UCS2');
  52965. return CMapFactory.create(ucs2CMapName, this.options.cMapOptions, null).then(function (ucs2CMap) {
  52966. var cMap = properties.cMap;
  52967. toUnicode = [];
  52968. cMap.forEach(function (charcode, cid) {
  52969. assert(cid <= 0xffff, 'Max size of CID is 65,535');
  52970. var ucs2 = ucs2CMap.lookup(cid);
  52971. if (ucs2) {
  52972. toUnicode[charcode] = String.fromCharCode((ucs2.charCodeAt(0) << 8) + ucs2.charCodeAt(1));
  52973. }
  52974. });
  52975. return new ToUnicodeMap(toUnicode);
  52976. });
  52977. }
  52978. return Promise.resolve(new IdentityToUnicodeMap(properties.firstChar, properties.lastChar));
  52979. },
  52980. readToUnicode: function PartialEvaluator_readToUnicode(toUnicode) {
  52981. var cmapObj = toUnicode;
  52982. if (isName(cmapObj)) {
  52983. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  52984. if (cmap instanceof IdentityCMap) {
  52985. return new IdentityToUnicodeMap(0, 0xFFFF);
  52986. }
  52987. return new ToUnicodeMap(cmap.getMap());
  52988. });
  52989. } else if (isStream(cmapObj)) {
  52990. return CMapFactory.create(cmapObj, this.options.cMapOptions, null).then(function (cmap) {
  52991. if (cmap instanceof IdentityCMap) {
  52992. return new IdentityToUnicodeMap(0, 0xFFFF);
  52993. }
  52994. var map = new Array(cmap.length);
  52995. cmap.forEach(function (charCode, token) {
  52996. var str = [];
  52997. for (var k = 0; k < token.length; k += 2) {
  52998. var w1 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  52999. if ((w1 & 0xF800) !== 0xD800) {
  53000. str.push(w1);
  53001. continue;
  53002. }
  53003. k += 2;
  53004. var w2 = token.charCodeAt(k) << 8 | token.charCodeAt(k + 1);
  53005. str.push(((w1 & 0x3ff) << 10) + (w2 & 0x3ff) + 0x10000);
  53006. }
  53007. map[charCode] = String.fromCharCode.apply(String, str);
  53008. });
  53009. return new ToUnicodeMap(map);
  53010. });
  53011. }
  53012. return Promise.resolve(null);
  53013. },
  53014. readCidToGidMap: function PartialEvaluator_readCidToGidMap(cidToGidStream) {
  53015. var glyphsData = cidToGidStream.getBytes();
  53016. var result = [];
  53017. for (var j = 0, jj = glyphsData.length; j < jj; j++) {
  53018. var glyphID = glyphsData[j++] << 8 | glyphsData[j];
  53019. if (glyphID === 0) {
  53020. continue;
  53021. }
  53022. var code = j >> 1;
  53023. result[code] = glyphID;
  53024. }
  53025. return result;
  53026. },
  53027. extractWidths: function PartialEvaluator_extractWidths(dict, xref, descriptor, properties) {
  53028. var glyphsWidths = [];
  53029. var defaultWidth = 0;
  53030. var glyphsVMetrics = [];
  53031. var defaultVMetrics;
  53032. var i, ii, j, jj, start, code, widths;
  53033. if (properties.composite) {
  53034. defaultWidth = dict.get('DW') || 1000;
  53035. widths = dict.get('W');
  53036. if (widths) {
  53037. for (i = 0, ii = widths.length; i < ii; i++) {
  53038. start = xref.fetchIfRef(widths[i++]);
  53039. code = xref.fetchIfRef(widths[i]);
  53040. if (isArray(code)) {
  53041. for (j = 0, jj = code.length; j < jj; j++) {
  53042. glyphsWidths[start++] = xref.fetchIfRef(code[j]);
  53043. }
  53044. } else {
  53045. var width = xref.fetchIfRef(widths[++i]);
  53046. for (j = start; j <= code; j++) {
  53047. glyphsWidths[j] = width;
  53048. }
  53049. }
  53050. }
  53051. }
  53052. if (properties.vertical) {
  53053. var vmetrics = dict.getArray('DW2') || [
  53054. 880,
  53055. -1000
  53056. ];
  53057. defaultVMetrics = [
  53058. vmetrics[1],
  53059. defaultWidth * 0.5,
  53060. vmetrics[0]
  53061. ];
  53062. vmetrics = dict.get('W2');
  53063. if (vmetrics) {
  53064. for (i = 0, ii = vmetrics.length; i < ii; i++) {
  53065. start = xref.fetchIfRef(vmetrics[i++]);
  53066. code = xref.fetchIfRef(vmetrics[i]);
  53067. if (isArray(code)) {
  53068. for (j = 0, jj = code.length; j < jj; j++) {
  53069. glyphsVMetrics[start++] = [
  53070. xref.fetchIfRef(code[j++]),
  53071. xref.fetchIfRef(code[j++]),
  53072. xref.fetchIfRef(code[j])
  53073. ];
  53074. }
  53075. } else {
  53076. var vmetric = [
  53077. xref.fetchIfRef(vmetrics[++i]),
  53078. xref.fetchIfRef(vmetrics[++i]),
  53079. xref.fetchIfRef(vmetrics[++i])
  53080. ];
  53081. for (j = start; j <= code; j++) {
  53082. glyphsVMetrics[j] = vmetric;
  53083. }
  53084. }
  53085. }
  53086. }
  53087. }
  53088. } else {
  53089. var firstChar = properties.firstChar;
  53090. widths = dict.get('Widths');
  53091. if (widths) {
  53092. j = firstChar;
  53093. for (i = 0, ii = widths.length; i < ii; i++) {
  53094. glyphsWidths[j++] = xref.fetchIfRef(widths[i]);
  53095. }
  53096. defaultWidth = parseFloat(descriptor.get('MissingWidth')) || 0;
  53097. } else {
  53098. var baseFontName = dict.get('BaseFont');
  53099. if (isName(baseFontName)) {
  53100. var metrics = this.getBaseFontMetrics(baseFontName.name);
  53101. glyphsWidths = this.buildCharCodeToWidth(metrics.widths, properties);
  53102. defaultWidth = metrics.defaultWidth;
  53103. }
  53104. }
  53105. }
  53106. var isMonospace = true;
  53107. var firstWidth = defaultWidth;
  53108. for (var glyph in glyphsWidths) {
  53109. var glyphWidth = glyphsWidths[glyph];
  53110. if (!glyphWidth) {
  53111. continue;
  53112. }
  53113. if (!firstWidth) {
  53114. firstWidth = glyphWidth;
  53115. continue;
  53116. }
  53117. if (firstWidth !== glyphWidth) {
  53118. isMonospace = false;
  53119. break;
  53120. }
  53121. }
  53122. if (isMonospace) {
  53123. properties.flags |= FontFlags.FixedPitch;
  53124. }
  53125. properties.defaultWidth = defaultWidth;
  53126. properties.widths = glyphsWidths;
  53127. properties.defaultVMetrics = defaultVMetrics;
  53128. properties.vmetrics = glyphsVMetrics;
  53129. },
  53130. isSerifFont: function PartialEvaluator_isSerifFont(baseFontName) {
  53131. var fontNameWoStyle = baseFontName.split('-')[0];
  53132. return fontNameWoStyle in getSerifFonts() || fontNameWoStyle.search(/serif/gi) !== -1;
  53133. },
  53134. getBaseFontMetrics: function PartialEvaluator_getBaseFontMetrics(name) {
  53135. var defaultWidth = 0;
  53136. var widths = [];
  53137. var monospace = false;
  53138. var stdFontMap = getStdFontMap();
  53139. var lookupName = stdFontMap[name] || name;
  53140. var Metrics = getMetrics();
  53141. if (!(lookupName in Metrics)) {
  53142. if (this.isSerifFont(name)) {
  53143. lookupName = 'Times-Roman';
  53144. } else {
  53145. lookupName = 'Helvetica';
  53146. }
  53147. }
  53148. var glyphWidths = Metrics[lookupName];
  53149. if (isNum(glyphWidths)) {
  53150. defaultWidth = glyphWidths;
  53151. monospace = true;
  53152. } else {
  53153. widths = glyphWidths();
  53154. }
  53155. return {
  53156. defaultWidth: defaultWidth,
  53157. monospace: monospace,
  53158. widths: widths
  53159. };
  53160. },
  53161. buildCharCodeToWidth: function PartialEvaluator_bulildCharCodeToWidth(widthsByGlyphName, properties) {
  53162. var widths = Object.create(null);
  53163. var differences = properties.differences;
  53164. var encoding = properties.defaultEncoding;
  53165. for (var charCode = 0; charCode < 256; charCode++) {
  53166. if (charCode in differences && widthsByGlyphName[differences[charCode]]) {
  53167. widths[charCode] = widthsByGlyphName[differences[charCode]];
  53168. continue;
  53169. }
  53170. if (charCode in encoding && widthsByGlyphName[encoding[charCode]]) {
  53171. widths[charCode] = widthsByGlyphName[encoding[charCode]];
  53172. continue;
  53173. }
  53174. }
  53175. return widths;
  53176. },
  53177. preEvaluateFont: function PartialEvaluator_preEvaluateFont(dict, xref) {
  53178. var baseDict = dict;
  53179. var type = dict.get('Subtype');
  53180. assert(isName(type), 'invalid font Subtype');
  53181. var composite = false;
  53182. var uint8array;
  53183. if (type.name === 'Type0') {
  53184. var df = dict.get('DescendantFonts');
  53185. if (!df) {
  53186. error('Descendant fonts are not specified');
  53187. }
  53188. dict = isArray(df) ? xref.fetchIfRef(df[0]) : df;
  53189. type = dict.get('Subtype');
  53190. assert(isName(type), 'invalid font Subtype');
  53191. composite = true;
  53192. }
  53193. var descriptor = dict.get('FontDescriptor');
  53194. if (descriptor) {
  53195. var hash = new MurmurHash3_64();
  53196. var encoding = baseDict.getRaw('Encoding');
  53197. if (isName(encoding)) {
  53198. hash.update(encoding.name);
  53199. } else if (isRef(encoding)) {
  53200. hash.update(encoding.toString());
  53201. } else if (isDict(encoding)) {
  53202. var keys = encoding.getKeys();
  53203. for (var i = 0, ii = keys.length; i < ii; i++) {
  53204. var entry = encoding.getRaw(keys[i]);
  53205. if (isName(entry)) {
  53206. hash.update(entry.name);
  53207. } else if (isRef(entry)) {
  53208. hash.update(entry.toString());
  53209. } else if (isArray(entry)) {
  53210. hash.update(entry.length.toString());
  53211. }
  53212. }
  53213. }
  53214. var toUnicode = dict.get('ToUnicode') || baseDict.get('ToUnicode');
  53215. if (isStream(toUnicode)) {
  53216. var stream = toUnicode.str || toUnicode;
  53217. uint8array = stream.buffer ? new Uint8Array(stream.buffer.buffer, 0, stream.bufferLength) : new Uint8Array(stream.bytes.buffer, stream.start, stream.end - stream.start);
  53218. hash.update(uint8array);
  53219. } else if (isName(toUnicode)) {
  53220. hash.update(toUnicode.name);
  53221. }
  53222. var widths = dict.get('Widths') || baseDict.get('Widths');
  53223. if (widths) {
  53224. uint8array = new Uint8Array(new Uint32Array(widths).buffer);
  53225. hash.update(uint8array);
  53226. }
  53227. }
  53228. return {
  53229. descriptor: descriptor,
  53230. dict: dict,
  53231. baseDict: baseDict,
  53232. composite: composite,
  53233. type: type.name,
  53234. hash: hash ? hash.hexdigest() : ''
  53235. };
  53236. },
  53237. translateFont: function PartialEvaluator_translateFont(preEvaluatedFont, xref) {
  53238. var baseDict = preEvaluatedFont.baseDict;
  53239. var dict = preEvaluatedFont.dict;
  53240. var composite = preEvaluatedFont.composite;
  53241. var descriptor = preEvaluatedFont.descriptor;
  53242. var type = preEvaluatedFont.type;
  53243. var maxCharIndex = composite ? 0xFFFF : 0xFF;
  53244. var cMapOptions = this.options.cMapOptions;
  53245. var properties;
  53246. if (!descriptor) {
  53247. if (type === 'Type3') {
  53248. descriptor = new Dict(null);
  53249. descriptor.set('FontName', Name.get(type));
  53250. descriptor.set('FontBBox', dict.getArray('FontBBox'));
  53251. } else {
  53252. var baseFontName = dict.get('BaseFont');
  53253. if (!isName(baseFontName)) {
  53254. error('Base font is not specified');
  53255. }
  53256. baseFontName = baseFontName.name.replace(/[,_]/g, '-');
  53257. var metrics = this.getBaseFontMetrics(baseFontName);
  53258. var fontNameWoStyle = baseFontName.split('-')[0];
  53259. var flags = (this.isSerifFont(fontNameWoStyle) ? FontFlags.Serif : 0) | (metrics.monospace ? FontFlags.FixedPitch : 0) | (getSymbolsFonts()[fontNameWoStyle] ? FontFlags.Symbolic : FontFlags.Nonsymbolic);
  53260. properties = {
  53261. type: type,
  53262. name: baseFontName,
  53263. widths: metrics.widths,
  53264. defaultWidth: metrics.defaultWidth,
  53265. flags: flags,
  53266. firstChar: 0,
  53267. lastChar: maxCharIndex
  53268. };
  53269. return this.extractDataStructures(dict, dict, xref, properties).then(function (properties) {
  53270. properties.widths = this.buildCharCodeToWidth(metrics.widths, properties);
  53271. return new Font(baseFontName, null, properties);
  53272. }.bind(this));
  53273. }
  53274. }
  53275. var firstChar = dict.get('FirstChar') || 0;
  53276. var lastChar = dict.get('LastChar') || maxCharIndex;
  53277. var fontName = descriptor.get('FontName');
  53278. var baseFont = dict.get('BaseFont');
  53279. if (isString(fontName)) {
  53280. fontName = Name.get(fontName);
  53281. }
  53282. if (isString(baseFont)) {
  53283. baseFont = Name.get(baseFont);
  53284. }
  53285. if (type !== 'Type3') {
  53286. var fontNameStr = fontName && fontName.name;
  53287. var baseFontStr = baseFont && baseFont.name;
  53288. if (fontNameStr !== baseFontStr) {
  53289. info('The FontDescriptor\'s FontName is "' + fontNameStr + '" but should be the same as the Font\'s BaseFont "' + baseFontStr + '"');
  53290. if (fontNameStr && baseFontStr && baseFontStr.indexOf(fontNameStr) === 0) {
  53291. fontName = baseFont;
  53292. }
  53293. }
  53294. }
  53295. fontName = fontName || baseFont;
  53296. assert(isName(fontName), 'invalid font name');
  53297. var fontFile = descriptor.get('FontFile', 'FontFile2', 'FontFile3');
  53298. if (fontFile) {
  53299. if (fontFile.dict) {
  53300. var subtype = fontFile.dict.get('Subtype');
  53301. if (subtype) {
  53302. subtype = subtype.name;
  53303. }
  53304. var length1 = fontFile.dict.get('Length1');
  53305. var length2 = fontFile.dict.get('Length2');
  53306. var length3 = fontFile.dict.get('Length3');
  53307. }
  53308. }
  53309. properties = {
  53310. type: type,
  53311. name: fontName.name,
  53312. subtype: subtype,
  53313. file: fontFile,
  53314. length1: length1,
  53315. length2: length2,
  53316. length3: length3,
  53317. loadedName: baseDict.loadedName,
  53318. composite: composite,
  53319. wideChars: composite,
  53320. fixedPitch: false,
  53321. fontMatrix: dict.getArray('FontMatrix') || FONT_IDENTITY_MATRIX,
  53322. firstChar: firstChar || 0,
  53323. lastChar: lastChar || maxCharIndex,
  53324. bbox: descriptor.getArray('FontBBox'),
  53325. ascent: descriptor.get('Ascent'),
  53326. descent: descriptor.get('Descent'),
  53327. xHeight: descriptor.get('XHeight'),
  53328. capHeight: descriptor.get('CapHeight'),
  53329. flags: descriptor.get('Flags'),
  53330. italicAngle: descriptor.get('ItalicAngle'),
  53331. coded: false
  53332. };
  53333. var cMapPromise;
  53334. if (composite) {
  53335. var cidEncoding = baseDict.get('Encoding');
  53336. if (isName(cidEncoding)) {
  53337. properties.cidEncoding = cidEncoding.name;
  53338. }
  53339. cMapPromise = CMapFactory.create(cidEncoding, cMapOptions, null).then(function (cMap) {
  53340. properties.cMap = cMap;
  53341. properties.vertical = properties.cMap.vertical;
  53342. });
  53343. } else {
  53344. cMapPromise = Promise.resolve(undefined);
  53345. }
  53346. return cMapPromise.then(function () {
  53347. return this.extractDataStructures(dict, baseDict, xref, properties);
  53348. }.bind(this)).then(function (properties) {
  53349. this.extractWidths(dict, xref, descriptor, properties);
  53350. if (type === 'Type3') {
  53351. properties.isType3Font = true;
  53352. }
  53353. return new Font(fontName.name, fontFile, properties);
  53354. }.bind(this));
  53355. }
  53356. };
  53357. return PartialEvaluator;
  53358. }();
  53359. var TranslatedFont = function TranslatedFontClosure() {
  53360. function TranslatedFont(loadedName, font, dict) {
  53361. this.loadedName = loadedName;
  53362. this.font = font;
  53363. this.dict = dict;
  53364. this.type3Loaded = null;
  53365. this.sent = false;
  53366. }
  53367. TranslatedFont.prototype = {
  53368. send: function (handler) {
  53369. if (this.sent) {
  53370. return;
  53371. }
  53372. var fontData = this.font.exportData();
  53373. handler.send('commonobj', [
  53374. this.loadedName,
  53375. 'Font',
  53376. fontData
  53377. ]);
  53378. this.sent = true;
  53379. },
  53380. loadType3Data: function (evaluator, resources, parentOperatorList, task) {
  53381. assert(this.font.isType3Font);
  53382. if (this.type3Loaded) {
  53383. return this.type3Loaded;
  53384. }
  53385. var translatedFont = this.font;
  53386. var loadCharProcsPromise = Promise.resolve();
  53387. var charProcs = this.dict.get('CharProcs');
  53388. var fontResources = this.dict.get('Resources') || resources;
  53389. var charProcKeys = charProcs.getKeys();
  53390. var charProcOperatorList = Object.create(null);
  53391. for (var i = 0, n = charProcKeys.length; i < n; ++i) {
  53392. loadCharProcsPromise = loadCharProcsPromise.then(function (key) {
  53393. var glyphStream = charProcs.get(key);
  53394. var operatorList = new OperatorList();
  53395. return evaluator.getOperatorList(glyphStream, task, fontResources, operatorList).then(function () {
  53396. charProcOperatorList[key] = operatorList.getIR();
  53397. parentOperatorList.addDependencies(operatorList.dependencies);
  53398. }, function (reason) {
  53399. warn('Type3 font resource \"' + key + '\" is not available');
  53400. var operatorList = new OperatorList();
  53401. charProcOperatorList[key] = operatorList.getIR();
  53402. });
  53403. }.bind(this, charProcKeys[i]));
  53404. }
  53405. this.type3Loaded = loadCharProcsPromise.then(function () {
  53406. translatedFont.charProcOperatorList = charProcOperatorList;
  53407. });
  53408. return this.type3Loaded;
  53409. }
  53410. };
  53411. return TranslatedFont;
  53412. }();
  53413. var OperatorList = function OperatorListClosure() {
  53414. var CHUNK_SIZE = 1000;
  53415. var CHUNK_SIZE_ABOUT = CHUNK_SIZE - 5;
  53416. function getTransfers(queue) {
  53417. var transfers = [];
  53418. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  53419. for (var i = 0, ii = queue.length; i < ii; i++) {
  53420. switch (fnArray[i]) {
  53421. case OPS.paintInlineImageXObject:
  53422. case OPS.paintInlineImageXObjectGroup:
  53423. case OPS.paintImageMaskXObject:
  53424. var arg = argsArray[i][0];
  53425. if (!arg.cached) {
  53426. transfers.push(arg.data.buffer);
  53427. }
  53428. break;
  53429. }
  53430. }
  53431. return transfers;
  53432. }
  53433. function OperatorList(intent, messageHandler, pageIndex) {
  53434. this.messageHandler = messageHandler;
  53435. this.fnArray = [];
  53436. this.argsArray = [];
  53437. this.dependencies = Object.create(null);
  53438. this._totalLength = 0;
  53439. this.pageIndex = pageIndex;
  53440. this.intent = intent;
  53441. }
  53442. OperatorList.prototype = {
  53443. get length() {
  53444. return this.argsArray.length;
  53445. },
  53446. get totalLength() {
  53447. return this._totalLength + this.length;
  53448. },
  53449. addOp: function (fn, args) {
  53450. this.fnArray.push(fn);
  53451. this.argsArray.push(args);
  53452. if (this.messageHandler) {
  53453. if (this.fnArray.length >= CHUNK_SIZE) {
  53454. this.flush();
  53455. } else if (this.fnArray.length >= CHUNK_SIZE_ABOUT && (fn === OPS.restore || fn === OPS.endText)) {
  53456. this.flush();
  53457. }
  53458. }
  53459. },
  53460. addDependency: function (dependency) {
  53461. if (dependency in this.dependencies) {
  53462. return;
  53463. }
  53464. this.dependencies[dependency] = true;
  53465. this.addOp(OPS.dependency, [dependency]);
  53466. },
  53467. addDependencies: function (dependencies) {
  53468. for (var key in dependencies) {
  53469. this.addDependency(key);
  53470. }
  53471. },
  53472. addOpList: function (opList) {
  53473. Util.extendObj(this.dependencies, opList.dependencies);
  53474. for (var i = 0, ii = opList.length; i < ii; i++) {
  53475. this.addOp(opList.fnArray[i], opList.argsArray[i]);
  53476. }
  53477. },
  53478. getIR: function () {
  53479. return {
  53480. fnArray: this.fnArray,
  53481. argsArray: this.argsArray,
  53482. length: this.length
  53483. };
  53484. },
  53485. flush: function (lastChunk) {
  53486. if (this.intent !== 'oplist') {
  53487. new QueueOptimizer().optimize(this);
  53488. }
  53489. var transfers = getTransfers(this);
  53490. var length = this.length;
  53491. this._totalLength += length;
  53492. this.messageHandler.send('RenderPageChunk', {
  53493. operatorList: {
  53494. fnArray: this.fnArray,
  53495. argsArray: this.argsArray,
  53496. lastChunk: lastChunk,
  53497. length: length
  53498. },
  53499. pageIndex: this.pageIndex,
  53500. intent: this.intent
  53501. }, transfers);
  53502. this.dependencies = Object.create(null);
  53503. this.fnArray.length = 0;
  53504. this.argsArray.length = 0;
  53505. }
  53506. };
  53507. return OperatorList;
  53508. }();
  53509. var StateManager = function StateManagerClosure() {
  53510. function StateManager(initialState) {
  53511. this.state = initialState;
  53512. this.stateStack = [];
  53513. }
  53514. StateManager.prototype = {
  53515. save: function () {
  53516. var old = this.state;
  53517. this.stateStack.push(this.state);
  53518. this.state = old.clone();
  53519. },
  53520. restore: function () {
  53521. var prev = this.stateStack.pop();
  53522. if (prev) {
  53523. this.state = prev;
  53524. }
  53525. },
  53526. transform: function (args) {
  53527. this.state.ctm = Util.transform(this.state.ctm, args);
  53528. }
  53529. };
  53530. return StateManager;
  53531. }();
  53532. var TextState = function TextStateClosure() {
  53533. function TextState() {
  53534. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53535. this.fontName = null;
  53536. this.fontSize = 0;
  53537. this.font = null;
  53538. this.fontMatrix = FONT_IDENTITY_MATRIX;
  53539. this.textMatrix = IDENTITY_MATRIX.slice();
  53540. this.textLineMatrix = IDENTITY_MATRIX.slice();
  53541. this.charSpacing = 0;
  53542. this.wordSpacing = 0;
  53543. this.leading = 0;
  53544. this.textHScale = 1;
  53545. this.textRise = 0;
  53546. }
  53547. TextState.prototype = {
  53548. setTextMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53549. var m = this.textMatrix;
  53550. m[0] = a;
  53551. m[1] = b;
  53552. m[2] = c;
  53553. m[3] = d;
  53554. m[4] = e;
  53555. m[5] = f;
  53556. },
  53557. setTextLineMatrix: function TextState_setTextMatrix(a, b, c, d, e, f) {
  53558. var m = this.textLineMatrix;
  53559. m[0] = a;
  53560. m[1] = b;
  53561. m[2] = c;
  53562. m[3] = d;
  53563. m[4] = e;
  53564. m[5] = f;
  53565. },
  53566. translateTextMatrix: function TextState_translateTextMatrix(x, y) {
  53567. var m = this.textMatrix;
  53568. m[4] = m[0] * x + m[2] * y + m[4];
  53569. m[5] = m[1] * x + m[3] * y + m[5];
  53570. },
  53571. translateTextLineMatrix: function TextState_translateTextMatrix(x, y) {
  53572. var m = this.textLineMatrix;
  53573. m[4] = m[0] * x + m[2] * y + m[4];
  53574. m[5] = m[1] * x + m[3] * y + m[5];
  53575. },
  53576. calcTextLineMatrixAdvance: function TextState_calcTextLineMatrixAdvance(a, b, c, d, e, f) {
  53577. var font = this.font;
  53578. if (!font) {
  53579. return null;
  53580. }
  53581. var m = this.textLineMatrix;
  53582. if (!(a === m[0] && b === m[1] && c === m[2] && d === m[3])) {
  53583. return null;
  53584. }
  53585. var txDiff = e - m[4], tyDiff = f - m[5];
  53586. if (font.vertical && txDiff !== 0 || !font.vertical && tyDiff !== 0) {
  53587. return null;
  53588. }
  53589. var tx, ty, denominator = a * d - b * c;
  53590. if (font.vertical) {
  53591. tx = -tyDiff * c / denominator;
  53592. ty = tyDiff * a / denominator;
  53593. } else {
  53594. tx = txDiff * d / denominator;
  53595. ty = -txDiff * b / denominator;
  53596. }
  53597. return {
  53598. width: tx,
  53599. height: ty,
  53600. value: font.vertical ? ty : tx
  53601. };
  53602. },
  53603. calcRenderMatrix: function TextState_calcRendeMatrix(ctm) {
  53604. var tsm = [
  53605. this.fontSize * this.textHScale,
  53606. 0,
  53607. 0,
  53608. this.fontSize,
  53609. 0,
  53610. this.textRise
  53611. ];
  53612. return Util.transform(ctm, Util.transform(this.textMatrix, tsm));
  53613. },
  53614. carriageReturn: function TextState_carriageReturn() {
  53615. this.translateTextLineMatrix(0, -this.leading);
  53616. this.textMatrix = this.textLineMatrix.slice();
  53617. },
  53618. clone: function TextState_clone() {
  53619. var clone = Object.create(this);
  53620. clone.textMatrix = this.textMatrix.slice();
  53621. clone.textLineMatrix = this.textLineMatrix.slice();
  53622. clone.fontMatrix = this.fontMatrix.slice();
  53623. return clone;
  53624. }
  53625. };
  53626. return TextState;
  53627. }();
  53628. var EvalState = function EvalStateClosure() {
  53629. function EvalState() {
  53630. this.ctm = new Float32Array(IDENTITY_MATRIX);
  53631. this.font = null;
  53632. this.textRenderingMode = TextRenderingMode.FILL;
  53633. this.fillColorSpace = ColorSpace.singletons.gray;
  53634. this.strokeColorSpace = ColorSpace.singletons.gray;
  53635. }
  53636. EvalState.prototype = {
  53637. clone: function CanvasExtraState_clone() {
  53638. return Object.create(this);
  53639. }
  53640. };
  53641. return EvalState;
  53642. }();
  53643. var EvaluatorPreprocessor = function EvaluatorPreprocessorClosure() {
  53644. var getOPMap = getLookupTableFactory(function (t) {
  53645. t['w'] = {
  53646. id: OPS.setLineWidth,
  53647. numArgs: 1,
  53648. variableArgs: false
  53649. };
  53650. t['J'] = {
  53651. id: OPS.setLineCap,
  53652. numArgs: 1,
  53653. variableArgs: false
  53654. };
  53655. t['j'] = {
  53656. id: OPS.setLineJoin,
  53657. numArgs: 1,
  53658. variableArgs: false
  53659. };
  53660. t['M'] = {
  53661. id: OPS.setMiterLimit,
  53662. numArgs: 1,
  53663. variableArgs: false
  53664. };
  53665. t['d'] = {
  53666. id: OPS.setDash,
  53667. numArgs: 2,
  53668. variableArgs: false
  53669. };
  53670. t['ri'] = {
  53671. id: OPS.setRenderingIntent,
  53672. numArgs: 1,
  53673. variableArgs: false
  53674. };
  53675. t['i'] = {
  53676. id: OPS.setFlatness,
  53677. numArgs: 1,
  53678. variableArgs: false
  53679. };
  53680. t['gs'] = {
  53681. id: OPS.setGState,
  53682. numArgs: 1,
  53683. variableArgs: false
  53684. };
  53685. t['q'] = {
  53686. id: OPS.save,
  53687. numArgs: 0,
  53688. variableArgs: false
  53689. };
  53690. t['Q'] = {
  53691. id: OPS.restore,
  53692. numArgs: 0,
  53693. variableArgs: false
  53694. };
  53695. t['cm'] = {
  53696. id: OPS.transform,
  53697. numArgs: 6,
  53698. variableArgs: false
  53699. };
  53700. t['m'] = {
  53701. id: OPS.moveTo,
  53702. numArgs: 2,
  53703. variableArgs: false
  53704. };
  53705. t['l'] = {
  53706. id: OPS.lineTo,
  53707. numArgs: 2,
  53708. variableArgs: false
  53709. };
  53710. t['c'] = {
  53711. id: OPS.curveTo,
  53712. numArgs: 6,
  53713. variableArgs: false
  53714. };
  53715. t['v'] = {
  53716. id: OPS.curveTo2,
  53717. numArgs: 4,
  53718. variableArgs: false
  53719. };
  53720. t['y'] = {
  53721. id: OPS.curveTo3,
  53722. numArgs: 4,
  53723. variableArgs: false
  53724. };
  53725. t['h'] = {
  53726. id: OPS.closePath,
  53727. numArgs: 0,
  53728. variableArgs: false
  53729. };
  53730. t['re'] = {
  53731. id: OPS.rectangle,
  53732. numArgs: 4,
  53733. variableArgs: false
  53734. };
  53735. t['S'] = {
  53736. id: OPS.stroke,
  53737. numArgs: 0,
  53738. variableArgs: false
  53739. };
  53740. t['s'] = {
  53741. id: OPS.closeStroke,
  53742. numArgs: 0,
  53743. variableArgs: false
  53744. };
  53745. t['f'] = {
  53746. id: OPS.fill,
  53747. numArgs: 0,
  53748. variableArgs: false
  53749. };
  53750. t['F'] = {
  53751. id: OPS.fill,
  53752. numArgs: 0,
  53753. variableArgs: false
  53754. };
  53755. t['f*'] = {
  53756. id: OPS.eoFill,
  53757. numArgs: 0,
  53758. variableArgs: false
  53759. };
  53760. t['B'] = {
  53761. id: OPS.fillStroke,
  53762. numArgs: 0,
  53763. variableArgs: false
  53764. };
  53765. t['B*'] = {
  53766. id: OPS.eoFillStroke,
  53767. numArgs: 0,
  53768. variableArgs: false
  53769. };
  53770. t['b'] = {
  53771. id: OPS.closeFillStroke,
  53772. numArgs: 0,
  53773. variableArgs: false
  53774. };
  53775. t['b*'] = {
  53776. id: OPS.closeEOFillStroke,
  53777. numArgs: 0,
  53778. variableArgs: false
  53779. };
  53780. t['n'] = {
  53781. id: OPS.endPath,
  53782. numArgs: 0,
  53783. variableArgs: false
  53784. };
  53785. t['W'] = {
  53786. id: OPS.clip,
  53787. numArgs: 0,
  53788. variableArgs: false
  53789. };
  53790. t['W*'] = {
  53791. id: OPS.eoClip,
  53792. numArgs: 0,
  53793. variableArgs: false
  53794. };
  53795. t['BT'] = {
  53796. id: OPS.beginText,
  53797. numArgs: 0,
  53798. variableArgs: false
  53799. };
  53800. t['ET'] = {
  53801. id: OPS.endText,
  53802. numArgs: 0,
  53803. variableArgs: false
  53804. };
  53805. t['Tc'] = {
  53806. id: OPS.setCharSpacing,
  53807. numArgs: 1,
  53808. variableArgs: false
  53809. };
  53810. t['Tw'] = {
  53811. id: OPS.setWordSpacing,
  53812. numArgs: 1,
  53813. variableArgs: false
  53814. };
  53815. t['Tz'] = {
  53816. id: OPS.setHScale,
  53817. numArgs: 1,
  53818. variableArgs: false
  53819. };
  53820. t['TL'] = {
  53821. id: OPS.setLeading,
  53822. numArgs: 1,
  53823. variableArgs: false
  53824. };
  53825. t['Tf'] = {
  53826. id: OPS.setFont,
  53827. numArgs: 2,
  53828. variableArgs: false
  53829. };
  53830. t['Tr'] = {
  53831. id: OPS.setTextRenderingMode,
  53832. numArgs: 1,
  53833. variableArgs: false
  53834. };
  53835. t['Ts'] = {
  53836. id: OPS.setTextRise,
  53837. numArgs: 1,
  53838. variableArgs: false
  53839. };
  53840. t['Td'] = {
  53841. id: OPS.moveText,
  53842. numArgs: 2,
  53843. variableArgs: false
  53844. };
  53845. t['TD'] = {
  53846. id: OPS.setLeadingMoveText,
  53847. numArgs: 2,
  53848. variableArgs: false
  53849. };
  53850. t['Tm'] = {
  53851. id: OPS.setTextMatrix,
  53852. numArgs: 6,
  53853. variableArgs: false
  53854. };
  53855. t['T*'] = {
  53856. id: OPS.nextLine,
  53857. numArgs: 0,
  53858. variableArgs: false
  53859. };
  53860. t['Tj'] = {
  53861. id: OPS.showText,
  53862. numArgs: 1,
  53863. variableArgs: false
  53864. };
  53865. t['TJ'] = {
  53866. id: OPS.showSpacedText,
  53867. numArgs: 1,
  53868. variableArgs: false
  53869. };
  53870. t['\''] = {
  53871. id: OPS.nextLineShowText,
  53872. numArgs: 1,
  53873. variableArgs: false
  53874. };
  53875. t['"'] = {
  53876. id: OPS.nextLineSetSpacingShowText,
  53877. numArgs: 3,
  53878. variableArgs: false
  53879. };
  53880. t['d0'] = {
  53881. id: OPS.setCharWidth,
  53882. numArgs: 2,
  53883. variableArgs: false
  53884. };
  53885. t['d1'] = {
  53886. id: OPS.setCharWidthAndBounds,
  53887. numArgs: 6,
  53888. variableArgs: false
  53889. };
  53890. t['CS'] = {
  53891. id: OPS.setStrokeColorSpace,
  53892. numArgs: 1,
  53893. variableArgs: false
  53894. };
  53895. t['cs'] = {
  53896. id: OPS.setFillColorSpace,
  53897. numArgs: 1,
  53898. variableArgs: false
  53899. };
  53900. t['SC'] = {
  53901. id: OPS.setStrokeColor,
  53902. numArgs: 4,
  53903. variableArgs: true
  53904. };
  53905. t['SCN'] = {
  53906. id: OPS.setStrokeColorN,
  53907. numArgs: 33,
  53908. variableArgs: true
  53909. };
  53910. t['sc'] = {
  53911. id: OPS.setFillColor,
  53912. numArgs: 4,
  53913. variableArgs: true
  53914. };
  53915. t['scn'] = {
  53916. id: OPS.setFillColorN,
  53917. numArgs: 33,
  53918. variableArgs: true
  53919. };
  53920. t['G'] = {
  53921. id: OPS.setStrokeGray,
  53922. numArgs: 1,
  53923. variableArgs: false
  53924. };
  53925. t['g'] = {
  53926. id: OPS.setFillGray,
  53927. numArgs: 1,
  53928. variableArgs: false
  53929. };
  53930. t['RG'] = {
  53931. id: OPS.setStrokeRGBColor,
  53932. numArgs: 3,
  53933. variableArgs: false
  53934. };
  53935. t['rg'] = {
  53936. id: OPS.setFillRGBColor,
  53937. numArgs: 3,
  53938. variableArgs: false
  53939. };
  53940. t['K'] = {
  53941. id: OPS.setStrokeCMYKColor,
  53942. numArgs: 4,
  53943. variableArgs: false
  53944. };
  53945. t['k'] = {
  53946. id: OPS.setFillCMYKColor,
  53947. numArgs: 4,
  53948. variableArgs: false
  53949. };
  53950. t['sh'] = {
  53951. id: OPS.shadingFill,
  53952. numArgs: 1,
  53953. variableArgs: false
  53954. };
  53955. t['BI'] = {
  53956. id: OPS.beginInlineImage,
  53957. numArgs: 0,
  53958. variableArgs: false
  53959. };
  53960. t['ID'] = {
  53961. id: OPS.beginImageData,
  53962. numArgs: 0,
  53963. variableArgs: false
  53964. };
  53965. t['EI'] = {
  53966. id: OPS.endInlineImage,
  53967. numArgs: 1,
  53968. variableArgs: false
  53969. };
  53970. t['Do'] = {
  53971. id: OPS.paintXObject,
  53972. numArgs: 1,
  53973. variableArgs: false
  53974. };
  53975. t['MP'] = {
  53976. id: OPS.markPoint,
  53977. numArgs: 1,
  53978. variableArgs: false
  53979. };
  53980. t['DP'] = {
  53981. id: OPS.markPointProps,
  53982. numArgs: 2,
  53983. variableArgs: false
  53984. };
  53985. t['BMC'] = {
  53986. id: OPS.beginMarkedContent,
  53987. numArgs: 1,
  53988. variableArgs: false
  53989. };
  53990. t['BDC'] = {
  53991. id: OPS.beginMarkedContentProps,
  53992. numArgs: 2,
  53993. variableArgs: false
  53994. };
  53995. t['EMC'] = {
  53996. id: OPS.endMarkedContent,
  53997. numArgs: 0,
  53998. variableArgs: false
  53999. };
  54000. t['BX'] = {
  54001. id: OPS.beginCompat,
  54002. numArgs: 0,
  54003. variableArgs: false
  54004. };
  54005. t['EX'] = {
  54006. id: OPS.endCompat,
  54007. numArgs: 0,
  54008. variableArgs: false
  54009. };
  54010. t['BM'] = null;
  54011. t['BD'] = null;
  54012. t['true'] = null;
  54013. t['fa'] = null;
  54014. t['fal'] = null;
  54015. t['fals'] = null;
  54016. t['false'] = null;
  54017. t['nu'] = null;
  54018. t['nul'] = null;
  54019. t['null'] = null;
  54020. });
  54021. function EvaluatorPreprocessor(stream, xref, stateManager) {
  54022. this.opMap = getOPMap();
  54023. this.parser = new Parser(new Lexer(stream, this.opMap), false, xref);
  54024. this.stateManager = stateManager;
  54025. this.nonProcessedArgs = [];
  54026. }
  54027. EvaluatorPreprocessor.prototype = {
  54028. get savedStatesDepth() {
  54029. return this.stateManager.stateStack.length;
  54030. },
  54031. read: function EvaluatorPreprocessor_read(operation) {
  54032. var args = operation.args;
  54033. while (true) {
  54034. var obj = this.parser.getObj();
  54035. if (isCmd(obj)) {
  54036. var cmd = obj.cmd;
  54037. var opSpec = this.opMap[cmd];
  54038. if (!opSpec) {
  54039. warn('Unknown command "' + cmd + '"');
  54040. continue;
  54041. }
  54042. var fn = opSpec.id;
  54043. var numArgs = opSpec.numArgs;
  54044. var argsLength = args !== null ? args.length : 0;
  54045. if (!opSpec.variableArgs) {
  54046. if (argsLength !== numArgs) {
  54047. var nonProcessedArgs = this.nonProcessedArgs;
  54048. while (argsLength > numArgs) {
  54049. nonProcessedArgs.push(args.shift());
  54050. argsLength--;
  54051. }
  54052. while (argsLength < numArgs && nonProcessedArgs.length !== 0) {
  54053. if (args === null) {
  54054. args = [];
  54055. }
  54056. args.unshift(nonProcessedArgs.pop());
  54057. argsLength++;
  54058. }
  54059. }
  54060. if (argsLength < numArgs) {
  54061. warn('Skipping command ' + fn + ': expected ' + numArgs + ' args, but received ' + argsLength + ' args.');
  54062. if (args !== null) {
  54063. args.length = 0;
  54064. }
  54065. continue;
  54066. }
  54067. } else if (argsLength > numArgs) {
  54068. info('Command ' + fn + ': expected [0,' + numArgs + '] args, but received ' + argsLength + ' args.');
  54069. }
  54070. this.preprocessCommand(fn, args);
  54071. operation.fn = fn;
  54072. operation.args = args;
  54073. return true;
  54074. } else {
  54075. if (isEOF(obj)) {
  54076. return false;
  54077. }
  54078. if (obj !== null) {
  54079. if (args === null) {
  54080. args = [];
  54081. }
  54082. args.push(obj);
  54083. assert(args.length <= 33, 'Too many arguments');
  54084. }
  54085. }
  54086. }
  54087. },
  54088. preprocessCommand: function EvaluatorPreprocessor_preprocessCommand(fn, args) {
  54089. switch (fn | 0) {
  54090. case OPS.save:
  54091. this.stateManager.save();
  54092. break;
  54093. case OPS.restore:
  54094. this.stateManager.restore();
  54095. break;
  54096. case OPS.transform:
  54097. this.stateManager.transform(args);
  54098. break;
  54099. }
  54100. }
  54101. };
  54102. return EvaluatorPreprocessor;
  54103. }();
  54104. var QueueOptimizer = function QueueOptimizerClosure() {
  54105. function addState(parentState, pattern, fn) {
  54106. var state = parentState;
  54107. for (var i = 0, ii = pattern.length - 1; i < ii; i++) {
  54108. var item = pattern[i];
  54109. state = state[item] || (state[item] = []);
  54110. }
  54111. state[pattern[pattern.length - 1]] = fn;
  54112. }
  54113. function handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray) {
  54114. var iFirstPIMXO = iFirstSave + 2;
  54115. for (var i = 0; i < count; i++) {
  54116. var arg = argsArray[iFirstPIMXO + 4 * i];
  54117. var imageMask = arg.length === 1 && arg[0];
  54118. if (imageMask && imageMask.width === 1 && imageMask.height === 1 && (!imageMask.data.length || imageMask.data.length === 1 && imageMask.data[0] === 0)) {
  54119. fnArray[iFirstPIMXO + 4 * i] = OPS.paintSolidColorImageMask;
  54120. continue;
  54121. }
  54122. break;
  54123. }
  54124. return count - i;
  54125. }
  54126. var InitialState = [];
  54127. addState(InitialState, [
  54128. OPS.save,
  54129. OPS.transform,
  54130. OPS.paintInlineImageXObject,
  54131. OPS.restore
  54132. ], function foundInlineImageGroup(context) {
  54133. var MIN_IMAGES_IN_INLINE_IMAGES_BLOCK = 10;
  54134. var MAX_IMAGES_IN_INLINE_IMAGES_BLOCK = 200;
  54135. var MAX_WIDTH = 1000;
  54136. var IMAGE_PADDING = 1;
  54137. var fnArray = context.fnArray, argsArray = context.argsArray;
  54138. var curr = context.iCurr;
  54139. var iFirstSave = curr - 3;
  54140. var iFirstTransform = curr - 2;
  54141. var iFirstPIIXO = curr - 1;
  54142. var i = iFirstSave + 4;
  54143. var ii = fnArray.length;
  54144. while (i + 3 < ii) {
  54145. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintInlineImageXObject || fnArray[i + 3] !== OPS.restore) {
  54146. break;
  54147. }
  54148. i += 4;
  54149. }
  54150. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_INLINE_IMAGES_BLOCK);
  54151. if (count < MIN_IMAGES_IN_INLINE_IMAGES_BLOCK) {
  54152. return i;
  54153. }
  54154. var maxX = 0;
  54155. var map = [], maxLineHeight = 0;
  54156. var currentX = IMAGE_PADDING, currentY = IMAGE_PADDING;
  54157. var q;
  54158. for (q = 0; q < count; q++) {
  54159. var transform = argsArray[iFirstTransform + (q << 2)];
  54160. var img = argsArray[iFirstPIIXO + (q << 2)][0];
  54161. if (currentX + img.width > MAX_WIDTH) {
  54162. maxX = Math.max(maxX, currentX);
  54163. currentY += maxLineHeight + 2 * IMAGE_PADDING;
  54164. currentX = 0;
  54165. maxLineHeight = 0;
  54166. }
  54167. map.push({
  54168. transform: transform,
  54169. x: currentX,
  54170. y: currentY,
  54171. w: img.width,
  54172. h: img.height
  54173. });
  54174. currentX += img.width + 2 * IMAGE_PADDING;
  54175. maxLineHeight = Math.max(maxLineHeight, img.height);
  54176. }
  54177. var imgWidth = Math.max(maxX, currentX) + IMAGE_PADDING;
  54178. var imgHeight = currentY + maxLineHeight + IMAGE_PADDING;
  54179. var imgData = new Uint8Array(imgWidth * imgHeight * 4);
  54180. var imgRowSize = imgWidth << 2;
  54181. for (q = 0; q < count; q++) {
  54182. var data = argsArray[iFirstPIIXO + (q << 2)][0].data;
  54183. var rowSize = map[q].w << 2;
  54184. var dataOffset = 0;
  54185. var offset = map[q].x + map[q].y * imgWidth << 2;
  54186. imgData.set(data.subarray(0, rowSize), offset - imgRowSize);
  54187. for (var k = 0, kk = map[q].h; k < kk; k++) {
  54188. imgData.set(data.subarray(dataOffset, dataOffset + rowSize), offset);
  54189. dataOffset += rowSize;
  54190. offset += imgRowSize;
  54191. }
  54192. imgData.set(data.subarray(dataOffset - rowSize, dataOffset), offset);
  54193. while (offset >= 0) {
  54194. data[offset - 4] = data[offset];
  54195. data[offset - 3] = data[offset + 1];
  54196. data[offset - 2] = data[offset + 2];
  54197. data[offset - 1] = data[offset + 3];
  54198. data[offset + rowSize] = data[offset + rowSize - 4];
  54199. data[offset + rowSize + 1] = data[offset + rowSize - 3];
  54200. data[offset + rowSize + 2] = data[offset + rowSize - 2];
  54201. data[offset + rowSize + 3] = data[offset + rowSize - 1];
  54202. offset -= imgRowSize;
  54203. }
  54204. }
  54205. fnArray.splice(iFirstSave, count * 4, OPS.paintInlineImageXObjectGroup);
  54206. argsArray.splice(iFirstSave, count * 4, [
  54207. {
  54208. width: imgWidth,
  54209. height: imgHeight,
  54210. kind: ImageKind.RGBA_32BPP,
  54211. data: imgData
  54212. },
  54213. map
  54214. ]);
  54215. return iFirstSave + 1;
  54216. });
  54217. addState(InitialState, [
  54218. OPS.save,
  54219. OPS.transform,
  54220. OPS.paintImageMaskXObject,
  54221. OPS.restore
  54222. ], function foundImageMaskGroup(context) {
  54223. var MIN_IMAGES_IN_MASKS_BLOCK = 10;
  54224. var MAX_IMAGES_IN_MASKS_BLOCK = 100;
  54225. var MAX_SAME_IMAGES_IN_MASKS_BLOCK = 1000;
  54226. var fnArray = context.fnArray, argsArray = context.argsArray;
  54227. var curr = context.iCurr;
  54228. var iFirstSave = curr - 3;
  54229. var iFirstTransform = curr - 2;
  54230. var iFirstPIMXO = curr - 1;
  54231. var i = iFirstSave + 4;
  54232. var ii = fnArray.length;
  54233. while (i + 3 < ii) {
  54234. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageMaskXObject || fnArray[i + 3] !== OPS.restore) {
  54235. break;
  54236. }
  54237. i += 4;
  54238. }
  54239. var count = (i - iFirstSave) / 4;
  54240. count = handlePaintSolidColorImageMask(iFirstSave, count, fnArray, argsArray);
  54241. if (count < MIN_IMAGES_IN_MASKS_BLOCK) {
  54242. return i;
  54243. }
  54244. var q;
  54245. var isSameImage = false;
  54246. var iTransform, transformArgs;
  54247. var firstPIMXOArg0 = argsArray[iFirstPIMXO][0];
  54248. if (argsArray[iFirstTransform][1] === 0 && argsArray[iFirstTransform][2] === 0) {
  54249. isSameImage = true;
  54250. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54251. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54252. iTransform = iFirstTransform + 4;
  54253. var iPIMXO = iFirstPIMXO + 4;
  54254. for (q = 1; q < count; q++, iTransform += 4, iPIMXO += 4) {
  54255. transformArgs = argsArray[iTransform];
  54256. if (argsArray[iPIMXO][0] !== firstPIMXOArg0 || transformArgs[0] !== firstTransformArg0 || transformArgs[1] !== 0 || transformArgs[2] !== 0 || transformArgs[3] !== firstTransformArg3) {
  54257. if (q < MIN_IMAGES_IN_MASKS_BLOCK) {
  54258. isSameImage = false;
  54259. } else {
  54260. count = q;
  54261. }
  54262. break;
  54263. }
  54264. }
  54265. }
  54266. if (isSameImage) {
  54267. count = Math.min(count, MAX_SAME_IMAGES_IN_MASKS_BLOCK);
  54268. var positions = new Float32Array(count * 2);
  54269. iTransform = iFirstTransform;
  54270. for (q = 0; q < count; q++, iTransform += 4) {
  54271. transformArgs = argsArray[iTransform];
  54272. positions[q << 1] = transformArgs[4];
  54273. positions[(q << 1) + 1] = transformArgs[5];
  54274. }
  54275. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectRepeat);
  54276. argsArray.splice(iFirstSave, count * 4, [
  54277. firstPIMXOArg0,
  54278. firstTransformArg0,
  54279. firstTransformArg3,
  54280. positions
  54281. ]);
  54282. } else {
  54283. count = Math.min(count, MAX_IMAGES_IN_MASKS_BLOCK);
  54284. var images = [];
  54285. for (q = 0; q < count; q++) {
  54286. transformArgs = argsArray[iFirstTransform + (q << 2)];
  54287. var maskParams = argsArray[iFirstPIMXO + (q << 2)][0];
  54288. images.push({
  54289. data: maskParams.data,
  54290. width: maskParams.width,
  54291. height: maskParams.height,
  54292. transform: transformArgs
  54293. });
  54294. }
  54295. fnArray.splice(iFirstSave, count * 4, OPS.paintImageMaskXObjectGroup);
  54296. argsArray.splice(iFirstSave, count * 4, [images]);
  54297. }
  54298. return iFirstSave + 1;
  54299. });
  54300. addState(InitialState, [
  54301. OPS.save,
  54302. OPS.transform,
  54303. OPS.paintImageXObject,
  54304. OPS.restore
  54305. ], function (context) {
  54306. var MIN_IMAGES_IN_BLOCK = 3;
  54307. var MAX_IMAGES_IN_BLOCK = 1000;
  54308. var fnArray = context.fnArray, argsArray = context.argsArray;
  54309. var curr = context.iCurr;
  54310. var iFirstSave = curr - 3;
  54311. var iFirstTransform = curr - 2;
  54312. var iFirstPIXO = curr - 1;
  54313. var iFirstRestore = curr;
  54314. if (argsArray[iFirstTransform][1] !== 0 || argsArray[iFirstTransform][2] !== 0) {
  54315. return iFirstRestore + 1;
  54316. }
  54317. var firstPIXOArg0 = argsArray[iFirstPIXO][0];
  54318. var firstTransformArg0 = argsArray[iFirstTransform][0];
  54319. var firstTransformArg3 = argsArray[iFirstTransform][3];
  54320. var i = iFirstSave + 4;
  54321. var ii = fnArray.length;
  54322. while (i + 3 < ii) {
  54323. if (fnArray[i] !== OPS.save || fnArray[i + 1] !== OPS.transform || fnArray[i + 2] !== OPS.paintImageXObject || fnArray[i + 3] !== OPS.restore) {
  54324. break;
  54325. }
  54326. if (argsArray[i + 1][0] !== firstTransformArg0 || argsArray[i + 1][1] !== 0 || argsArray[i + 1][2] !== 0 || argsArray[i + 1][3] !== firstTransformArg3) {
  54327. break;
  54328. }
  54329. if (argsArray[i + 2][0] !== firstPIXOArg0) {
  54330. break;
  54331. }
  54332. i += 4;
  54333. }
  54334. var count = Math.min((i - iFirstSave) / 4, MAX_IMAGES_IN_BLOCK);
  54335. if (count < MIN_IMAGES_IN_BLOCK) {
  54336. return i;
  54337. }
  54338. var positions = new Float32Array(count * 2);
  54339. var iTransform = iFirstTransform;
  54340. for (var q = 0; q < count; q++, iTransform += 4) {
  54341. var transformArgs = argsArray[iTransform];
  54342. positions[q << 1] = transformArgs[4];
  54343. positions[(q << 1) + 1] = transformArgs[5];
  54344. }
  54345. var args = [
  54346. firstPIXOArg0,
  54347. firstTransformArg0,
  54348. firstTransformArg3,
  54349. positions
  54350. ];
  54351. fnArray.splice(iFirstSave, count * 4, OPS.paintImageXObjectRepeat);
  54352. argsArray.splice(iFirstSave, count * 4, args);
  54353. return iFirstSave + 1;
  54354. });
  54355. addState(InitialState, [
  54356. OPS.beginText,
  54357. OPS.setFont,
  54358. OPS.setTextMatrix,
  54359. OPS.showText,
  54360. OPS.endText
  54361. ], function (context) {
  54362. var MIN_CHARS_IN_BLOCK = 3;
  54363. var MAX_CHARS_IN_BLOCK = 1000;
  54364. var fnArray = context.fnArray, argsArray = context.argsArray;
  54365. var curr = context.iCurr;
  54366. var iFirstBeginText = curr - 4;
  54367. var iFirstSetFont = curr - 3;
  54368. var iFirstSetTextMatrix = curr - 2;
  54369. var iFirstShowText = curr - 1;
  54370. var iFirstEndText = curr;
  54371. var firstSetFontArg0 = argsArray[iFirstSetFont][0];
  54372. var firstSetFontArg1 = argsArray[iFirstSetFont][1];
  54373. var i = iFirstBeginText + 5;
  54374. var ii = fnArray.length;
  54375. while (i + 4 < ii) {
  54376. 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) {
  54377. break;
  54378. }
  54379. if (argsArray[i + 1][0] !== firstSetFontArg0 || argsArray[i + 1][1] !== firstSetFontArg1) {
  54380. break;
  54381. }
  54382. i += 5;
  54383. }
  54384. var count = Math.min((i - iFirstBeginText) / 5, MAX_CHARS_IN_BLOCK);
  54385. if (count < MIN_CHARS_IN_BLOCK) {
  54386. return i;
  54387. }
  54388. var iFirst = iFirstBeginText;
  54389. 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) {
  54390. count++;
  54391. iFirst -= 5;
  54392. }
  54393. var iEndText = iFirst + 4;
  54394. for (var q = 1; q < count; q++) {
  54395. fnArray.splice(iEndText, 3);
  54396. argsArray.splice(iEndText, 3);
  54397. iEndText += 2;
  54398. }
  54399. return iEndText + 1;
  54400. });
  54401. function QueueOptimizer() {
  54402. }
  54403. QueueOptimizer.prototype = {
  54404. optimize: function QueueOptimizer_optimize(queue) {
  54405. var fnArray = queue.fnArray, argsArray = queue.argsArray;
  54406. var context = {
  54407. iCurr: 0,
  54408. fnArray: fnArray,
  54409. argsArray: argsArray
  54410. };
  54411. var state;
  54412. var i = 0, ii = fnArray.length;
  54413. while (i < ii) {
  54414. state = (state || InitialState)[fnArray[i]];
  54415. if (typeof state === 'function') {
  54416. context.iCurr = i;
  54417. i = state(context);
  54418. state = undefined;
  54419. ii = context.fnArray.length;
  54420. } else {
  54421. i++;
  54422. }
  54423. }
  54424. }
  54425. };
  54426. return QueueOptimizer;
  54427. }();
  54428. exports.OperatorList = OperatorList;
  54429. exports.PartialEvaluator = PartialEvaluator;
  54430. }));
  54431. (function (root, factory) {
  54432. factory(root.pdfjsCoreAnnotation = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreColorSpace, root.pdfjsCoreObj, root.pdfjsCoreEvaluator);
  54433. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreColorSpace, coreObj, coreEvaluator) {
  54434. var AnnotationBorderStyleType = sharedUtil.AnnotationBorderStyleType;
  54435. var AnnotationFieldFlag = sharedUtil.AnnotationFieldFlag;
  54436. var AnnotationFlag = sharedUtil.AnnotationFlag;
  54437. var AnnotationType = sharedUtil.AnnotationType;
  54438. var OPS = sharedUtil.OPS;
  54439. var Util = sharedUtil.Util;
  54440. var isString = sharedUtil.isString;
  54441. var isArray = sharedUtil.isArray;
  54442. var isInt = sharedUtil.isInt;
  54443. var stringToBytes = sharedUtil.stringToBytes;
  54444. var stringToPDFString = sharedUtil.stringToPDFString;
  54445. var warn = sharedUtil.warn;
  54446. var Dict = corePrimitives.Dict;
  54447. var isDict = corePrimitives.isDict;
  54448. var isName = corePrimitives.isName;
  54449. var isRef = corePrimitives.isRef;
  54450. var Stream = coreStream.Stream;
  54451. var ColorSpace = coreColorSpace.ColorSpace;
  54452. var Catalog = coreObj.Catalog;
  54453. var ObjectLoader = coreObj.ObjectLoader;
  54454. var FileSpec = coreObj.FileSpec;
  54455. var OperatorList = coreEvaluator.OperatorList;
  54456. function AnnotationFactory() {
  54457. }
  54458. AnnotationFactory.prototype = {
  54459. create: function AnnotationFactory_create(xref, ref, pdfManager, uniquePrefix, idCounters) {
  54460. var dict = xref.fetchIfRef(ref);
  54461. if (!isDict(dict)) {
  54462. return;
  54463. }
  54464. var id = isRef(ref) ? ref.toString() : 'annot_' + (uniquePrefix || '') + ++idCounters.obj;
  54465. var subtype = dict.get('Subtype');
  54466. subtype = isName(subtype) ? subtype.name : null;
  54467. var parameters = {
  54468. xref: xref,
  54469. dict: dict,
  54470. ref: isRef(ref) ? ref : null,
  54471. subtype: subtype,
  54472. id: id,
  54473. pdfManager: pdfManager
  54474. };
  54475. switch (subtype) {
  54476. case 'Link':
  54477. return new LinkAnnotation(parameters);
  54478. case 'Text':
  54479. return new TextAnnotation(parameters);
  54480. case 'Widget':
  54481. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54482. fieldType = isName(fieldType) ? fieldType.name : null;
  54483. switch (fieldType) {
  54484. case 'Tx':
  54485. return new TextWidgetAnnotation(parameters);
  54486. case 'Ch':
  54487. return new ChoiceWidgetAnnotation(parameters);
  54488. }
  54489. warn('Unimplemented widget field type "' + fieldType + '", ' + 'falling back to base field type.');
  54490. return new WidgetAnnotation(parameters);
  54491. case 'Popup':
  54492. return new PopupAnnotation(parameters);
  54493. case 'Highlight':
  54494. return new HighlightAnnotation(parameters);
  54495. case 'Underline':
  54496. return new UnderlineAnnotation(parameters);
  54497. case 'Squiggly':
  54498. return new SquigglyAnnotation(parameters);
  54499. case 'StrikeOut':
  54500. return new StrikeOutAnnotation(parameters);
  54501. case 'FileAttachment':
  54502. return new FileAttachmentAnnotation(parameters);
  54503. default:
  54504. if (!subtype) {
  54505. warn('Annotation is missing the required /Subtype.');
  54506. } else {
  54507. warn('Unimplemented annotation type "' + subtype + '", ' + 'falling back to base annotation.');
  54508. }
  54509. return new Annotation(parameters);
  54510. }
  54511. }
  54512. };
  54513. var Annotation = function AnnotationClosure() {
  54514. function getTransformMatrix(rect, bbox, matrix) {
  54515. var bounds = Util.getAxialAlignedBoundingBox(bbox, matrix);
  54516. var minX = bounds[0];
  54517. var minY = bounds[1];
  54518. var maxX = bounds[2];
  54519. var maxY = bounds[3];
  54520. if (minX === maxX || minY === maxY) {
  54521. return [
  54522. 1,
  54523. 0,
  54524. 0,
  54525. 1,
  54526. rect[0],
  54527. rect[1]
  54528. ];
  54529. }
  54530. var xRatio = (rect[2] - rect[0]) / (maxX - minX);
  54531. var yRatio = (rect[3] - rect[1]) / (maxY - minY);
  54532. return [
  54533. xRatio,
  54534. 0,
  54535. 0,
  54536. yRatio,
  54537. rect[0] - minX * xRatio,
  54538. rect[1] - minY * yRatio
  54539. ];
  54540. }
  54541. function getDefaultAppearance(dict) {
  54542. var appearanceState = dict.get('AP');
  54543. if (!isDict(appearanceState)) {
  54544. return;
  54545. }
  54546. var appearance;
  54547. var appearances = appearanceState.get('N');
  54548. if (isDict(appearances)) {
  54549. var as = dict.get('AS');
  54550. if (as && appearances.has(as.name)) {
  54551. appearance = appearances.get(as.name);
  54552. }
  54553. } else {
  54554. appearance = appearances;
  54555. }
  54556. return appearance;
  54557. }
  54558. function Annotation(params) {
  54559. var dict = params.dict;
  54560. this.setFlags(dict.get('F'));
  54561. this.setRectangle(dict.getArray('Rect'));
  54562. this.setColor(dict.getArray('C'));
  54563. this.setBorderStyle(dict);
  54564. this.appearance = getDefaultAppearance(dict);
  54565. this.data = {};
  54566. this.data.id = params.id;
  54567. this.data.subtype = params.subtype;
  54568. this.data.annotationFlags = this.flags;
  54569. this.data.rect = this.rectangle;
  54570. this.data.color = this.color;
  54571. this.data.borderStyle = this.borderStyle;
  54572. this.data.hasAppearance = !!this.appearance;
  54573. }
  54574. Annotation.prototype = {
  54575. _hasFlag: function Annotation_hasFlag(flags, flag) {
  54576. return !!(flags & flag);
  54577. },
  54578. _isViewable: function Annotation_isViewable(flags) {
  54579. return !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN) && !this._hasFlag(flags, AnnotationFlag.NOVIEW);
  54580. },
  54581. _isPrintable: function AnnotationFlag_isPrintable(flags) {
  54582. return this._hasFlag(flags, AnnotationFlag.PRINT) && !this._hasFlag(flags, AnnotationFlag.INVISIBLE) && !this._hasFlag(flags, AnnotationFlag.HIDDEN);
  54583. },
  54584. get viewable() {
  54585. if (this.flags === 0) {
  54586. return true;
  54587. }
  54588. return this._isViewable(this.flags);
  54589. },
  54590. get printable() {
  54591. if (this.flags === 0) {
  54592. return false;
  54593. }
  54594. return this._isPrintable(this.flags);
  54595. },
  54596. setFlags: function Annotation_setFlags(flags) {
  54597. this.flags = isInt(flags) && flags > 0 ? flags : 0;
  54598. },
  54599. hasFlag: function Annotation_hasFlag(flag) {
  54600. return this._hasFlag(this.flags, flag);
  54601. },
  54602. setRectangle: function Annotation_setRectangle(rectangle) {
  54603. if (isArray(rectangle) && rectangle.length === 4) {
  54604. this.rectangle = Util.normalizeRect(rectangle);
  54605. } else {
  54606. this.rectangle = [
  54607. 0,
  54608. 0,
  54609. 0,
  54610. 0
  54611. ];
  54612. }
  54613. },
  54614. setColor: function Annotation_setColor(color) {
  54615. var rgbColor = new Uint8Array(3);
  54616. if (!isArray(color)) {
  54617. this.color = rgbColor;
  54618. return;
  54619. }
  54620. switch (color.length) {
  54621. case 0:
  54622. this.color = null;
  54623. break;
  54624. case 1:
  54625. ColorSpace.singletons.gray.getRgbItem(color, 0, rgbColor, 0);
  54626. this.color = rgbColor;
  54627. break;
  54628. case 3:
  54629. ColorSpace.singletons.rgb.getRgbItem(color, 0, rgbColor, 0);
  54630. this.color = rgbColor;
  54631. break;
  54632. case 4:
  54633. ColorSpace.singletons.cmyk.getRgbItem(color, 0, rgbColor, 0);
  54634. this.color = rgbColor;
  54635. break;
  54636. default:
  54637. this.color = rgbColor;
  54638. break;
  54639. }
  54640. },
  54641. setBorderStyle: function Annotation_setBorderStyle(borderStyle) {
  54642. this.borderStyle = new AnnotationBorderStyle();
  54643. if (!isDict(borderStyle)) {
  54644. return;
  54645. }
  54646. if (borderStyle.has('BS')) {
  54647. var dict = borderStyle.get('BS');
  54648. var dictType = dict.get('Type');
  54649. if (!dictType || isName(dictType, 'Border')) {
  54650. this.borderStyle.setWidth(dict.get('W'));
  54651. this.borderStyle.setStyle(dict.get('S'));
  54652. this.borderStyle.setDashArray(dict.getArray('D'));
  54653. }
  54654. } else if (borderStyle.has('Border')) {
  54655. var array = borderStyle.getArray('Border');
  54656. if (isArray(array) && array.length >= 3) {
  54657. this.borderStyle.setHorizontalCornerRadius(array[0]);
  54658. this.borderStyle.setVerticalCornerRadius(array[1]);
  54659. this.borderStyle.setWidth(array[2]);
  54660. if (array.length === 4) {
  54661. this.borderStyle.setDashArray(array[3]);
  54662. }
  54663. }
  54664. } else {
  54665. this.borderStyle.setWidth(0);
  54666. }
  54667. },
  54668. _preparePopup: function Annotation_preparePopup(dict) {
  54669. if (!dict.has('C')) {
  54670. this.data.color = null;
  54671. }
  54672. this.data.hasPopup = dict.has('Popup');
  54673. this.data.title = stringToPDFString(dict.get('T') || '');
  54674. this.data.contents = stringToPDFString(dict.get('Contents') || '');
  54675. },
  54676. loadResources: function Annotation_loadResources(keys) {
  54677. return new Promise(function (resolve, reject) {
  54678. this.appearance.dict.getAsync('Resources').then(function (resources) {
  54679. if (!resources) {
  54680. resolve();
  54681. return;
  54682. }
  54683. var objectLoader = new ObjectLoader(resources.map, keys, resources.xref);
  54684. objectLoader.load().then(function () {
  54685. resolve(resources);
  54686. }, reject);
  54687. }, reject);
  54688. }.bind(this));
  54689. },
  54690. getOperatorList: function Annotation_getOperatorList(evaluator, task, renderForms) {
  54691. if (!this.appearance) {
  54692. return Promise.resolve(new OperatorList());
  54693. }
  54694. var data = this.data;
  54695. var appearanceDict = this.appearance.dict;
  54696. var resourcesPromise = this.loadResources([
  54697. 'ExtGState',
  54698. 'ColorSpace',
  54699. 'Pattern',
  54700. 'Shading',
  54701. 'XObject',
  54702. 'Font'
  54703. ]);
  54704. var bbox = appearanceDict.getArray('BBox') || [
  54705. 0,
  54706. 0,
  54707. 1,
  54708. 1
  54709. ];
  54710. var matrix = appearanceDict.getArray('Matrix') || [
  54711. 1,
  54712. 0,
  54713. 0,
  54714. 1,
  54715. 0,
  54716. 0
  54717. ];
  54718. var transform = getTransformMatrix(data.rect, bbox, matrix);
  54719. var self = this;
  54720. return resourcesPromise.then(function (resources) {
  54721. var opList = new OperatorList();
  54722. opList.addOp(OPS.beginAnnotation, [
  54723. data.rect,
  54724. transform,
  54725. matrix
  54726. ]);
  54727. return evaluator.getOperatorList(self.appearance, task, resources, opList).then(function () {
  54728. opList.addOp(OPS.endAnnotation, []);
  54729. self.appearance.reset();
  54730. return opList;
  54731. });
  54732. });
  54733. }
  54734. };
  54735. Annotation.appendToOperatorList = function Annotation_appendToOperatorList(annotations, opList, partialEvaluator, task, intent, renderForms) {
  54736. var annotationPromises = [];
  54737. for (var i = 0, n = annotations.length; i < n; ++i) {
  54738. if (intent === 'display' && annotations[i].viewable || intent === 'print' && annotations[i].printable) {
  54739. annotationPromises.push(annotations[i].getOperatorList(partialEvaluator, task, renderForms));
  54740. }
  54741. }
  54742. return Promise.all(annotationPromises).then(function (operatorLists) {
  54743. opList.addOp(OPS.beginAnnotations, []);
  54744. for (var i = 0, n = operatorLists.length; i < n; ++i) {
  54745. opList.addOpList(operatorLists[i]);
  54746. }
  54747. opList.addOp(OPS.endAnnotations, []);
  54748. });
  54749. };
  54750. return Annotation;
  54751. }();
  54752. var AnnotationBorderStyle = function AnnotationBorderStyleClosure() {
  54753. function AnnotationBorderStyle() {
  54754. this.width = 1;
  54755. this.style = AnnotationBorderStyleType.SOLID;
  54756. this.dashArray = [3];
  54757. this.horizontalCornerRadius = 0;
  54758. this.verticalCornerRadius = 0;
  54759. }
  54760. AnnotationBorderStyle.prototype = {
  54761. setWidth: function AnnotationBorderStyle_setWidth(width) {
  54762. if (width === (width | 0)) {
  54763. this.width = width;
  54764. }
  54765. },
  54766. setStyle: function AnnotationBorderStyle_setStyle(style) {
  54767. if (!style) {
  54768. return;
  54769. }
  54770. switch (style.name) {
  54771. case 'S':
  54772. this.style = AnnotationBorderStyleType.SOLID;
  54773. break;
  54774. case 'D':
  54775. this.style = AnnotationBorderStyleType.DASHED;
  54776. break;
  54777. case 'B':
  54778. this.style = AnnotationBorderStyleType.BEVELED;
  54779. break;
  54780. case 'I':
  54781. this.style = AnnotationBorderStyleType.INSET;
  54782. break;
  54783. case 'U':
  54784. this.style = AnnotationBorderStyleType.UNDERLINE;
  54785. break;
  54786. default:
  54787. break;
  54788. }
  54789. },
  54790. setDashArray: function AnnotationBorderStyle_setDashArray(dashArray) {
  54791. if (isArray(dashArray) && dashArray.length > 0) {
  54792. var isValid = true;
  54793. var allZeros = true;
  54794. for (var i = 0, len = dashArray.length; i < len; i++) {
  54795. var element = dashArray[i];
  54796. var validNumber = +element >= 0;
  54797. if (!validNumber) {
  54798. isValid = false;
  54799. break;
  54800. } else if (element > 0) {
  54801. allZeros = false;
  54802. }
  54803. }
  54804. if (isValid && !allZeros) {
  54805. this.dashArray = dashArray;
  54806. } else {
  54807. this.width = 0;
  54808. }
  54809. } else if (dashArray) {
  54810. this.width = 0;
  54811. }
  54812. },
  54813. setHorizontalCornerRadius: function AnnotationBorderStyle_setHorizontalCornerRadius(radius) {
  54814. if (radius === (radius | 0)) {
  54815. this.horizontalCornerRadius = radius;
  54816. }
  54817. },
  54818. setVerticalCornerRadius: function AnnotationBorderStyle_setVerticalCornerRadius(radius) {
  54819. if (radius === (radius | 0)) {
  54820. this.verticalCornerRadius = radius;
  54821. }
  54822. }
  54823. };
  54824. return AnnotationBorderStyle;
  54825. }();
  54826. var WidgetAnnotation = function WidgetAnnotationClosure() {
  54827. function WidgetAnnotation(params) {
  54828. Annotation.call(this, params);
  54829. var dict = params.dict;
  54830. var data = this.data;
  54831. data.annotationType = AnnotationType.WIDGET;
  54832. data.fieldName = this._constructFieldName(dict);
  54833. data.fieldValue = Util.getInheritableProperty(dict, 'V', true);
  54834. data.alternativeText = stringToPDFString(dict.get('TU') || '');
  54835. data.defaultAppearance = Util.getInheritableProperty(dict, 'DA') || '';
  54836. var fieldType = Util.getInheritableProperty(dict, 'FT');
  54837. data.fieldType = isName(fieldType) ? fieldType.name : null;
  54838. this.fieldResources = Util.getInheritableProperty(dict, 'DR') || Dict.empty;
  54839. data.fieldFlags = Util.getInheritableProperty(dict, 'Ff');
  54840. if (!isInt(data.fieldFlags) || data.fieldFlags < 0) {
  54841. data.fieldFlags = 0;
  54842. }
  54843. data.readOnly = this.hasFieldFlag(AnnotationFieldFlag.READONLY);
  54844. if (data.fieldType === 'Sig') {
  54845. this.setFlags(AnnotationFlag.HIDDEN);
  54846. }
  54847. }
  54848. Util.inherit(WidgetAnnotation, Annotation, {
  54849. _constructFieldName: function WidgetAnnotation_constructFieldName(dict) {
  54850. if (!dict.has('T') && !dict.has('Parent')) {
  54851. warn('Unknown field name, falling back to empty field name.');
  54852. return '';
  54853. }
  54854. if (!dict.has('Parent')) {
  54855. return stringToPDFString(dict.get('T'));
  54856. }
  54857. var fieldName = [];
  54858. if (dict.has('T')) {
  54859. fieldName.unshift(stringToPDFString(dict.get('T')));
  54860. }
  54861. var loopDict = dict;
  54862. while (loopDict.has('Parent')) {
  54863. loopDict = loopDict.get('Parent');
  54864. if (loopDict.has('T')) {
  54865. fieldName.unshift(stringToPDFString(loopDict.get('T')));
  54866. }
  54867. }
  54868. return fieldName.join('.');
  54869. },
  54870. hasFieldFlag: function WidgetAnnotation_hasFieldFlag(flag) {
  54871. return !!(this.data.fieldFlags & flag);
  54872. }
  54873. });
  54874. return WidgetAnnotation;
  54875. }();
  54876. var TextWidgetAnnotation = function TextWidgetAnnotationClosure() {
  54877. function TextWidgetAnnotation(params) {
  54878. WidgetAnnotation.call(this, params);
  54879. this.data.fieldValue = stringToPDFString(this.data.fieldValue || '');
  54880. var alignment = Util.getInheritableProperty(params.dict, 'Q');
  54881. if (!isInt(alignment) || alignment < 0 || alignment > 2) {
  54882. alignment = null;
  54883. }
  54884. this.data.textAlignment = alignment;
  54885. var maximumLength = Util.getInheritableProperty(params.dict, 'MaxLen');
  54886. if (!isInt(maximumLength) || maximumLength < 0) {
  54887. maximumLength = null;
  54888. }
  54889. this.data.maxLen = maximumLength;
  54890. this.data.multiLine = this.hasFieldFlag(AnnotationFieldFlag.MULTILINE);
  54891. this.data.comb = this.hasFieldFlag(AnnotationFieldFlag.COMB) && !this.hasFieldFlag(AnnotationFieldFlag.MULTILINE) && !this.hasFieldFlag(AnnotationFieldFlag.PASSWORD) && !this.hasFieldFlag(AnnotationFieldFlag.FILESELECT) && this.data.maxLen !== null;
  54892. }
  54893. Util.inherit(TextWidgetAnnotation, WidgetAnnotation, {
  54894. getOperatorList: function TextWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54895. var operatorList = new OperatorList();
  54896. if (renderForms) {
  54897. return Promise.resolve(operatorList);
  54898. }
  54899. if (this.appearance) {
  54900. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54901. }
  54902. if (!this.data.defaultAppearance) {
  54903. return Promise.resolve(operatorList);
  54904. }
  54905. var stream = new Stream(stringToBytes(this.data.defaultAppearance));
  54906. return evaluator.getOperatorList(stream, task, this.fieldResources, operatorList).then(function () {
  54907. return operatorList;
  54908. });
  54909. }
  54910. });
  54911. return TextWidgetAnnotation;
  54912. }();
  54913. var ChoiceWidgetAnnotation = function ChoiceWidgetAnnotationClosure() {
  54914. function ChoiceWidgetAnnotation(params) {
  54915. WidgetAnnotation.call(this, params);
  54916. this.data.options = [];
  54917. var options = params.dict.getArray('Opt');
  54918. if (isArray(options)) {
  54919. for (var i = 0, ii = options.length; i < ii; i++) {
  54920. var option = options[i];
  54921. this.data.options[i] = {
  54922. exportValue: isArray(option) ? option[0] : option,
  54923. displayValue: isArray(option) ? option[1] : option
  54924. };
  54925. }
  54926. }
  54927. if (!isArray(this.data.fieldValue)) {
  54928. this.data.fieldValue = [this.data.fieldValue];
  54929. }
  54930. this.data.combo = this.hasFieldFlag(AnnotationFieldFlag.COMBO);
  54931. this.data.multiSelect = this.hasFieldFlag(AnnotationFieldFlag.MULTISELECT);
  54932. }
  54933. Util.inherit(ChoiceWidgetAnnotation, WidgetAnnotation, {
  54934. getOperatorList: function ChoiceWidgetAnnotation_getOperatorList(evaluator, task, renderForms) {
  54935. var operatorList = new OperatorList();
  54936. if (renderForms) {
  54937. return Promise.resolve(operatorList);
  54938. }
  54939. return Annotation.prototype.getOperatorList.call(this, evaluator, task, renderForms);
  54940. }
  54941. });
  54942. return ChoiceWidgetAnnotation;
  54943. }();
  54944. var TextAnnotation = function TextAnnotationClosure() {
  54945. var DEFAULT_ICON_SIZE = 22;
  54946. function TextAnnotation(parameters) {
  54947. Annotation.call(this, parameters);
  54948. this.data.annotationType = AnnotationType.TEXT;
  54949. if (this.data.hasAppearance) {
  54950. this.data.name = 'NoIcon';
  54951. } else {
  54952. this.data.rect[1] = this.data.rect[3] - DEFAULT_ICON_SIZE;
  54953. this.data.rect[2] = this.data.rect[0] + DEFAULT_ICON_SIZE;
  54954. this.data.name = parameters.dict.has('Name') ? parameters.dict.get('Name').name : 'Note';
  54955. }
  54956. this._preparePopup(parameters.dict);
  54957. }
  54958. Util.inherit(TextAnnotation, Annotation, {});
  54959. return TextAnnotation;
  54960. }();
  54961. var LinkAnnotation = function LinkAnnotationClosure() {
  54962. function LinkAnnotation(params) {
  54963. Annotation.call(this, params);
  54964. var data = this.data;
  54965. data.annotationType = AnnotationType.LINK;
  54966. Catalog.parseDestDictionary({
  54967. destDict: params.dict,
  54968. resultObj: data,
  54969. docBaseUrl: params.pdfManager.docBaseUrl
  54970. });
  54971. }
  54972. Util.inherit(LinkAnnotation, Annotation, {});
  54973. return LinkAnnotation;
  54974. }();
  54975. var PopupAnnotation = function PopupAnnotationClosure() {
  54976. function PopupAnnotation(parameters) {
  54977. Annotation.call(this, parameters);
  54978. this.data.annotationType = AnnotationType.POPUP;
  54979. var dict = parameters.dict;
  54980. var parentItem = dict.get('Parent');
  54981. if (!parentItem) {
  54982. warn('Popup annotation has a missing or invalid parent annotation.');
  54983. return;
  54984. }
  54985. this.data.parentId = dict.getRaw('Parent').toString();
  54986. this.data.title = stringToPDFString(parentItem.get('T') || '');
  54987. this.data.contents = stringToPDFString(parentItem.get('Contents') || '');
  54988. if (!parentItem.has('C')) {
  54989. this.data.color = null;
  54990. } else {
  54991. this.setColor(parentItem.getArray('C'));
  54992. this.data.color = this.color;
  54993. }
  54994. if (!this.viewable) {
  54995. var parentFlags = parentItem.get('F');
  54996. if (this._isViewable(parentFlags)) {
  54997. this.setFlags(parentFlags);
  54998. }
  54999. }
  55000. }
  55001. Util.inherit(PopupAnnotation, Annotation, {});
  55002. return PopupAnnotation;
  55003. }();
  55004. var HighlightAnnotation = function HighlightAnnotationClosure() {
  55005. function HighlightAnnotation(parameters) {
  55006. Annotation.call(this, parameters);
  55007. this.data.annotationType = AnnotationType.HIGHLIGHT;
  55008. this._preparePopup(parameters.dict);
  55009. this.data.borderStyle.setWidth(0);
  55010. }
  55011. Util.inherit(HighlightAnnotation, Annotation, {});
  55012. return HighlightAnnotation;
  55013. }();
  55014. var UnderlineAnnotation = function UnderlineAnnotationClosure() {
  55015. function UnderlineAnnotation(parameters) {
  55016. Annotation.call(this, parameters);
  55017. this.data.annotationType = AnnotationType.UNDERLINE;
  55018. this._preparePopup(parameters.dict);
  55019. this.data.borderStyle.setWidth(0);
  55020. }
  55021. Util.inherit(UnderlineAnnotation, Annotation, {});
  55022. return UnderlineAnnotation;
  55023. }();
  55024. var SquigglyAnnotation = function SquigglyAnnotationClosure() {
  55025. function SquigglyAnnotation(parameters) {
  55026. Annotation.call(this, parameters);
  55027. this.data.annotationType = AnnotationType.SQUIGGLY;
  55028. this._preparePopup(parameters.dict);
  55029. this.data.borderStyle.setWidth(0);
  55030. }
  55031. Util.inherit(SquigglyAnnotation, Annotation, {});
  55032. return SquigglyAnnotation;
  55033. }();
  55034. var StrikeOutAnnotation = function StrikeOutAnnotationClosure() {
  55035. function StrikeOutAnnotation(parameters) {
  55036. Annotation.call(this, parameters);
  55037. this.data.annotationType = AnnotationType.STRIKEOUT;
  55038. this._preparePopup(parameters.dict);
  55039. this.data.borderStyle.setWidth(0);
  55040. }
  55041. Util.inherit(StrikeOutAnnotation, Annotation, {});
  55042. return StrikeOutAnnotation;
  55043. }();
  55044. var FileAttachmentAnnotation = function FileAttachmentAnnotationClosure() {
  55045. function FileAttachmentAnnotation(parameters) {
  55046. Annotation.call(this, parameters);
  55047. var file = new FileSpec(parameters.dict.get('FS'), parameters.xref);
  55048. this.data.annotationType = AnnotationType.FILEATTACHMENT;
  55049. this.data.file = file.serializable;
  55050. this._preparePopup(parameters.dict);
  55051. }
  55052. Util.inherit(FileAttachmentAnnotation, Annotation, {});
  55053. return FileAttachmentAnnotation;
  55054. }();
  55055. exports.Annotation = Annotation;
  55056. exports.AnnotationBorderStyle = AnnotationBorderStyle;
  55057. exports.AnnotationFactory = AnnotationFactory;
  55058. }));
  55059. (function (root, factory) {
  55060. factory(root.pdfjsCoreDocument = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCoreStream, root.pdfjsCoreObj, root.pdfjsCoreParser, root.pdfjsCoreCrypto, root.pdfjsCoreEvaluator, root.pdfjsCoreAnnotation);
  55061. }(this, function (exports, sharedUtil, corePrimitives, coreStream, coreObj, coreParser, coreCrypto, coreEvaluator, coreAnnotation) {
  55062. var MissingDataException = sharedUtil.MissingDataException;
  55063. var Util = sharedUtil.Util;
  55064. var assert = sharedUtil.assert;
  55065. var error = sharedUtil.error;
  55066. var info = sharedUtil.info;
  55067. var isArray = sharedUtil.isArray;
  55068. var isArrayBuffer = sharedUtil.isArrayBuffer;
  55069. var isNum = sharedUtil.isNum;
  55070. var isString = sharedUtil.isString;
  55071. var shadow = sharedUtil.shadow;
  55072. var stringToBytes = sharedUtil.stringToBytes;
  55073. var stringToPDFString = sharedUtil.stringToPDFString;
  55074. var warn = sharedUtil.warn;
  55075. var isSpace = sharedUtil.isSpace;
  55076. var Dict = corePrimitives.Dict;
  55077. var isDict = corePrimitives.isDict;
  55078. var isName = corePrimitives.isName;
  55079. var isStream = corePrimitives.isStream;
  55080. var NullStream = coreStream.NullStream;
  55081. var Stream = coreStream.Stream;
  55082. var StreamsSequenceStream = coreStream.StreamsSequenceStream;
  55083. var Catalog = coreObj.Catalog;
  55084. var ObjectLoader = coreObj.ObjectLoader;
  55085. var XRef = coreObj.XRef;
  55086. var Linearization = coreParser.Linearization;
  55087. var calculateMD5 = coreCrypto.calculateMD5;
  55088. var OperatorList = coreEvaluator.OperatorList;
  55089. var PartialEvaluator = coreEvaluator.PartialEvaluator;
  55090. var Annotation = coreAnnotation.Annotation;
  55091. var AnnotationFactory = coreAnnotation.AnnotationFactory;
  55092. var Page = function PageClosure() {
  55093. var DEFAULT_USER_UNIT = 1.0;
  55094. var LETTER_SIZE_MEDIABOX = [
  55095. 0,
  55096. 0,
  55097. 612,
  55098. 792
  55099. ];
  55100. function Page(pdfManager, xref, pageIndex, pageDict, ref, fontCache) {
  55101. this.pdfManager = pdfManager;
  55102. this.pageIndex = pageIndex;
  55103. this.pageDict = pageDict;
  55104. this.xref = xref;
  55105. this.ref = ref;
  55106. this.fontCache = fontCache;
  55107. this.uniquePrefix = 'p' + this.pageIndex + '_';
  55108. this.idCounters = { obj: 0 };
  55109. this.evaluatorOptions = pdfManager.evaluatorOptions;
  55110. this.resourcesPromise = null;
  55111. }
  55112. Page.prototype = {
  55113. getPageProp: function Page_getPageProp(key) {
  55114. return this.pageDict.get(key);
  55115. },
  55116. getInheritedPageProp: function Page_getInheritedPageProp(key, getArray) {
  55117. var dict = this.pageDict, valueArray = null, loopCount = 0;
  55118. var MAX_LOOP_COUNT = 100;
  55119. getArray = getArray || false;
  55120. while (dict) {
  55121. var value = getArray ? dict.getArray(key) : dict.get(key);
  55122. if (value) {
  55123. if (!valueArray) {
  55124. valueArray = [];
  55125. }
  55126. valueArray.push(value);
  55127. }
  55128. if (++loopCount > MAX_LOOP_COUNT) {
  55129. warn('Page_getInheritedPageProp: maximum loop count exceeded.');
  55130. break;
  55131. }
  55132. dict = dict.get('Parent');
  55133. }
  55134. if (!valueArray) {
  55135. return Dict.empty;
  55136. }
  55137. if (valueArray.length === 1 || !isDict(valueArray[0]) || loopCount > MAX_LOOP_COUNT) {
  55138. return valueArray[0];
  55139. }
  55140. return Dict.merge(this.xref, valueArray);
  55141. },
  55142. get content() {
  55143. return this.getPageProp('Contents');
  55144. },
  55145. get resources() {
  55146. return shadow(this, 'resources', this.getInheritedPageProp('Resources'));
  55147. },
  55148. get mediaBox() {
  55149. var mediaBox = this.getInheritedPageProp('MediaBox', true);
  55150. if (!isArray(mediaBox) || mediaBox.length !== 4) {
  55151. return shadow(this, 'mediaBox', LETTER_SIZE_MEDIABOX);
  55152. }
  55153. return shadow(this, 'mediaBox', mediaBox);
  55154. },
  55155. get cropBox() {
  55156. var cropBox = this.getInheritedPageProp('CropBox', true);
  55157. if (!isArray(cropBox) || cropBox.length !== 4) {
  55158. return shadow(this, 'cropBox', this.mediaBox);
  55159. }
  55160. return shadow(this, 'cropBox', cropBox);
  55161. },
  55162. get userUnit() {
  55163. var obj = this.getPageProp('UserUnit');
  55164. if (!isNum(obj) || obj <= 0) {
  55165. obj = DEFAULT_USER_UNIT;
  55166. }
  55167. return shadow(this, 'userUnit', obj);
  55168. },
  55169. get view() {
  55170. var mediaBox = this.mediaBox, cropBox = this.cropBox;
  55171. if (mediaBox === cropBox) {
  55172. return shadow(this, 'view', mediaBox);
  55173. }
  55174. var intersection = Util.intersect(cropBox, mediaBox);
  55175. return shadow(this, 'view', intersection || mediaBox);
  55176. },
  55177. get rotate() {
  55178. var rotate = this.getInheritedPageProp('Rotate') || 0;
  55179. if (rotate % 90 !== 0) {
  55180. rotate = 0;
  55181. } else if (rotate >= 360) {
  55182. rotate = rotate % 360;
  55183. } else if (rotate < 0) {
  55184. rotate = (rotate % 360 + 360) % 360;
  55185. }
  55186. return shadow(this, 'rotate', rotate);
  55187. },
  55188. getContentStream: function Page_getContentStream() {
  55189. var content = this.content;
  55190. var stream;
  55191. if (isArray(content)) {
  55192. var xref = this.xref;
  55193. var i, n = content.length;
  55194. var streams = [];
  55195. for (i = 0; i < n; ++i) {
  55196. streams.push(xref.fetchIfRef(content[i]));
  55197. }
  55198. stream = new StreamsSequenceStream(streams);
  55199. } else if (isStream(content)) {
  55200. stream = content;
  55201. } else {
  55202. stream = new NullStream();
  55203. }
  55204. return stream;
  55205. },
  55206. loadResources: function Page_loadResources(keys) {
  55207. if (!this.resourcesPromise) {
  55208. this.resourcesPromise = this.pdfManager.ensure(this, 'resources');
  55209. }
  55210. return this.resourcesPromise.then(function resourceSuccess() {
  55211. var objectLoader = new ObjectLoader(this.resources.map, keys, this.xref);
  55212. return objectLoader.load();
  55213. }.bind(this));
  55214. },
  55215. getOperatorList: function Page_getOperatorList(handler, task, intent, renderInteractiveForms) {
  55216. var self = this;
  55217. var pdfManager = this.pdfManager;
  55218. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55219. var resourcesPromise = this.loadResources([
  55220. 'ExtGState',
  55221. 'ColorSpace',
  55222. 'Pattern',
  55223. 'Shading',
  55224. 'XObject',
  55225. 'Font'
  55226. ]);
  55227. var partialEvaluator = new PartialEvaluator(pdfManager, this.xref, handler, this.pageIndex, this.uniquePrefix, this.idCounters, this.fontCache, this.evaluatorOptions);
  55228. var dataPromises = Promise.all([
  55229. contentStreamPromise,
  55230. resourcesPromise
  55231. ]);
  55232. var pageListPromise = dataPromises.then(function (data) {
  55233. var contentStream = data[0];
  55234. var opList = new OperatorList(intent, handler, self.pageIndex);
  55235. handler.send('StartRenderPage', {
  55236. transparency: partialEvaluator.hasBlendModes(self.resources),
  55237. pageIndex: self.pageIndex,
  55238. intent: intent
  55239. });
  55240. return partialEvaluator.getOperatorList(contentStream, task, self.resources, opList).then(function () {
  55241. return opList;
  55242. });
  55243. });
  55244. var annotationsPromise = pdfManager.ensure(this, 'annotations');
  55245. return Promise.all([
  55246. pageListPromise,
  55247. annotationsPromise
  55248. ]).then(function (datas) {
  55249. var pageOpList = datas[0];
  55250. var annotations = datas[1];
  55251. if (annotations.length === 0) {
  55252. pageOpList.flush(true);
  55253. return pageOpList;
  55254. }
  55255. var annotationsReadyPromise = Annotation.appendToOperatorList(annotations, pageOpList, partialEvaluator, task, intent, renderInteractiveForms);
  55256. return annotationsReadyPromise.then(function () {
  55257. pageOpList.flush(true);
  55258. return pageOpList;
  55259. });
  55260. });
  55261. },
  55262. extractTextContent: function Page_extractTextContent(task, normalizeWhitespace, combineTextItems) {
  55263. var handler = {
  55264. on: function nullHandlerOn() {
  55265. },
  55266. send: function nullHandlerSend() {
  55267. }
  55268. };
  55269. var self = this;
  55270. var pdfManager = this.pdfManager;
  55271. var contentStreamPromise = pdfManager.ensure(this, 'getContentStream', []);
  55272. var resourcesPromise = this.loadResources([
  55273. 'ExtGState',
  55274. 'XObject',
  55275. 'Font'
  55276. ]);
  55277. var dataPromises = Promise.all([
  55278. contentStreamPromise,
  55279. resourcesPromise
  55280. ]);
  55281. return dataPromises.then(function (data) {
  55282. var contentStream = data[0];
  55283. var partialEvaluator = new PartialEvaluator(pdfManager, self.xref, handler, self.pageIndex, self.uniquePrefix, self.idCounters, self.fontCache, self.evaluatorOptions);
  55284. return partialEvaluator.getTextContent(contentStream, task, self.resources, null, normalizeWhitespace, combineTextItems);
  55285. });
  55286. },
  55287. getAnnotationsData: function Page_getAnnotationsData(intent) {
  55288. var annotations = this.annotations;
  55289. var annotationsData = [];
  55290. for (var i = 0, n = annotations.length; i < n; ++i) {
  55291. if (intent) {
  55292. if (!(intent === 'display' && annotations[i].viewable) && !(intent === 'print' && annotations[i].printable)) {
  55293. continue;
  55294. }
  55295. }
  55296. annotationsData.push(annotations[i].data);
  55297. }
  55298. return annotationsData;
  55299. },
  55300. get annotations() {
  55301. var annotations = [];
  55302. var annotationRefs = this.getInheritedPageProp('Annots') || [];
  55303. var annotationFactory = new AnnotationFactory();
  55304. for (var i = 0, n = annotationRefs.length; i < n; ++i) {
  55305. var annotationRef = annotationRefs[i];
  55306. var annotation = annotationFactory.create(this.xref, annotationRef, this.pdfManager, this.uniquePrefix, this.idCounters);
  55307. if (annotation) {
  55308. annotations.push(annotation);
  55309. }
  55310. }
  55311. return shadow(this, 'annotations', annotations);
  55312. }
  55313. };
  55314. return Page;
  55315. }();
  55316. var PDFDocument = function PDFDocumentClosure() {
  55317. var FINGERPRINT_FIRST_BYTES = 1024;
  55318. var EMPTY_FINGERPRINT = '\x00\x00\x00\x00\x00\x00\x00' + '\x00\x00\x00\x00\x00\x00\x00\x00\x00';
  55319. function PDFDocument(pdfManager, arg, password) {
  55320. if (isStream(arg)) {
  55321. init.call(this, pdfManager, arg, password);
  55322. } else if (isArrayBuffer(arg)) {
  55323. init.call(this, pdfManager, new Stream(arg), password);
  55324. } else {
  55325. error('PDFDocument: Unknown argument type');
  55326. }
  55327. }
  55328. function init(pdfManager, stream, password) {
  55329. assert(stream.length > 0, 'stream must have data');
  55330. this.pdfManager = pdfManager;
  55331. this.stream = stream;
  55332. var xref = new XRef(this.stream, password, pdfManager);
  55333. this.xref = xref;
  55334. }
  55335. function find(stream, needle, limit, backwards) {
  55336. var pos = stream.pos;
  55337. var end = stream.end;
  55338. var strBuf = [];
  55339. if (pos + limit > end) {
  55340. limit = end - pos;
  55341. }
  55342. for (var n = 0; n < limit; ++n) {
  55343. strBuf.push(String.fromCharCode(stream.getByte()));
  55344. }
  55345. var str = strBuf.join('');
  55346. stream.pos = pos;
  55347. var index = backwards ? str.lastIndexOf(needle) : str.indexOf(needle);
  55348. if (index === -1) {
  55349. return false;
  55350. }
  55351. stream.pos += index;
  55352. return true;
  55353. }
  55354. var DocumentInfoValidators = {
  55355. get entries() {
  55356. return shadow(this, 'entries', {
  55357. Title: isString,
  55358. Author: isString,
  55359. Subject: isString,
  55360. Keywords: isString,
  55361. Creator: isString,
  55362. Producer: isString,
  55363. CreationDate: isString,
  55364. ModDate: isString,
  55365. Trapped: isName
  55366. });
  55367. }
  55368. };
  55369. PDFDocument.prototype = {
  55370. parse: function PDFDocument_parse(recoveryMode) {
  55371. this.setup(recoveryMode);
  55372. var version = this.catalog.catDict.get('Version');
  55373. if (isName(version)) {
  55374. this.pdfFormatVersion = version.name;
  55375. }
  55376. try {
  55377. this.acroForm = this.catalog.catDict.get('AcroForm');
  55378. if (this.acroForm) {
  55379. this.xfa = this.acroForm.get('XFA');
  55380. var fields = this.acroForm.get('Fields');
  55381. if ((!fields || !isArray(fields) || fields.length === 0) && !this.xfa) {
  55382. this.acroForm = null;
  55383. }
  55384. }
  55385. } catch (ex) {
  55386. info('Something wrong with AcroForm entry');
  55387. this.acroForm = null;
  55388. }
  55389. },
  55390. get linearization() {
  55391. var linearization = null;
  55392. if (this.stream.length) {
  55393. try {
  55394. linearization = Linearization.create(this.stream);
  55395. } catch (err) {
  55396. if (err instanceof MissingDataException) {
  55397. throw err;
  55398. }
  55399. info(err);
  55400. }
  55401. }
  55402. return shadow(this, 'linearization', linearization);
  55403. },
  55404. get startXRef() {
  55405. var stream = this.stream;
  55406. var startXRef = 0;
  55407. var linearization = this.linearization;
  55408. if (linearization) {
  55409. stream.reset();
  55410. if (find(stream, 'endobj', 1024)) {
  55411. startXRef = stream.pos + 6;
  55412. }
  55413. } else {
  55414. var step = 1024;
  55415. var found = false, pos = stream.end;
  55416. while (!found && pos > 0) {
  55417. pos -= step - 'startxref'.length;
  55418. if (pos < 0) {
  55419. pos = 0;
  55420. }
  55421. stream.pos = pos;
  55422. found = find(stream, 'startxref', step, true);
  55423. }
  55424. if (found) {
  55425. stream.skip(9);
  55426. var ch;
  55427. do {
  55428. ch = stream.getByte();
  55429. } while (isSpace(ch));
  55430. var str = '';
  55431. while (ch >= 0x20 && ch <= 0x39) {
  55432. str += String.fromCharCode(ch);
  55433. ch = stream.getByte();
  55434. }
  55435. startXRef = parseInt(str, 10);
  55436. if (isNaN(startXRef)) {
  55437. startXRef = 0;
  55438. }
  55439. }
  55440. }
  55441. return shadow(this, 'startXRef', startXRef);
  55442. },
  55443. get mainXRefEntriesOffset() {
  55444. var mainXRefEntriesOffset = 0;
  55445. var linearization = this.linearization;
  55446. if (linearization) {
  55447. mainXRefEntriesOffset = linearization.mainXRefEntriesOffset;
  55448. }
  55449. return shadow(this, 'mainXRefEntriesOffset', mainXRefEntriesOffset);
  55450. },
  55451. checkHeader: function PDFDocument_checkHeader() {
  55452. var stream = this.stream;
  55453. stream.reset();
  55454. if (find(stream, '%PDF-', 1024)) {
  55455. stream.moveStart();
  55456. var MAX_VERSION_LENGTH = 12;
  55457. var version = '', ch;
  55458. while ((ch = stream.getByte()) > 0x20) {
  55459. if (version.length >= MAX_VERSION_LENGTH) {
  55460. break;
  55461. }
  55462. version += String.fromCharCode(ch);
  55463. }
  55464. if (!this.pdfFormatVersion) {
  55465. this.pdfFormatVersion = version.substring(5);
  55466. }
  55467. return;
  55468. }
  55469. },
  55470. parseStartXRef: function PDFDocument_parseStartXRef() {
  55471. var startXRef = this.startXRef;
  55472. this.xref.setStartXRef(startXRef);
  55473. },
  55474. setup: function PDFDocument_setup(recoveryMode) {
  55475. this.xref.parse(recoveryMode);
  55476. var self = this;
  55477. var pageFactory = {
  55478. createPage: function (pageIndex, dict, ref, fontCache) {
  55479. return new Page(self.pdfManager, self.xref, pageIndex, dict, ref, fontCache);
  55480. }
  55481. };
  55482. this.catalog = new Catalog(this.pdfManager, this.xref, pageFactory);
  55483. },
  55484. get numPages() {
  55485. var linearization = this.linearization;
  55486. var num = linearization ? linearization.numPages : this.catalog.numPages;
  55487. return shadow(this, 'numPages', num);
  55488. },
  55489. get documentInfo() {
  55490. var docInfo = {
  55491. PDFFormatVersion: this.pdfFormatVersion,
  55492. IsAcroFormPresent: !!this.acroForm,
  55493. IsXFAPresent: !!this.xfa
  55494. };
  55495. var infoDict;
  55496. try {
  55497. infoDict = this.xref.trailer.get('Info');
  55498. } catch (err) {
  55499. info('The document information dictionary is invalid.');
  55500. }
  55501. if (infoDict) {
  55502. var validEntries = DocumentInfoValidators.entries;
  55503. for (var key in validEntries) {
  55504. if (infoDict.has(key)) {
  55505. var value = infoDict.get(key);
  55506. if (validEntries[key](value)) {
  55507. docInfo[key] = typeof value !== 'string' ? value : stringToPDFString(value);
  55508. } else {
  55509. info('Bad value in document info for "' + key + '"');
  55510. }
  55511. }
  55512. }
  55513. }
  55514. return shadow(this, 'documentInfo', docInfo);
  55515. },
  55516. get fingerprint() {
  55517. var xref = this.xref, hash, fileID = '';
  55518. var idArray = xref.trailer.get('ID');
  55519. if (idArray && isArray(idArray) && idArray[0] && isString(idArray[0]) && idArray[0] !== EMPTY_FINGERPRINT) {
  55520. hash = stringToBytes(idArray[0]);
  55521. } else {
  55522. if (this.stream.ensureRange) {
  55523. this.stream.ensureRange(0, Math.min(FINGERPRINT_FIRST_BYTES, this.stream.end));
  55524. }
  55525. hash = calculateMD5(this.stream.bytes.subarray(0, FINGERPRINT_FIRST_BYTES), 0, FINGERPRINT_FIRST_BYTES);
  55526. }
  55527. for (var i = 0, n = hash.length; i < n; i++) {
  55528. var hex = hash[i].toString(16);
  55529. fileID += hex.length === 1 ? '0' + hex : hex;
  55530. }
  55531. return shadow(this, 'fingerprint', fileID);
  55532. },
  55533. getPage: function PDFDocument_getPage(pageIndex) {
  55534. return this.catalog.getPage(pageIndex);
  55535. },
  55536. cleanup: function PDFDocument_cleanup() {
  55537. return this.catalog.cleanup();
  55538. }
  55539. };
  55540. return PDFDocument;
  55541. }();
  55542. exports.Page = Page;
  55543. exports.PDFDocument = PDFDocument;
  55544. }));
  55545. (function (root, factory) {
  55546. factory(root.pdfjsCorePdfManager = {}, root.pdfjsSharedUtil, root.pdfjsCoreStream, root.pdfjsCoreChunkedStream, root.pdfjsCoreDocument);
  55547. }(this, function (exports, sharedUtil, coreStream, coreChunkedStream, coreDocument) {
  55548. var warn = sharedUtil.warn;
  55549. var createValidAbsoluteUrl = sharedUtil.createValidAbsoluteUrl;
  55550. var shadow = sharedUtil.shadow;
  55551. var NotImplementedException = sharedUtil.NotImplementedException;
  55552. var MissingDataException = sharedUtil.MissingDataException;
  55553. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55554. var Util = sharedUtil.Util;
  55555. var Stream = coreStream.Stream;
  55556. var ChunkedStreamManager = coreChunkedStream.ChunkedStreamManager;
  55557. var PDFDocument = coreDocument.PDFDocument;
  55558. var BasePdfManager = function BasePdfManagerClosure() {
  55559. function BasePdfManager() {
  55560. throw new Error('Cannot initialize BaseManagerManager');
  55561. }
  55562. BasePdfManager.prototype = {
  55563. get docId() {
  55564. return this._docId;
  55565. },
  55566. get docBaseUrl() {
  55567. var docBaseUrl = null;
  55568. if (this._docBaseUrl) {
  55569. var absoluteUrl = createValidAbsoluteUrl(this._docBaseUrl);
  55570. if (absoluteUrl) {
  55571. docBaseUrl = absoluteUrl.href;
  55572. } else {
  55573. warn('Invalid absolute docBaseUrl: "' + this._docBaseUrl + '".');
  55574. }
  55575. }
  55576. return shadow(this, 'docBaseUrl', docBaseUrl);
  55577. },
  55578. onLoadedStream: function BasePdfManager_onLoadedStream() {
  55579. throw new NotImplementedException();
  55580. },
  55581. ensureDoc: function BasePdfManager_ensureDoc(prop, args) {
  55582. return this.ensure(this.pdfDocument, prop, args);
  55583. },
  55584. ensureXRef: function BasePdfManager_ensureXRef(prop, args) {
  55585. return this.ensure(this.pdfDocument.xref, prop, args);
  55586. },
  55587. ensureCatalog: function BasePdfManager_ensureCatalog(prop, args) {
  55588. return this.ensure(this.pdfDocument.catalog, prop, args);
  55589. },
  55590. getPage: function BasePdfManager_getPage(pageIndex) {
  55591. return this.pdfDocument.getPage(pageIndex);
  55592. },
  55593. cleanup: function BasePdfManager_cleanup() {
  55594. return this.pdfDocument.cleanup();
  55595. },
  55596. ensure: function BasePdfManager_ensure(obj, prop, args) {
  55597. return new NotImplementedException();
  55598. },
  55599. requestRange: function BasePdfManager_requestRange(begin, end) {
  55600. return new NotImplementedException();
  55601. },
  55602. requestLoadedStream: function BasePdfManager_requestLoadedStream() {
  55603. return new NotImplementedException();
  55604. },
  55605. sendProgressiveData: function BasePdfManager_sendProgressiveData(chunk) {
  55606. return new NotImplementedException();
  55607. },
  55608. updatePassword: function BasePdfManager_updatePassword(password) {
  55609. this.pdfDocument.xref.password = this.password = password;
  55610. if (this._passwordChangedCapability) {
  55611. this._passwordChangedCapability.resolve();
  55612. }
  55613. },
  55614. passwordChanged: function BasePdfManager_passwordChanged() {
  55615. this._passwordChangedCapability = createPromiseCapability();
  55616. return this._passwordChangedCapability.promise;
  55617. },
  55618. terminate: function BasePdfManager_terminate() {
  55619. return new NotImplementedException();
  55620. }
  55621. };
  55622. return BasePdfManager;
  55623. }();
  55624. var LocalPdfManager = function LocalPdfManagerClosure() {
  55625. function LocalPdfManager(docId, data, password, evaluatorOptions, docBaseUrl) {
  55626. this._docId = docId;
  55627. this._docBaseUrl = docBaseUrl;
  55628. this.evaluatorOptions = evaluatorOptions;
  55629. var stream = new Stream(data);
  55630. this.pdfDocument = new PDFDocument(this, stream, password);
  55631. this._loadedStreamCapability = createPromiseCapability();
  55632. this._loadedStreamCapability.resolve(stream);
  55633. }
  55634. Util.inherit(LocalPdfManager, BasePdfManager, {
  55635. ensure: function LocalPdfManager_ensure(obj, prop, args) {
  55636. return new Promise(function (resolve, reject) {
  55637. try {
  55638. var value = obj[prop];
  55639. var result;
  55640. if (typeof value === 'function') {
  55641. result = value.apply(obj, args);
  55642. } else {
  55643. result = value;
  55644. }
  55645. resolve(result);
  55646. } catch (e) {
  55647. reject(e);
  55648. }
  55649. });
  55650. },
  55651. requestRange: function LocalPdfManager_requestRange(begin, end) {
  55652. return Promise.resolve();
  55653. },
  55654. requestLoadedStream: function LocalPdfManager_requestLoadedStream() {
  55655. return;
  55656. },
  55657. onLoadedStream: function LocalPdfManager_onLoadedStream() {
  55658. return this._loadedStreamCapability.promise;
  55659. },
  55660. terminate: function LocalPdfManager_terminate() {
  55661. return;
  55662. }
  55663. });
  55664. return LocalPdfManager;
  55665. }();
  55666. var NetworkPdfManager = function NetworkPdfManagerClosure() {
  55667. function NetworkPdfManager(docId, pdfNetworkStream, args, evaluatorOptions, docBaseUrl) {
  55668. this._docId = docId;
  55669. this._docBaseUrl = docBaseUrl;
  55670. this.msgHandler = args.msgHandler;
  55671. this.evaluatorOptions = evaluatorOptions;
  55672. var params = {
  55673. msgHandler: args.msgHandler,
  55674. url: args.url,
  55675. length: args.length,
  55676. disableAutoFetch: args.disableAutoFetch,
  55677. rangeChunkSize: args.rangeChunkSize
  55678. };
  55679. this.streamManager = new ChunkedStreamManager(pdfNetworkStream, params);
  55680. this.pdfDocument = new PDFDocument(this, this.streamManager.getStream(), args.password);
  55681. }
  55682. Util.inherit(NetworkPdfManager, BasePdfManager, {
  55683. ensure: function NetworkPdfManager_ensure(obj, prop, args) {
  55684. var pdfManager = this;
  55685. return new Promise(function (resolve, reject) {
  55686. function ensureHelper() {
  55687. try {
  55688. var result;
  55689. var value = obj[prop];
  55690. if (typeof value === 'function') {
  55691. result = value.apply(obj, args);
  55692. } else {
  55693. result = value;
  55694. }
  55695. resolve(result);
  55696. } catch (e) {
  55697. if (!(e instanceof MissingDataException)) {
  55698. reject(e);
  55699. return;
  55700. }
  55701. pdfManager.streamManager.requestRange(e.begin, e.end).then(ensureHelper, reject);
  55702. }
  55703. }
  55704. ensureHelper();
  55705. });
  55706. },
  55707. requestRange: function NetworkPdfManager_requestRange(begin, end) {
  55708. return this.streamManager.requestRange(begin, end);
  55709. },
  55710. requestLoadedStream: function NetworkPdfManager_requestLoadedStream() {
  55711. this.streamManager.requestAllChunks();
  55712. },
  55713. sendProgressiveData: function NetworkPdfManager_sendProgressiveData(chunk) {
  55714. this.streamManager.onReceiveData({ chunk: chunk });
  55715. },
  55716. onLoadedStream: function NetworkPdfManager_onLoadedStream() {
  55717. return this.streamManager.onLoadedStream();
  55718. },
  55719. terminate: function NetworkPdfManager_terminate() {
  55720. this.streamManager.abort();
  55721. }
  55722. });
  55723. return NetworkPdfManager;
  55724. }();
  55725. exports.LocalPdfManager = LocalPdfManager;
  55726. exports.NetworkPdfManager = NetworkPdfManager;
  55727. }));
  55728. (function (root, factory) {
  55729. factory(root.pdfjsCoreWorker = {}, root.pdfjsSharedUtil, root.pdfjsCorePrimitives, root.pdfjsCorePdfManager);
  55730. }(this, function (exports, sharedUtil, corePrimitives, corePdfManager) {
  55731. var UNSUPPORTED_FEATURES = sharedUtil.UNSUPPORTED_FEATURES;
  55732. var InvalidPDFException = sharedUtil.InvalidPDFException;
  55733. var MessageHandler = sharedUtil.MessageHandler;
  55734. var MissingPDFException = sharedUtil.MissingPDFException;
  55735. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  55736. var PasswordException = sharedUtil.PasswordException;
  55737. var PasswordResponses = sharedUtil.PasswordResponses;
  55738. var UnknownErrorException = sharedUtil.UnknownErrorException;
  55739. var XRefParseException = sharedUtil.XRefParseException;
  55740. var arrayByteLength = sharedUtil.arrayByteLength;
  55741. var arraysToBytes = sharedUtil.arraysToBytes;
  55742. var assert = sharedUtil.assert;
  55743. var createPromiseCapability = sharedUtil.createPromiseCapability;
  55744. var error = sharedUtil.error;
  55745. var info = sharedUtil.info;
  55746. var warn = sharedUtil.warn;
  55747. var setVerbosityLevel = sharedUtil.setVerbosityLevel;
  55748. var Ref = corePrimitives.Ref;
  55749. var LocalPdfManager = corePdfManager.LocalPdfManager;
  55750. var NetworkPdfManager = corePdfManager.NetworkPdfManager;
  55751. var globalScope = sharedUtil.globalScope;
  55752. var WorkerTask = function WorkerTaskClosure() {
  55753. function WorkerTask(name) {
  55754. this.name = name;
  55755. this.terminated = false;
  55756. this._capability = createPromiseCapability();
  55757. }
  55758. WorkerTask.prototype = {
  55759. get finished() {
  55760. return this._capability.promise;
  55761. },
  55762. finish: function () {
  55763. this._capability.resolve();
  55764. },
  55765. terminate: function () {
  55766. this.terminated = true;
  55767. },
  55768. ensureNotTerminated: function () {
  55769. if (this.terminated) {
  55770. throw new Error('Worker task was terminated');
  55771. }
  55772. }
  55773. };
  55774. return WorkerTask;
  55775. }();
  55776. var PDFWorkerStream = function PDFWorkerStreamClosure() {
  55777. function PDFWorkerStream(params, msgHandler) {
  55778. this._queuedChunks = [];
  55779. var initialData = params.initialData;
  55780. if (initialData && initialData.length > 0) {
  55781. this._queuedChunks.push(initialData);
  55782. }
  55783. this._msgHandler = msgHandler;
  55784. this._isRangeSupported = !params.disableRange;
  55785. this._isStreamingSupported = !params.disableStream;
  55786. this._contentLength = params.length;
  55787. this._fullRequestReader = null;
  55788. this._rangeReaders = [];
  55789. msgHandler.on('OnDataRange', this._onReceiveData.bind(this));
  55790. msgHandler.on('OnDataProgress', this._onProgress.bind(this));
  55791. }
  55792. PDFWorkerStream.prototype = {
  55793. _onReceiveData: function PDFWorkerStream_onReceiveData(args) {
  55794. if (args.begin === undefined) {
  55795. if (this._fullRequestReader) {
  55796. this._fullRequestReader._enqueue(args.chunk);
  55797. } else {
  55798. this._queuedChunks.push(args.chunk);
  55799. }
  55800. } else {
  55801. var found = this._rangeReaders.some(function (rangeReader) {
  55802. if (rangeReader._begin !== args.begin) {
  55803. return false;
  55804. }
  55805. rangeReader._enqueue(args.chunk);
  55806. return true;
  55807. });
  55808. assert(found);
  55809. }
  55810. },
  55811. _onProgress: function PDFWorkerStream_onProgress(evt) {
  55812. if (this._rangeReaders.length > 0) {
  55813. var firstReader = this._rangeReaders[0];
  55814. if (firstReader.onProgress) {
  55815. firstReader.onProgress({ loaded: evt.loaded });
  55816. }
  55817. }
  55818. },
  55819. _removeRangeReader: function PDFWorkerStream_removeRangeReader(reader) {
  55820. var i = this._rangeReaders.indexOf(reader);
  55821. if (i >= 0) {
  55822. this._rangeReaders.splice(i, 1);
  55823. }
  55824. },
  55825. getFullReader: function PDFWorkerStream_getFullReader() {
  55826. assert(!this._fullRequestReader);
  55827. var queuedChunks = this._queuedChunks;
  55828. this._queuedChunks = null;
  55829. return new PDFWorkerStreamReader(this, queuedChunks);
  55830. },
  55831. getRangeReader: function PDFWorkerStream_getRangeReader(begin, end) {
  55832. var reader = new PDFWorkerStreamRangeReader(this, begin, end);
  55833. this._msgHandler.send('RequestDataRange', {
  55834. begin: begin,
  55835. end: end
  55836. });
  55837. this._rangeReaders.push(reader);
  55838. return reader;
  55839. },
  55840. cancelAllRequests: function PDFWorkerStream_cancelAllRequests(reason) {
  55841. if (this._fullRequestReader) {
  55842. this._fullRequestReader.cancel(reason);
  55843. }
  55844. var readers = this._rangeReaders.slice(0);
  55845. readers.forEach(function (rangeReader) {
  55846. rangeReader.cancel(reason);
  55847. });
  55848. }
  55849. };
  55850. function PDFWorkerStreamReader(stream, queuedChunks) {
  55851. this._stream = stream;
  55852. this._done = false;
  55853. this._queuedChunks = queuedChunks || [];
  55854. this._requests = [];
  55855. this._headersReady = Promise.resolve();
  55856. stream._fullRequestReader = this;
  55857. this.onProgress = null;
  55858. }
  55859. PDFWorkerStreamReader.prototype = {
  55860. _enqueue: function PDFWorkerStreamReader_enqueue(chunk) {
  55861. if (this._done) {
  55862. return;
  55863. }
  55864. if (this._requests.length > 0) {
  55865. var requestCapability = this._requests.shift();
  55866. requestCapability.resolve({
  55867. value: chunk,
  55868. done: false
  55869. });
  55870. return;
  55871. }
  55872. this._queuedChunks.push(chunk);
  55873. },
  55874. get headersReady() {
  55875. return this._headersReady;
  55876. },
  55877. get isRangeSupported() {
  55878. return this._stream._isRangeSupported;
  55879. },
  55880. get isStreamingSupported() {
  55881. return this._stream._isStreamingSupported;
  55882. },
  55883. get contentLength() {
  55884. return this._stream._contentLength;
  55885. },
  55886. read: function PDFWorkerStreamReader_read() {
  55887. if (this._queuedChunks.length > 0) {
  55888. var chunk = this._queuedChunks.shift();
  55889. return Promise.resolve({
  55890. value: chunk,
  55891. done: false
  55892. });
  55893. }
  55894. if (this._done) {
  55895. return Promise.resolve({
  55896. value: undefined,
  55897. done: true
  55898. });
  55899. }
  55900. var requestCapability = createPromiseCapability();
  55901. this._requests.push(requestCapability);
  55902. return requestCapability.promise;
  55903. },
  55904. cancel: function PDFWorkerStreamReader_cancel(reason) {
  55905. this._done = true;
  55906. this._requests.forEach(function (requestCapability) {
  55907. requestCapability.resolve({
  55908. value: undefined,
  55909. done: true
  55910. });
  55911. });
  55912. this._requests = [];
  55913. }
  55914. };
  55915. function PDFWorkerStreamRangeReader(stream, begin, end) {
  55916. this._stream = stream;
  55917. this._begin = begin;
  55918. this._end = end;
  55919. this._queuedChunk = null;
  55920. this._requests = [];
  55921. this._done = false;
  55922. this.onProgress = null;
  55923. }
  55924. PDFWorkerStreamRangeReader.prototype = {
  55925. _enqueue: function PDFWorkerStreamRangeReader_enqueue(chunk) {
  55926. if (this._done) {
  55927. return;
  55928. }
  55929. if (this._requests.length === 0) {
  55930. this._queuedChunk = chunk;
  55931. } else {
  55932. var requestsCapability = this._requests.shift();
  55933. requestsCapability.resolve({
  55934. value: chunk,
  55935. done: false
  55936. });
  55937. this._requests.forEach(function (requestCapability) {
  55938. requestCapability.resolve({
  55939. value: undefined,
  55940. done: true
  55941. });
  55942. });
  55943. this._requests = [];
  55944. }
  55945. this._done = true;
  55946. this._stream._removeRangeReader(this);
  55947. },
  55948. get isStreamingSupported() {
  55949. return false;
  55950. },
  55951. read: function PDFWorkerStreamRangeReader_read() {
  55952. if (this._queuedChunk) {
  55953. return Promise.resolve({
  55954. value: this._queuedChunk,
  55955. done: false
  55956. });
  55957. }
  55958. if (this._done) {
  55959. return Promise.resolve({
  55960. value: undefined,
  55961. done: true
  55962. });
  55963. }
  55964. var requestCapability = createPromiseCapability();
  55965. this._requests.push(requestCapability);
  55966. return requestCapability.promise;
  55967. },
  55968. cancel: function PDFWorkerStreamRangeReader_cancel(reason) {
  55969. this._done = true;
  55970. this._requests.forEach(function (requestCapability) {
  55971. requestCapability.resolve({
  55972. value: undefined,
  55973. done: true
  55974. });
  55975. });
  55976. this._requests = [];
  55977. this._stream._removeRangeReader(this);
  55978. }
  55979. };
  55980. return PDFWorkerStream;
  55981. }();
  55982. var PDFNetworkStream;
  55983. function setPDFNetworkStreamClass(cls) {
  55984. PDFNetworkStream = cls;
  55985. }
  55986. var WorkerMessageHandler = {
  55987. setup: function wphSetup(handler, port) {
  55988. var testMessageProcessed = false;
  55989. handler.on('test', function wphSetupTest(data) {
  55990. if (testMessageProcessed) {
  55991. return;
  55992. }
  55993. testMessageProcessed = true;
  55994. if (!(data instanceof Uint8Array)) {
  55995. handler.send('test', 'main', false);
  55996. return;
  55997. }
  55998. var supportTransfers = data[0] === 255;
  55999. handler.postMessageTransfers = supportTransfers;
  56000. var xhr = new XMLHttpRequest();
  56001. var responseExists = 'response' in xhr;
  56002. try {
  56003. var dummy = xhr.responseType;
  56004. } catch (e) {
  56005. responseExists = false;
  56006. }
  56007. if (!responseExists) {
  56008. handler.send('test', false);
  56009. return;
  56010. }
  56011. handler.send('test', {
  56012. supportTypedArray: true,
  56013. supportTransfers: supportTransfers
  56014. });
  56015. });
  56016. handler.on('configure', function wphConfigure(data) {
  56017. setVerbosityLevel(data.verbosity);
  56018. });
  56019. handler.on('GetDocRequest', function wphSetupDoc(data) {
  56020. return WorkerMessageHandler.createDocumentHandler(data, port);
  56021. });
  56022. },
  56023. createDocumentHandler: function wphCreateDocumentHandler(docParams, port) {
  56024. var pdfManager;
  56025. var terminated = false;
  56026. var cancelXHRs = null;
  56027. var WorkerTasks = [];
  56028. var docId = docParams.docId;
  56029. var docBaseUrl = docParams.docBaseUrl;
  56030. var workerHandlerName = docParams.docId + '_worker';
  56031. var handler = new MessageHandler(workerHandlerName, docId, port);
  56032. handler.postMessageTransfers = docParams.postMessageTransfers;
  56033. function ensureNotTerminated() {
  56034. if (terminated) {
  56035. throw new Error('Worker was terminated');
  56036. }
  56037. }
  56038. function startWorkerTask(task) {
  56039. WorkerTasks.push(task);
  56040. }
  56041. function finishWorkerTask(task) {
  56042. task.finish();
  56043. var i = WorkerTasks.indexOf(task);
  56044. WorkerTasks.splice(i, 1);
  56045. }
  56046. function loadDocument(recoveryMode) {
  56047. var loadDocumentCapability = createPromiseCapability();
  56048. var parseSuccess = function parseSuccess() {
  56049. var numPagesPromise = pdfManager.ensureDoc('numPages');
  56050. var fingerprintPromise = pdfManager.ensureDoc('fingerprint');
  56051. var encryptedPromise = pdfManager.ensureXRef('encrypt');
  56052. Promise.all([
  56053. numPagesPromise,
  56054. fingerprintPromise,
  56055. encryptedPromise
  56056. ]).then(function onDocReady(results) {
  56057. var doc = {
  56058. numPages: results[0],
  56059. fingerprint: results[1],
  56060. encrypted: !!results[2]
  56061. };
  56062. loadDocumentCapability.resolve(doc);
  56063. }, parseFailure);
  56064. };
  56065. var parseFailure = function parseFailure(e) {
  56066. loadDocumentCapability.reject(e);
  56067. };
  56068. pdfManager.ensureDoc('checkHeader', []).then(function () {
  56069. pdfManager.ensureDoc('parseStartXRef', []).then(function () {
  56070. pdfManager.ensureDoc('parse', [recoveryMode]).then(parseSuccess, parseFailure);
  56071. }, parseFailure);
  56072. }, parseFailure);
  56073. return loadDocumentCapability.promise;
  56074. }
  56075. function getPdfManager(data, evaluatorOptions) {
  56076. var pdfManagerCapability = createPromiseCapability();
  56077. var pdfManager;
  56078. var source = data.source;
  56079. if (source.data) {
  56080. try {
  56081. pdfManager = new LocalPdfManager(docId, source.data, source.password, evaluatorOptions, docBaseUrl);
  56082. pdfManagerCapability.resolve(pdfManager);
  56083. } catch (ex) {
  56084. pdfManagerCapability.reject(ex);
  56085. }
  56086. return pdfManagerCapability.promise;
  56087. }
  56088. var pdfStream;
  56089. try {
  56090. if (source.chunkedViewerLoading) {
  56091. pdfStream = new PDFWorkerStream(source, handler);
  56092. } else {
  56093. assert(PDFNetworkStream, 'pdfjs/core/network module is not loaded');
  56094. pdfStream = new PDFNetworkStream(data);
  56095. }
  56096. } catch (ex) {
  56097. pdfManagerCapability.reject(ex);
  56098. return pdfManagerCapability.promise;
  56099. }
  56100. var fullRequest = pdfStream.getFullReader();
  56101. fullRequest.headersReady.then(function () {
  56102. if (!fullRequest.isStreamingSupported || !fullRequest.isRangeSupported) {
  56103. fullRequest.onProgress = function (evt) {
  56104. handler.send('DocProgress', {
  56105. loaded: evt.loaded,
  56106. total: evt.total
  56107. });
  56108. };
  56109. }
  56110. if (!fullRequest.isRangeSupported) {
  56111. return;
  56112. }
  56113. var disableAutoFetch = source.disableAutoFetch || fullRequest.isStreamingSupported;
  56114. pdfManager = new NetworkPdfManager(docId, pdfStream, {
  56115. msgHandler: handler,
  56116. url: source.url,
  56117. password: source.password,
  56118. length: fullRequest.contentLength,
  56119. disableAutoFetch: disableAutoFetch,
  56120. rangeChunkSize: source.rangeChunkSize
  56121. }, evaluatorOptions, docBaseUrl);
  56122. pdfManagerCapability.resolve(pdfManager);
  56123. cancelXHRs = null;
  56124. }).catch(function (reason) {
  56125. pdfManagerCapability.reject(reason);
  56126. cancelXHRs = null;
  56127. });
  56128. var cachedChunks = [], loaded = 0;
  56129. var flushChunks = function () {
  56130. var pdfFile = arraysToBytes(cachedChunks);
  56131. if (source.length && pdfFile.length !== source.length) {
  56132. warn('reported HTTP length is different from actual');
  56133. }
  56134. try {
  56135. pdfManager = new LocalPdfManager(docId, pdfFile, source.password, evaluatorOptions, docBaseUrl);
  56136. pdfManagerCapability.resolve(pdfManager);
  56137. } catch (ex) {
  56138. pdfManagerCapability.reject(ex);
  56139. }
  56140. cachedChunks = [];
  56141. };
  56142. var readPromise = new Promise(function (resolve, reject) {
  56143. var readChunk = function (chunk) {
  56144. try {
  56145. ensureNotTerminated();
  56146. if (chunk.done) {
  56147. if (!pdfManager) {
  56148. flushChunks();
  56149. }
  56150. cancelXHRs = null;
  56151. return;
  56152. }
  56153. var data = chunk.value;
  56154. loaded += arrayByteLength(data);
  56155. if (!fullRequest.isStreamingSupported) {
  56156. handler.send('DocProgress', {
  56157. loaded: loaded,
  56158. total: Math.max(loaded, fullRequest.contentLength || 0)
  56159. });
  56160. }
  56161. if (pdfManager) {
  56162. pdfManager.sendProgressiveData(data);
  56163. } else {
  56164. cachedChunks.push(data);
  56165. }
  56166. fullRequest.read().then(readChunk, reject);
  56167. } catch (e) {
  56168. reject(e);
  56169. }
  56170. };
  56171. fullRequest.read().then(readChunk, reject);
  56172. });
  56173. readPromise.catch(function (e) {
  56174. pdfManagerCapability.reject(e);
  56175. cancelXHRs = null;
  56176. });
  56177. cancelXHRs = function () {
  56178. pdfStream.cancelAllRequests('abort');
  56179. };
  56180. return pdfManagerCapability.promise;
  56181. }
  56182. var setupDoc = function (data) {
  56183. var onSuccess = function (doc) {
  56184. ensureNotTerminated();
  56185. handler.send('GetDoc', { pdfInfo: doc });
  56186. };
  56187. var onFailure = function (e) {
  56188. if (e instanceof PasswordException) {
  56189. if (e.code === PasswordResponses.NEED_PASSWORD) {
  56190. handler.send('NeedPassword', e);
  56191. } else if (e.code === PasswordResponses.INCORRECT_PASSWORD) {
  56192. handler.send('IncorrectPassword', e);
  56193. }
  56194. } else if (e instanceof InvalidPDFException) {
  56195. handler.send('InvalidPDF', e);
  56196. } else if (e instanceof MissingPDFException) {
  56197. handler.send('MissingPDF', e);
  56198. } else if (e instanceof UnexpectedResponseException) {
  56199. handler.send('UnexpectedResponse', e);
  56200. } else {
  56201. handler.send('UnknownError', new UnknownErrorException(e.message, e.toString()));
  56202. }
  56203. };
  56204. ensureNotTerminated();
  56205. var cMapOptions = {
  56206. url: data.cMapUrl === undefined ? null : data.cMapUrl,
  56207. packed: data.cMapPacked === true
  56208. };
  56209. var evaluatorOptions = {
  56210. forceDataSchema: data.disableCreateObjectURL,
  56211. maxImageSize: data.maxImageSize === undefined ? -1 : data.maxImageSize,
  56212. disableFontFace: data.disableFontFace,
  56213. cMapOptions: cMapOptions
  56214. };
  56215. getPdfManager(data, evaluatorOptions).then(function (newPdfManager) {
  56216. if (terminated) {
  56217. newPdfManager.terminate();
  56218. throw new Error('Worker was terminated');
  56219. }
  56220. pdfManager = newPdfManager;
  56221. handler.send('PDFManagerReady', null);
  56222. pdfManager.onLoadedStream().then(function (stream) {
  56223. handler.send('DataLoaded', { length: stream.bytes.byteLength });
  56224. });
  56225. }).then(function pdfManagerReady() {
  56226. ensureNotTerminated();
  56227. loadDocument(false).then(onSuccess, function loadFailure(ex) {
  56228. ensureNotTerminated();
  56229. if (!(ex instanceof XRefParseException)) {
  56230. if (ex instanceof PasswordException) {
  56231. pdfManager.passwordChanged().then(pdfManagerReady);
  56232. }
  56233. onFailure(ex);
  56234. return;
  56235. }
  56236. pdfManager.requestLoadedStream();
  56237. pdfManager.onLoadedStream().then(function () {
  56238. ensureNotTerminated();
  56239. loadDocument(true).then(onSuccess, onFailure);
  56240. });
  56241. }, onFailure);
  56242. }, onFailure);
  56243. };
  56244. handler.on('GetPage', function wphSetupGetPage(data) {
  56245. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56246. var rotatePromise = pdfManager.ensure(page, 'rotate');
  56247. var refPromise = pdfManager.ensure(page, 'ref');
  56248. var userUnitPromise = pdfManager.ensure(page, 'userUnit');
  56249. var viewPromise = pdfManager.ensure(page, 'view');
  56250. return Promise.all([
  56251. rotatePromise,
  56252. refPromise,
  56253. userUnitPromise,
  56254. viewPromise
  56255. ]).then(function (results) {
  56256. return {
  56257. rotate: results[0],
  56258. ref: results[1],
  56259. userUnit: results[2],
  56260. view: results[3]
  56261. };
  56262. });
  56263. });
  56264. });
  56265. handler.on('GetPageIndex', function wphSetupGetPageIndex(data) {
  56266. var ref = new Ref(data.ref.num, data.ref.gen);
  56267. var catalog = pdfManager.pdfDocument.catalog;
  56268. return catalog.getPageIndex(ref);
  56269. });
  56270. handler.on('GetDestinations', function wphSetupGetDestinations(data) {
  56271. return pdfManager.ensureCatalog('destinations');
  56272. });
  56273. handler.on('GetDestination', function wphSetupGetDestination(data) {
  56274. return pdfManager.ensureCatalog('getDestination', [data.id]);
  56275. });
  56276. handler.on('GetPageLabels', function wphSetupGetPageLabels(data) {
  56277. return pdfManager.ensureCatalog('pageLabels');
  56278. });
  56279. handler.on('GetAttachments', function wphSetupGetAttachments(data) {
  56280. return pdfManager.ensureCatalog('attachments');
  56281. });
  56282. handler.on('GetJavaScript', function wphSetupGetJavaScript(data) {
  56283. return pdfManager.ensureCatalog('javaScript');
  56284. });
  56285. handler.on('GetOutline', function wphSetupGetOutline(data) {
  56286. return pdfManager.ensureCatalog('documentOutline');
  56287. });
  56288. handler.on('GetMetadata', function wphSetupGetMetadata(data) {
  56289. return Promise.all([
  56290. pdfManager.ensureDoc('documentInfo'),
  56291. pdfManager.ensureCatalog('metadata')
  56292. ]);
  56293. });
  56294. handler.on('GetData', function wphSetupGetData(data) {
  56295. pdfManager.requestLoadedStream();
  56296. return pdfManager.onLoadedStream().then(function (stream) {
  56297. return stream.bytes;
  56298. });
  56299. });
  56300. handler.on('GetStats', function wphSetupGetStats(data) {
  56301. return pdfManager.pdfDocument.xref.stats;
  56302. });
  56303. handler.on('UpdatePassword', function wphSetupUpdatePassword(data) {
  56304. pdfManager.updatePassword(data);
  56305. });
  56306. handler.on('GetAnnotations', function wphSetupGetAnnotations(data) {
  56307. return pdfManager.getPage(data.pageIndex).then(function (page) {
  56308. return pdfManager.ensure(page, 'getAnnotationsData', [data.intent]);
  56309. });
  56310. });
  56311. handler.on('RenderPageRequest', function wphSetupRenderPage(data) {
  56312. var pageIndex = data.pageIndex;
  56313. pdfManager.getPage(pageIndex).then(function (page) {
  56314. var task = new WorkerTask('RenderPageRequest: page ' + pageIndex);
  56315. startWorkerTask(task);
  56316. var pageNum = pageIndex + 1;
  56317. var start = Date.now();
  56318. page.getOperatorList(handler, task, data.intent, data.renderInteractiveForms).then(function (operatorList) {
  56319. finishWorkerTask(task);
  56320. info('page=' + pageNum + ' - getOperatorList: time=' + (Date.now() - start) + 'ms, len=' + operatorList.totalLength);
  56321. }, function (e) {
  56322. finishWorkerTask(task);
  56323. if (task.terminated) {
  56324. return;
  56325. }
  56326. handler.send('UnsupportedFeature', { featureId: UNSUPPORTED_FEATURES.unknown });
  56327. var minimumStackMessage = 'worker.js: while trying to getPage() and getOperatorList()';
  56328. var wrappedException;
  56329. if (typeof e === 'string') {
  56330. wrappedException = {
  56331. message: e,
  56332. stack: minimumStackMessage
  56333. };
  56334. } else if (typeof e === 'object') {
  56335. wrappedException = {
  56336. message: e.message || e.toString(),
  56337. stack: e.stack || minimumStackMessage
  56338. };
  56339. } else {
  56340. wrappedException = {
  56341. message: 'Unknown exception type: ' + typeof e,
  56342. stack: minimumStackMessage
  56343. };
  56344. }
  56345. handler.send('PageError', {
  56346. pageNum: pageNum,
  56347. error: wrappedException,
  56348. intent: data.intent
  56349. });
  56350. });
  56351. });
  56352. }, this);
  56353. handler.on('GetTextContent', function wphExtractText(data) {
  56354. var pageIndex = data.pageIndex;
  56355. var normalizeWhitespace = data.normalizeWhitespace;
  56356. var combineTextItems = data.combineTextItems;
  56357. return pdfManager.getPage(pageIndex).then(function (page) {
  56358. var task = new WorkerTask('GetTextContent: page ' + pageIndex);
  56359. startWorkerTask(task);
  56360. var pageNum = pageIndex + 1;
  56361. var start = Date.now();
  56362. return page.extractTextContent(task, normalizeWhitespace, combineTextItems).then(function (textContent) {
  56363. finishWorkerTask(task);
  56364. info('text indexing: page=' + pageNum + ' - time=' + (Date.now() - start) + 'ms');
  56365. return textContent;
  56366. }, function (reason) {
  56367. finishWorkerTask(task);
  56368. if (task.terminated) {
  56369. return;
  56370. }
  56371. throw reason;
  56372. });
  56373. });
  56374. });
  56375. handler.on('Cleanup', function wphCleanup(data) {
  56376. return pdfManager.cleanup();
  56377. });
  56378. handler.on('Terminate', function wphTerminate(data) {
  56379. terminated = true;
  56380. if (pdfManager) {
  56381. pdfManager.terminate();
  56382. pdfManager = null;
  56383. }
  56384. if (cancelXHRs) {
  56385. cancelXHRs();
  56386. }
  56387. var waitOn = [];
  56388. WorkerTasks.forEach(function (task) {
  56389. waitOn.push(task.finished);
  56390. task.terminate();
  56391. });
  56392. return Promise.all(waitOn).then(function () {
  56393. handler.destroy();
  56394. handler = null;
  56395. });
  56396. });
  56397. handler.on('Ready', function wphReady(data) {
  56398. setupDoc(docParams);
  56399. docParams = null;
  56400. });
  56401. return workerHandlerName;
  56402. }
  56403. };
  56404. function initializeWorker() {
  56405. if (!('console' in globalScope)) {
  56406. var consoleTimer = {};
  56407. var workerConsole = {
  56408. log: function log() {
  56409. var args = Array.prototype.slice.call(arguments);
  56410. globalScope.postMessage({
  56411. targetName: 'main',
  56412. action: 'console_log',
  56413. data: args
  56414. });
  56415. },
  56416. error: function error() {
  56417. var args = Array.prototype.slice.call(arguments);
  56418. globalScope.postMessage({
  56419. targetName: 'main',
  56420. action: 'console_error',
  56421. data: args
  56422. });
  56423. throw 'pdf.js execution error';
  56424. },
  56425. time: function time(name) {
  56426. consoleTimer[name] = Date.now();
  56427. },
  56428. timeEnd: function timeEnd(name) {
  56429. var time = consoleTimer[name];
  56430. if (!time) {
  56431. error('Unknown timer name ' + name);
  56432. }
  56433. this.log('Timer:', name, Date.now() - time);
  56434. }
  56435. };
  56436. globalScope.console = workerConsole;
  56437. }
  56438. var handler = new MessageHandler('worker', 'main', self);
  56439. WorkerMessageHandler.setup(handler, self);
  56440. handler.send('ready', null);
  56441. }
  56442. if (typeof window === 'undefined' && !(typeof module !== 'undefined' && module.require)) {
  56443. initializeWorker();
  56444. }
  56445. exports.setPDFNetworkStreamClass = setPDFNetworkStreamClass;
  56446. exports.WorkerTask = WorkerTask;
  56447. exports.WorkerMessageHandler = WorkerMessageHandler;
  56448. }));
  56449. (function (root, factory) {
  56450. factory(root.pdfjsCoreNetwork = {}, root.pdfjsSharedUtil, root.pdfjsCoreWorker);
  56451. }(this, function (exports, sharedUtil, coreWorker) {
  56452. var OK_RESPONSE = 200;
  56453. var PARTIAL_CONTENT_RESPONSE = 206;
  56454. function NetworkManager(url, args) {
  56455. this.url = url;
  56456. args = args || {};
  56457. this.isHttp = /^https?:/i.test(url);
  56458. this.httpHeaders = this.isHttp && args.httpHeaders || {};
  56459. this.withCredentials = args.withCredentials || false;
  56460. this.getXhr = args.getXhr || function NetworkManager_getXhr() {
  56461. return new XMLHttpRequest();
  56462. };
  56463. this.currXhrId = 0;
  56464. this.pendingRequests = Object.create(null);
  56465. this.loadedRequests = Object.create(null);
  56466. }
  56467. function getArrayBuffer(xhr) {
  56468. var data = xhr.response;
  56469. if (typeof data !== 'string') {
  56470. return data;
  56471. }
  56472. var length = data.length;
  56473. var array = new Uint8Array(length);
  56474. for (var i = 0; i < length; i++) {
  56475. array[i] = data.charCodeAt(i) & 0xFF;
  56476. }
  56477. return array.buffer;
  56478. }
  56479. var supportsMozChunked = function supportsMozChunkedClosure() {
  56480. try {
  56481. var x = new XMLHttpRequest();
  56482. x.open('GET', 'https://example.com');
  56483. x.responseType = 'moz-chunked-arraybuffer';
  56484. return x.responseType === 'moz-chunked-arraybuffer';
  56485. } catch (e) {
  56486. return false;
  56487. }
  56488. }();
  56489. NetworkManager.prototype = {
  56490. requestRange: function NetworkManager_requestRange(begin, end, listeners) {
  56491. var args = {
  56492. begin: begin,
  56493. end: end
  56494. };
  56495. for (var prop in listeners) {
  56496. args[prop] = listeners[prop];
  56497. }
  56498. return this.request(args);
  56499. },
  56500. requestFull: function NetworkManager_requestFull(listeners) {
  56501. return this.request(listeners);
  56502. },
  56503. request: function NetworkManager_request(args) {
  56504. var xhr = this.getXhr();
  56505. var xhrId = this.currXhrId++;
  56506. var pendingRequest = this.pendingRequests[xhrId] = { xhr: xhr };
  56507. xhr.open('GET', this.url);
  56508. xhr.withCredentials = this.withCredentials;
  56509. for (var property in this.httpHeaders) {
  56510. var value = this.httpHeaders[property];
  56511. if (typeof value === 'undefined') {
  56512. continue;
  56513. }
  56514. xhr.setRequestHeader(property, value);
  56515. }
  56516. if (this.isHttp && 'begin' in args && 'end' in args) {
  56517. var rangeStr = args.begin + '-' + (args.end - 1);
  56518. xhr.setRequestHeader('Range', 'bytes=' + rangeStr);
  56519. pendingRequest.expectedStatus = 206;
  56520. } else {
  56521. pendingRequest.expectedStatus = 200;
  56522. }
  56523. var useMozChunkedLoading = supportsMozChunked && !!args.onProgressiveData;
  56524. if (useMozChunkedLoading) {
  56525. xhr.responseType = 'moz-chunked-arraybuffer';
  56526. pendingRequest.onProgressiveData = args.onProgressiveData;
  56527. pendingRequest.mozChunked = true;
  56528. } else {
  56529. xhr.responseType = 'arraybuffer';
  56530. }
  56531. if (args.onError) {
  56532. xhr.onerror = function (evt) {
  56533. args.onError(xhr.status);
  56534. };
  56535. }
  56536. xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
  56537. xhr.onprogress = this.onProgress.bind(this, xhrId);
  56538. pendingRequest.onHeadersReceived = args.onHeadersReceived;
  56539. pendingRequest.onDone = args.onDone;
  56540. pendingRequest.onError = args.onError;
  56541. pendingRequest.onProgress = args.onProgress;
  56542. xhr.send(null);
  56543. return xhrId;
  56544. },
  56545. onProgress: function NetworkManager_onProgress(xhrId, evt) {
  56546. var pendingRequest = this.pendingRequests[xhrId];
  56547. if (!pendingRequest) {
  56548. return;
  56549. }
  56550. if (pendingRequest.mozChunked) {
  56551. var chunk = getArrayBuffer(pendingRequest.xhr);
  56552. pendingRequest.onProgressiveData(chunk);
  56553. }
  56554. var onProgress = pendingRequest.onProgress;
  56555. if (onProgress) {
  56556. onProgress(evt);
  56557. }
  56558. },
  56559. onStateChange: function NetworkManager_onStateChange(xhrId, evt) {
  56560. var pendingRequest = this.pendingRequests[xhrId];
  56561. if (!pendingRequest) {
  56562. return;
  56563. }
  56564. var xhr = pendingRequest.xhr;
  56565. if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
  56566. pendingRequest.onHeadersReceived();
  56567. delete pendingRequest.onHeadersReceived;
  56568. }
  56569. if (xhr.readyState !== 4) {
  56570. return;
  56571. }
  56572. if (!(xhrId in this.pendingRequests)) {
  56573. return;
  56574. }
  56575. delete this.pendingRequests[xhrId];
  56576. if (xhr.status === 0 && this.isHttp) {
  56577. if (pendingRequest.onError) {
  56578. pendingRequest.onError(xhr.status);
  56579. }
  56580. return;
  56581. }
  56582. var xhrStatus = xhr.status || OK_RESPONSE;
  56583. var ok_response_on_range_request = xhrStatus === OK_RESPONSE && pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
  56584. if (!ok_response_on_range_request && xhrStatus !== pendingRequest.expectedStatus) {
  56585. if (pendingRequest.onError) {
  56586. pendingRequest.onError(xhr.status);
  56587. }
  56588. return;
  56589. }
  56590. this.loadedRequests[xhrId] = true;
  56591. var chunk = getArrayBuffer(xhr);
  56592. if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
  56593. var rangeHeader = xhr.getResponseHeader('Content-Range');
  56594. var matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
  56595. var begin = parseInt(matches[1], 10);
  56596. pendingRequest.onDone({
  56597. begin: begin,
  56598. chunk: chunk
  56599. });
  56600. } else if (pendingRequest.onProgressiveData) {
  56601. pendingRequest.onDone(null);
  56602. } else if (chunk) {
  56603. pendingRequest.onDone({
  56604. begin: 0,
  56605. chunk: chunk
  56606. });
  56607. } else if (pendingRequest.onError) {
  56608. pendingRequest.onError(xhr.status);
  56609. }
  56610. },
  56611. hasPendingRequests: function NetworkManager_hasPendingRequests() {
  56612. for (var xhrId in this.pendingRequests) {
  56613. return true;
  56614. }
  56615. return false;
  56616. },
  56617. getRequestXhr: function NetworkManager_getXhr(xhrId) {
  56618. return this.pendingRequests[xhrId].xhr;
  56619. },
  56620. isStreamingRequest: function NetworkManager_isStreamingRequest(xhrId) {
  56621. return !!this.pendingRequests[xhrId].onProgressiveData;
  56622. },
  56623. isPendingRequest: function NetworkManager_isPendingRequest(xhrId) {
  56624. return xhrId in this.pendingRequests;
  56625. },
  56626. isLoadedRequest: function NetworkManager_isLoadedRequest(xhrId) {
  56627. return xhrId in this.loadedRequests;
  56628. },
  56629. abortAllRequests: function NetworkManager_abortAllRequests() {
  56630. for (var xhrId in this.pendingRequests) {
  56631. this.abortRequest(xhrId | 0);
  56632. }
  56633. },
  56634. abortRequest: function NetworkManager_abortRequest(xhrId) {
  56635. var xhr = this.pendingRequests[xhrId].xhr;
  56636. delete this.pendingRequests[xhrId];
  56637. xhr.abort();
  56638. }
  56639. };
  56640. var assert = sharedUtil.assert;
  56641. var createPromiseCapability = sharedUtil.createPromiseCapability;
  56642. var isInt = sharedUtil.isInt;
  56643. var MissingPDFException = sharedUtil.MissingPDFException;
  56644. var UnexpectedResponseException = sharedUtil.UnexpectedResponseException;
  56645. function PDFNetworkStream(options) {
  56646. this._options = options;
  56647. var source = options.source;
  56648. this._manager = new NetworkManager(source.url, {
  56649. httpHeaders: source.httpHeaders,
  56650. withCredentials: source.withCredentials
  56651. });
  56652. this._rangeChunkSize = source.rangeChunkSize;
  56653. this._fullRequestReader = null;
  56654. this._rangeRequestReaders = [];
  56655. }
  56656. PDFNetworkStream.prototype = {
  56657. _onRangeRequestReaderClosed: function PDFNetworkStream_onRangeRequestReaderClosed(reader) {
  56658. var i = this._rangeRequestReaders.indexOf(reader);
  56659. if (i >= 0) {
  56660. this._rangeRequestReaders.splice(i, 1);
  56661. }
  56662. },
  56663. getFullReader: function PDFNetworkStream_getFullReader() {
  56664. assert(!this._fullRequestReader);
  56665. this._fullRequestReader = new PDFNetworkStreamFullRequestReader(this._manager, this._options);
  56666. return this._fullRequestReader;
  56667. },
  56668. getRangeReader: function PDFNetworkStream_getRangeReader(begin, end) {
  56669. var reader = new PDFNetworkStreamRangeRequestReader(this._manager, begin, end);
  56670. reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
  56671. this._rangeRequestReaders.push(reader);
  56672. return reader;
  56673. },
  56674. cancelAllRequests: function PDFNetworkStream_cancelAllRequests(reason) {
  56675. if (this._fullRequestReader) {
  56676. this._fullRequestReader.cancel(reason);
  56677. }
  56678. var readers = this._rangeRequestReaders.slice(0);
  56679. readers.forEach(function (reader) {
  56680. reader.cancel(reason);
  56681. });
  56682. }
  56683. };
  56684. function PDFNetworkStreamFullRequestReader(manager, options) {
  56685. this._manager = manager;
  56686. var source = options.source;
  56687. var args = {
  56688. onHeadersReceived: this._onHeadersReceived.bind(this),
  56689. onProgressiveData: source.disableStream ? null : this._onProgressiveData.bind(this),
  56690. onDone: this._onDone.bind(this),
  56691. onError: this._onError.bind(this),
  56692. onProgress: this._onProgress.bind(this)
  56693. };
  56694. this._url = source.url;
  56695. this._fullRequestId = manager.requestFull(args);
  56696. this._headersReceivedCapability = createPromiseCapability();
  56697. this._disableRange = options.disableRange || false;
  56698. this._contentLength = source.length;
  56699. this._rangeChunkSize = source.rangeChunkSize;
  56700. if (!this._rangeChunkSize && !this._disableRange) {
  56701. this._disableRange = true;
  56702. }
  56703. this._isStreamingSupported = false;
  56704. this._isRangeSupported = false;
  56705. this._cachedChunks = [];
  56706. this._requests = [];
  56707. this._done = false;
  56708. this._storedError = undefined;
  56709. this.onProgress = null;
  56710. }
  56711. PDFNetworkStreamFullRequestReader.prototype = {
  56712. _validateRangeRequestCapabilities: function PDFNetworkStreamFullRequestReader_validateRangeRequestCapabilities() {
  56713. if (this._disableRange) {
  56714. return false;
  56715. }
  56716. var networkManager = this._manager;
  56717. if (!networkManager.isHttp) {
  56718. return false;
  56719. }
  56720. var fullRequestXhrId = this._fullRequestId;
  56721. var fullRequestXhr = networkManager.getRequestXhr(fullRequestXhrId);
  56722. if (fullRequestXhr.getResponseHeader('Accept-Ranges') !== 'bytes') {
  56723. return false;
  56724. }
  56725. var contentEncoding = fullRequestXhr.getResponseHeader('Content-Encoding') || 'identity';
  56726. if (contentEncoding !== 'identity') {
  56727. return false;
  56728. }
  56729. var length = fullRequestXhr.getResponseHeader('Content-Length');
  56730. length = parseInt(length, 10);
  56731. if (!isInt(length)) {
  56732. return false;
  56733. }
  56734. this._contentLength = length;
  56735. if (length <= 2 * this._rangeChunkSize) {
  56736. return false;
  56737. }
  56738. return true;
  56739. },
  56740. _onHeadersReceived: function PDFNetworkStreamFullRequestReader_onHeadersReceived() {
  56741. if (this._validateRangeRequestCapabilities()) {
  56742. this._isRangeSupported = true;
  56743. }
  56744. var networkManager = this._manager;
  56745. var fullRequestXhrId = this._fullRequestId;
  56746. if (networkManager.isStreamingRequest(fullRequestXhrId)) {
  56747. this._isStreamingSupported = true;
  56748. } else if (this._isRangeSupported) {
  56749. networkManager.abortRequest(fullRequestXhrId);
  56750. }
  56751. this._headersReceivedCapability.resolve();
  56752. },
  56753. _onProgressiveData: function PDFNetworkStreamFullRequestReader_onProgressiveData(chunk) {
  56754. if (this._requests.length > 0) {
  56755. var requestCapability = this._requests.shift();
  56756. requestCapability.resolve({
  56757. value: chunk,
  56758. done: false
  56759. });
  56760. } else {
  56761. this._cachedChunks.push(chunk);
  56762. }
  56763. },
  56764. _onDone: function PDFNetworkStreamFullRequestReader_onDone(args) {
  56765. if (args) {
  56766. this._onProgressiveData(args.chunk);
  56767. }
  56768. this._done = true;
  56769. if (this._cachedChunks.length > 0) {
  56770. return;
  56771. }
  56772. this._requests.forEach(function (requestCapability) {
  56773. requestCapability.resolve({
  56774. value: undefined,
  56775. done: true
  56776. });
  56777. });
  56778. this._requests = [];
  56779. },
  56780. _onError: function PDFNetworkStreamFullRequestReader_onError(status) {
  56781. var url = this._url;
  56782. var exception;
  56783. if (status === 404 || status === 0 && /^file:/.test(url)) {
  56784. exception = new MissingPDFException('Missing PDF "' + url + '".');
  56785. } else {
  56786. exception = new UnexpectedResponseException('Unexpected server response (' + status + ') while retrieving PDF "' + url + '".', status);
  56787. }
  56788. this._storedError = exception;
  56789. this._headersReceivedCapability.reject(exception);
  56790. this._requests.forEach(function (requestCapability) {
  56791. requestCapability.reject(exception);
  56792. });
  56793. this._requests = [];
  56794. this._cachedChunks = [];
  56795. },
  56796. _onProgress: function PDFNetworkStreamFullRequestReader_onProgress(data) {
  56797. if (this.onProgress) {
  56798. this.onProgress({
  56799. loaded: data.loaded,
  56800. total: data.lengthComputable ? data.total : this._contentLength
  56801. });
  56802. }
  56803. },
  56804. get isRangeSupported() {
  56805. return this._isRangeSupported;
  56806. },
  56807. get isStreamingSupported() {
  56808. return this._isStreamingSupported;
  56809. },
  56810. get contentLength() {
  56811. return this._contentLength;
  56812. },
  56813. get headersReady() {
  56814. return this._headersReceivedCapability.promise;
  56815. },
  56816. read: function PDFNetworkStreamFullRequestReader_read() {
  56817. if (this._storedError) {
  56818. return Promise.reject(this._storedError);
  56819. }
  56820. if (this._cachedChunks.length > 0) {
  56821. var chunk = this._cachedChunks.shift();
  56822. return Promise.resolve(chunk);
  56823. }
  56824. if (this._done) {
  56825. return Promise.resolve({
  56826. value: undefined,
  56827. done: true
  56828. });
  56829. }
  56830. var requestCapability = createPromiseCapability();
  56831. this._requests.push(requestCapability);
  56832. return requestCapability.promise;
  56833. },
  56834. cancel: function PDFNetworkStreamFullRequestReader_cancel(reason) {
  56835. this._done = true;
  56836. this._headersReceivedCapability.reject(reason);
  56837. this._requests.forEach(function (requestCapability) {
  56838. requestCapability.resolve({
  56839. value: undefined,
  56840. done: true
  56841. });
  56842. });
  56843. this._requests = [];
  56844. if (this._manager.isPendingRequest(this._fullRequestId)) {
  56845. this._manager.abortRequest(this._fullRequestId);
  56846. }
  56847. this._fullRequestReader = null;
  56848. }
  56849. };
  56850. function PDFNetworkStreamRangeRequestReader(manager, begin, end) {
  56851. this._manager = manager;
  56852. var args = {
  56853. onDone: this._onDone.bind(this),
  56854. onProgress: this._onProgress.bind(this)
  56855. };
  56856. this._requestId = manager.requestRange(begin, end, args);
  56857. this._requests = [];
  56858. this._queuedChunk = null;
  56859. this._done = false;
  56860. this.onProgress = null;
  56861. this.onClosed = null;
  56862. }
  56863. PDFNetworkStreamRangeRequestReader.prototype = {
  56864. _close: function PDFNetworkStreamRangeRequestReader_close() {
  56865. if (this.onClosed) {
  56866. this.onClosed(this);
  56867. }
  56868. },
  56869. _onDone: function PDFNetworkStreamRangeRequestReader_onDone(data) {
  56870. var chunk = data.chunk;
  56871. if (this._requests.length > 0) {
  56872. var requestCapability = this._requests.shift();
  56873. requestCapability.resolve({
  56874. value: chunk,
  56875. done: false
  56876. });
  56877. } else {
  56878. this._queuedChunk = chunk;
  56879. }
  56880. this._done = true;
  56881. this._requests.forEach(function (requestCapability) {
  56882. requestCapability.resolve({
  56883. value: undefined,
  56884. done: true
  56885. });
  56886. });
  56887. this._requests = [];
  56888. this._close();
  56889. },
  56890. _onProgress: function PDFNetworkStreamRangeRequestReader_onProgress(evt) {
  56891. if (!this.isStreamingSupported && this.onProgress) {
  56892. this.onProgress({ loaded: evt.loaded });
  56893. }
  56894. },
  56895. get isStreamingSupported() {
  56896. return false;
  56897. },
  56898. read: function PDFNetworkStreamRangeRequestReader_read() {
  56899. if (this._queuedChunk !== null) {
  56900. var chunk = this._queuedChunk;
  56901. this._queuedChunk = null;
  56902. return Promise.resolve({
  56903. value: chunk,
  56904. done: false
  56905. });
  56906. }
  56907. if (this._done) {
  56908. return Promise.resolve({
  56909. value: undefined,
  56910. done: true
  56911. });
  56912. }
  56913. var requestCapability = createPromiseCapability();
  56914. this._requests.push(requestCapability);
  56915. return requestCapability.promise;
  56916. },
  56917. cancel: function PDFNetworkStreamRangeRequestReader_cancel(reason) {
  56918. this._done = true;
  56919. this._requests.forEach(function (requestCapability) {
  56920. requestCapability.resolve({
  56921. value: undefined,
  56922. done: true
  56923. });
  56924. });
  56925. this._requests = [];
  56926. if (this._manager.isPendingRequest(this._requestId)) {
  56927. this._manager.abortRequest(this._requestId);
  56928. }
  56929. this._close();
  56930. }
  56931. };
  56932. coreWorker.setPDFNetworkStreamClass(PDFNetworkStream);
  56933. exports.PDFNetworkStream = PDFNetworkStream;
  56934. exports.NetworkManager = NetworkManager;
  56935. }));
  56936. }.call(pdfjsLibs));
  56937. exports.PDFJS = pdfjsLibs.pdfjsDisplayGlobal.PDFJS;
  56938. exports.build = pdfjsLibs.pdfjsDisplayAPI.build;
  56939. exports.version = pdfjsLibs.pdfjsDisplayAPI.version;
  56940. exports.getDocument = pdfjsLibs.pdfjsDisplayAPI.getDocument;
  56941. exports.PDFDataRangeTransport = pdfjsLibs.pdfjsDisplayAPI.PDFDataRangeTransport;
  56942. exports.PDFWorker = pdfjsLibs.pdfjsDisplayAPI.PDFWorker;
  56943. exports.renderTextLayer = pdfjsLibs.pdfjsDisplayTextLayer.renderTextLayer;
  56944. exports.AnnotationLayer = pdfjsLibs.pdfjsDisplayAnnotationLayer.AnnotationLayer;
  56945. exports.CustomStyle = pdfjsLibs.pdfjsDisplayDOMUtils.CustomStyle;
  56946. exports.PasswordResponses = pdfjsLibs.pdfjsSharedUtil.PasswordResponses;
  56947. exports.InvalidPDFException = pdfjsLibs.pdfjsSharedUtil.InvalidPDFException;
  56948. exports.MissingPDFException = pdfjsLibs.pdfjsSharedUtil.MissingPDFException;
  56949. exports.SVGGraphics = pdfjsLibs.pdfjsDisplaySVG.SVGGraphics;
  56950. exports.UnexpectedResponseException = pdfjsLibs.pdfjsSharedUtil.UnexpectedResponseException;
  56951. exports.OPS = pdfjsLibs.pdfjsSharedUtil.OPS;
  56952. exports.UNSUPPORTED_FEATURES = pdfjsLibs.pdfjsSharedUtil.UNSUPPORTED_FEATURES;
  56953. exports.isValidUrl = pdfjsLibs.pdfjsDisplayDOMUtils.isValidUrl;
  56954. exports.createValidAbsoluteUrl = pdfjsLibs.pdfjsSharedUtil.createValidAbsoluteUrl;
  56955. exports.createObjectURL = pdfjsLibs.pdfjsSharedUtil.createObjectURL;
  56956. exports.removeNullCharacters = pdfjsLibs.pdfjsSharedUtil.removeNullCharacters;
  56957. exports.shadow = pdfjsLibs.pdfjsSharedUtil.shadow;
  56958. exports.createBlob = pdfjsLibs.pdfjsSharedUtil.createBlob;
  56959. exports.getFilenameFromUrl = pdfjsLibs.pdfjsDisplayDOMUtils.getFilenameFromUrl;
  56960. exports.addLinkAttributes = pdfjsLibs.pdfjsDisplayDOMUtils.addLinkAttributes;
  56961. }));